Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
frontend: search jumps to messages older than the latest 100 (batch2 F)
Lin (kwant bot)bef8f554122d
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex d8d993d8..af7b4bec 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -139,6 +139,9 @@ export const App: React.FC = () => {const [isRoutinesOpen, setIsRoutinesOpen] = useState(false);const [editingChannelInstructions, setEditingChannelInstructions] = useState<Channel | null>(null);const [highlightMessageId, setHighlightMessageId] = useState<string | null>(null);+ // Older messages shown instead of the latest (a search hit beyond them). Kept apart from the+ // cache, which live updates keep current underneath.+ const [historyWindow, setHistoryWindow] = useState<{ ctx: string; messages: ChatMessage[] } | null>(null);const [profiles, setProfiles] = useState<Profile[]>([]);const [toasts, setToasts] = useState<Toast[]>([]);const toastIdRef = useRef(0);@@ -358,6 +361,7 @@ export const App: React.FC = () => {// The open chat (channel, direct chat or thread): show what's cached, then load the latest.useEffect(() => {+ setHistoryWindow((w) => (w && w.ctx !== openCtx ? null : w));if (!openCtx) return;const b = streamsRef.current[openCtx];setStreamingText(b?.text ?? '');@@ -842,6 +846,7 @@ export const App: React.FC = () => {};const handleSendMessage = async (text: string, attachments: AttachmentRef[] = []) => {+ setHistoryWindow(null);const targetId = openCtx;const threadId = openThreadId;const isTargetChannel = isChannel;@@ -1167,7 +1172,8 @@ export const App: React.FC = () => {);};- // Search result picked: open its chat, then scroll to the message if it's among the ones loaded.+ // Search result picked: open its chat and scroll to the message, loading the messages around it+ // when it's older than the latest page.const handleJump = async (hit: SearchHit) => {const targetId = hit.channel_id ?? hit.kwant_id;if (!targetId || !openTarget(hit)) {@@ -1180,8 +1186,23 @@ export const App: React.FC = () => {const data: ChatMessage[] = await res.json();messagesCacheRef.current[targetId] = data;if (selectedIdRef.current === targetId) setMessages(data);- if (data.some((m) => m.id === hit.message_id)) setHighlightMessageId(hit.message_id);- else pushToast('Opened the chat', 'That message is older than the latest 100 shown here.');+ if (data.some((m) => m.id === hit.message_id)) {+ setHistoryWindow(null);+ setHighlightMessageId(hit.message_id);+ return;+ }+ const around = await fetch(+ `/api/channels/${encodeURIComponent(targetId)}/messages?around=${encodeURIComponent(hit.message_id)}`,+ );+ if (around.status === 404) {+ pushToast('Opened the chat', 'That message is no longer there.');+ return;+ }+ if (!around.ok) throw new Error(`HTTP ${around.status}`);+ const older: ChatMessage[] = await around.json();+ if (selectedIdRef.current !== targetId) return;+ setHistoryWindow({ ctx: targetId, messages: older });+ setHighlightMessageId(hit.message_id);} catch {pushToast('Could not load that chat.');}@@ -1693,6 +1714,7 @@ export const App: React.FC = () => {busyKwants[t.kwant_id] = `${t.state === 'queued' ? 'Waiting to work on' : awaitingTurns.has(t.turn_id) ? 'Asked you a question in' : 'Working on'} ${describeContext(t.context_id, t.kwant_id)}`;}+ const viewingHistory = !!historyWindow && historyWindow.ctx === openCtx;const errorBar = messagesError ? (<div role="alert" className="px-3 sm:px-6 py-2 border-b border-rose-500/20 bg-rose-500/5 flex items-center gap-2 text-xs text-rose-300"><span>{messagesError}</span>@@ -1799,7 +1821,9 @@ export const App: React.FC = () => {<ChatViewtitle={chatTitle}subtitle={chatSubtitle}- messages={messages}+ messages={viewingHistory ? historyWindow.messages : messages}+ viewingHistory={viewingHistory}+ onJumpToLatest={() => setHistoryWindow(null)}streamingText={isCurrentContextStreaming ? streamingText : ''}streamingThinking={isCurrentContextStreaming ? streamingThinking : ''}pendingApproval={pendingApproval}diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex 72c65ab5..9bfce535 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -1,5 +1,5 @@import React, { useState, useRef, useEffect } from 'react';-import { ArrowUp, Paperclip, Sparkles, ChevronDown, ChevronRight, Copy, Check, Cpu, Users, Square, Settings2, Folder, GitBranch, Pencil, Pin } from 'lucide-react';+import { ArrowDown, ArrowUp, Paperclip, Sparkles, ChevronDown, ChevronRight, Copy, Check, Cpu, Users, Square, Settings2, Folder, GitBranch, Pencil, Pin } from 'lucide-react';import { ModernAvatar } from './ModernAvatar';import { ModernApprovalCard, PendingApproval } from './ModernApprovalCard';import { MentionPopover, MentionItem } from './MentionPopover';@@ -126,6 +126,10 @@ export interface ChatViewProps {/** A message to scroll to and flash (from search). */highlightMessageId?: string | null;onHighlightDone?: () => void;+ /** Set while `messages` is an older window (a search hit beyond the latest page). */+ viewingHistory?: boolean;+ /** Leaves that window for the latest messages. */+ onJumpToLatest?: () => void;/** Under the header: the agent's conversations and the open thread's controls. */subHeader?: React.ReactNode;/** Next to the title, e.g. "Working on …" while the agent has background turns. */@@ -268,6 +272,8 @@ export const ChatView: React.FC<ChatViewProps> = ({onEditInstructions,highlightMessageId,onHighlightDone,+ viewingHistory,+ onJumpToLatest,subHeader,titleExtra,queued,@@ -419,6 +425,10 @@ export const ChatView: React.FC<ChatViewProps> = ({useEffect(() => {stickRef.current = true;}, [contextKey]);+ // Back from an older window: land on the newest message+ useEffect(() => {+ if (!viewingHistory) stickRef.current = true;+ }, [viewingHistory]);useEffect(() => {if (scrollRef.current && stickRef.current) {scrollRef.current.scrollTop = scrollRef.current.scrollHeight;@@ -1059,6 +1069,22 @@ export const ChatView: React.FC<ChatViewProps> = ({</div>)}+ {viewingHistory && (+ <div role="status" className="max-w-4xl mx-auto mb-2 flex items-center justify-between gap-2 px-3 py-1.5 rounded-xl border border-sky-800/50 bg-sky-950/40 text-xs text-sky-200">+ <span className="min-w-0">Showing older messages around the search result.</span>+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onJumpToLatest?.();+ }}+ className="shrink-0 flex items-center gap-1 px-2 py-0.5 rounded-lg border border-sky-700/60 text-sky-100 hover:bg-sky-900/60 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ >+ <ArrowDown size={12} aria-hidden="true" /> Jump to latest+ </button>+ </div>+ )}+<formonSubmit={handleSubmit}{...dropHandlers}