Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(chat): every conversation in the history opens, and all of them are reachable
rubenluetke10-beep659812ea7d60
diff --git a/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx b/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsxnew file mode 100644index 0000000000..37d00a24c7--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx@@ -0,0 +1,271 @@+import { useEffect, useMemo, useRef, useState } from "react";+import * as Dialog from "@radix-ui/react-dialog";+import { MessageSquare, Mic, Search, Trash2, X } from "lucide-react";++import { useT } from "@/i18n";+import { cn } from "@/lib/utils";+import {+ filterChatRows,+ formatChatWhen,+ groupChatRows,+ useChatRows,+ type ChatRow,+} from "@/components/home/chatRows";++/**+ * "All chats" — the whole history, not the handful the sidebar has room for.+ *+ * The sidebar block is a shortcut to what you touched last; this is the+ * archive: every voice session and every agent chat, searchable, grouped by+ * day like a mail client, opening on the same click path as the sidebar+ * (components/home/chatRows). Modelled on the recents dialog desktop chat+ * apps use — one field, one list, Escape closes — because a second full+ * SECTION for the same data would be one more place to keep in sync.+ *+ * The list is whatever the two pollers already hold, so opening the dialog+ * costs no request; the sidebar refreshes both lists every few seconds.+ */+export function AllChatsDialog({+ open,+ onOpenChange,+}: {+ open: boolean;+ onOpenChange: (open: boolean) => void;+}) {+ const t = useT();+ const { rows, isActive, open: openRow, remove } = useChatRows();+ const [query, setQuery] = useState("");+ const [kind, setKind] = useState<"all" | "agent" | "voice">("all");+ const searchRef = useRef<HTMLInputElement | null>(null);++ // A reopened dialog starts clean — a stale filter hiding the chat someone+ // came looking for is the one failure this surface must not have.+ useEffect(() => {+ if (open) {+ setQuery("");+ setKind("all");+ }+ }, [open]);++ const visible = useMemo(() => {+ const byKind = kind === "all" ? rows : rows.filter((r) => r.kind === kind);+ return filterChatRows(byKind, query);+ }, [kind, query, rows]);+ const groups = useMemo(() => groupChatRows(visible), [visible]);++ const counts = useMemo(+ () => ({+ all: rows.length,+ agent: rows.filter((r) => r.kind === "agent").length,+ voice: rows.filter((r) => r.kind === "voice").length,+ }),+ [rows],+ );++ return (+ <Dialog.Root open={open} onOpenChange={onOpenChange}>+ <Dialog.Portal>+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-[#090909]/70 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />+ <Dialog.Content+ data-testid="all-chats-dialog"+ onOpenAutoFocus={(e) => {+ e.preventDefault();+ searchRef.current?.focus();+ }}+ className={cn(+ "fixed left-1/2 top-1/2 z-[90] flex max-h-[min(84dvh,44rem)] w-[min(680px,calc(100vw-2rem))]",+ "-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border",+ "bg-card shadow-[0_28px_90px_-24px_rgba(0,0,0,0.6)] outline-none",+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none",+ )}+ >+ <header className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">+ <div className="min-w-0">+ <Dialog.Title className="font-display text-base font-semibold tracking-tight text-foreground">+ {t("all_chats.title")}+ </Dialog.Title>+ <Dialog.Description className="mt-0.5 text-xs leading-relaxed text-muted-foreground">+ {t("all_chats.description")}+ </Dialog.Description>+ </div>+ <Dialog.Close asChild>+ <button+ type="button"+ aria-label={t("all_chats.close")}+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ >+ <X className="h-4 w-4" aria-hidden />+ </button>+ </Dialog.Close>+ </header>++ <div className="flex flex-col gap-3 border-b border-border px-5 py-3">+ <div className="relative">+ <Search+ aria-hidden+ className="pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"+ />+ <input+ ref={searchRef}+ type="text"+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ placeholder={t("all_chats.search_placeholder")}+ aria-label={t("all_chats.search_placeholder")}+ data-testid="all-chats-search"+ className={cn(+ "w-full rounded-xl border border-border bg-background/60 py-2 pl-9 pr-3 text-sm text-foreground",+ "placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ )}+ />+ </div>+ <div className="flex items-center gap-1.5">+ <FilterChip+ label={t("all_chats.filter_all")}+ count={counts.all}+ selected={kind === "all"}+ onClick={() => setKind("all")}+ />+ <FilterChip+ label={t("all_chats.filter_chats")}+ count={counts.agent}+ selected={kind === "agent"}+ onClick={() => setKind("agent")}+ />+ <FilterChip+ label={t("all_chats.filter_voice")}+ count={counts.voice}+ selected={kind === "voice"}+ onClick={() => setKind("voice")}+ />+ </div>+ </div>++ <div className="min-h-0 flex-1 overflow-y-auto px-3 py-3 scrollbar-jarvis">+ {visible.length === 0 ? (+ <p className="px-2 py-10 text-center text-xs text-muted-foreground">+ {rows.length === 0 ? t("all_chats.empty") : t("all_chats.no_match")}+ </p>+ ) : (+ groups.map(({ bucket, rows: group }) => (+ <section key={bucket} className="mb-3 last:mb-0">+ <h3 className="px-2 pb-1 font-mono text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground">+ {t(`all_chats.group_${bucket}`)}+ </h3>+ <ul className="space-y-px">+ {group.map((row) => (+ <ArchiveRow+ key={`${row.kind}-${row.id}`}+ row={row}+ active={isActive(row)}+ onOpen={() => {+ openRow(row);+ onOpenChange(false);+ }}+ onDelete={row.kind === "agent" ? () => remove(row) : undefined}+ />+ ))}+ </ul>+ </section>+ ))+ )}+ </div>+ </Dialog.Content>+ </Dialog.Portal>+ </Dialog.Root>+ );+}++function FilterChip({+ label,+ count,+ selected,+ onClick,+}: {+ label: string;+ count: number;+ selected: boolean;+ onClick: () => void;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ aria-pressed={selected}+ className={cn(+ "flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-[11px] font-medium transition-colors",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ selected+ ? "border-primary/40 bg-primary/10 text-primary"+ : "border-border text-muted-foreground hover:bg-background/60 hover:text-foreground",+ )}+ >+ {label}+ <span className={cn("font-mono tabular-nums", selected ? "text-primary/70" : "text-muted-foreground/70")}>+ {count}+ </span>+ </button>+ );+}++function ArchiveRow({+ row,+ active,+ onOpen,+ onDelete,+}: {+ row: ChatRow;+ active: boolean;+ onOpen: () => void;+ onDelete?: () => void;+}) {+ const t = useT();+ const isVoice = row.kind === "voice";+ const Icon = isVoice ? Mic : MessageSquare;+ const title = row.title || t("chats_view.new_chat");+ const preview = row.preview && row.preview !== title ? row.preview : "";+ return (+ <li className="group relative">+ <button+ type="button"+ onClick={onOpen}+ title={title}+ data-testid="all-chats-row"+ data-kind={row.kind}+ className={cn(+ "flex w-full items-start gap-2.5 rounded-xl px-2.5 py-2 text-left transition-colors",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ active ? "bg-background/80 shadow-sm" : "hover:bg-background/50",+ )}+ >+ <Icon+ aria-hidden+ className={cn("mt-0.5 h-3.5 w-3.5 shrink-0", active ? "text-primary" : "text-muted-foreground")}+ />+ <span className="min-w-0 flex-1">+ <span className="block truncate text-xs font-medium text-foreground">{title}</span>+ {preview && (+ <span className="mt-0.5 block truncate text-[11px] text-muted-foreground">{preview}</span>+ )}+ </span>+ <span className="mt-0.5 shrink-0 pr-6 font-mono text-[10px] tabular-nums text-muted-foreground">+ {formatChatWhen(row.updatedMs)}+ </span>+ </button>+ {onDelete && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ onDelete();+ }}+ title={t("chats_view.delete")}+ aria-label={t("chats_view.delete")}+ className="absolute right-1.5 top-2 hidden rounded-md bg-card p-1 text-muted-foreground transition-colors hover:bg-destructive/15 hover:text-destructive group-hover:block"+ >+ <Trash2 className="h-3 w-3" aria-hidden />+ </button>+ )}+ </li>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsxindex 0c8daf0dfd..241381c524 100644--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx@@ -84,6 +84,12 @@ describe("ChatStage (agent chat)", () => {writable: true,value: scrollTo,});+ // jsdom implements neither; the column scrolls with one or the other.+ Object.defineProperty(HTMLElement.prototype, "scrollIntoView", {+ configurable: true,+ writable: true,+ value: vi.fn(),+ });window.localStorage.clear();useEventStore.setState({ connected: true, wsWarming: false, assistantName: "Jarvis" });useAgentChatStore.setState({@@ -375,4 +381,52 @@ describe("ChatStage (agent chat)", () => {expect(footer.textContent).toContain("219");expect(footer.textContent).toContain("$0.8483");});++ it("reads an opened voice session in the chat column instead of the previous chat", () => {+ // The regression this guards: the sidebar's history lists voice sessions+ // next to agent chats, and clicking one used to load its words into the+ // event store while the stage kept rendering the agent timeline — the+ // screen did not change at all.+ const timeline = reduceEvents(EMPTY_TIMELINE, [+ ev("user_message", { turn_id: "t1", text: "Earlier agent chat" }),+ ]);+ useAgentChatStore.setState({ activeSessionId: null, timeline });+ useEventStore.setState({+ activeKind: "voice",+ activeThreadId: "v1",+ conversations: [+ {+ kind: "voice",+ id: "v1",+ title: "Kitchen timer",+ preview: "set a timer",+ created_ms: 1,+ updated_ms: 2,+ message_count: 2,+ },+ ],+ messages: [+ { id: "m1", role: "user", content: "set a timer", ts: 1 },+ { id: "m2", role: "assistant", content: "Ten minutes, running.", ts: 2 },+ ],+ thinkingTraces: {},+ });+ render(<ChatStage />);++ const stage = screen.getByTestId("voice-thread-stage");+ expect(stage.getAttribute("data-thread")).toBe("v1");+ expect(stage.textContent).toContain("Kitchen timer");+ expect(stage.textContent).toContain("Ten minutes, running.");+ // A spoken thread has no composer: it is continued by talking.+ expect(screen.queryByTestId("agent-composer")).toBeNull();+ expect(screen.getByTestId("continue-by-voice")).toBeTruthy();+ });++ it("gives the stage back to the agent chat once a session is open", () => {+ useEventStore.setState({ activeKind: "voice", activeThreadId: "v1", messages: [] });+ useAgentChatStore.setState({ activeSessionId: "s1", timeline: EMPTY_TIMELINE });+ render(<ChatStage />);+ expect(screen.queryByTestId("voice-thread-stage")).toBeNull();+ expect(screen.getByTestId("chat-stage")).toBeTruthy();+ });});diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsxindex 4fde7384c5..13de25e3f7 100644--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx@@ -6,6 +6,7 @@ import { ScrollArea } from "@/components/ui/scroll-area";import { AgentComposer } from "@/components/agentchat/AgentComposer";import { AgentTimeline } from "@/components/agentchat/AgentTimeline";import { Greeting } from "@/components/home/Greeting";+import { VoiceThreadStage } from "@/components/home/VoiceThreadStage";import type { ApprovalDecision } from "@/lib/agentChatApi";import { useT } from "@/i18n";@@ -24,6 +25,13 @@ import { useT } from "@/i18n";* scrolls and the composer docks to the bottom. The history is the* sidebar's (components/home/RecentChats), visible from every section.*+ * One conversation is on stage at a time. The sidebar's history mixes agent+ * chats with VOICE sessions, and a voice session opened from here is read in+ * components/home/VoiceThreadStage — the same column, no composer. Which of+ * the two shows is decided by the event store's active thread: opening either+ * kind clears the other (components/home/chatRows), so the two can never both+ * claim the stage and leave a click looking like it did nothing.+ ** Scrolling follows the Claude app: when the person sends, their message* is brought to the TOP of the scroll area and the answer grows below it —* the eye stays where the new turn begins instead of chasing the bottom.@@ -40,6 +48,7 @@ export function ChatStage() {const decide = useAgentChatStore((s) => s.decide);const loadCatalog = useAgentChatStore((s) => s.loadCatalog);const loadSessions = useAgentChatStore((s) => s.loadSessions);+ const voiceThreadId = useEventStore((s) => (s.activeKind === "voice" ? s.activeThreadId : null));const hasContent = items.length > 0;useEffect(() => {@@ -124,6 +133,10 @@ export function ChatStage() {const subtitle = useMemo(() => t("agent_chat.empty_subtitle"), [t]);+ // A spoken thread was opened from the history: read it here, in the column+ // the composer would otherwise own. An agent chat opening clears this.+ if (voiceThreadId && !activeSessionId) return <VoiceThreadStage />;+if (!hasContent) {return (<div className="flex min-h-0 flex-1 flex-col items-center" data-testid="chat-stage" data-empty="true">diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsxindex 8561c15db4..e8f69ae5ad 100644--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx@@ -10,6 +10,8 @@ function row(kind: ConversationSummary["kind"], id: string, title: string): Convreturn { kind, id, title, preview: title, created_ms: 500, updated_ms: 1_000, message_count: 2 };}+const CONVERSATIONS = [row("voice", "v1", "Spoken thread"), row("text", "t1", "Typed thread")];+const DETAIL = {kind: "voice",id: "v1",@@ -35,11 +37,13 @@ describe("RecentChats", () => {vi.fn(async (url: string) =>String(url).endsWith("/resume")? new Response(JSON.stringify(DETAIL), { status: 200 })- : new Response(JSON.stringify([]), { status: 200 }),+ : // The block polls GET /api/chats on mount; answering with the same+ // rows keeps the refresh from wiping what the test just seeded.+ new Response(JSON.stringify(CONVERSATIONS), { status: 200 }),),);useEventStore.setState({- conversations: [row("voice", "v1", "Spoken thread"), row("text", "t1", "Typed thread")],+ conversations: CONVERSATIONS,activeThreadId: null,messages: [],activeSection: "board",@@ -64,6 +68,7 @@ describe("RecentChats", () => {],activeSessionId: null,loadSessions: async () => {},+ newChat: vi.fn(),openSession: vi.fn((id: string) => useAgentChatStore.setState({ activeSessionId: id })),});});@@ -98,12 +103,49 @@ describe("RecentChats", () => {expect(useHomeStore.getState().transcript).toEqual([]);});- it("opens a voice session on the chat surface when that is where you are", async () => {+ it("clears the voice thread when an agent chat takes the stage", async () => {+ useEventStore.setState({ activeKind: "voice", activeThreadId: "v1" });+ render(<RecentChats />);+ fireEvent.click(screen.getByTitle("Agent chat"));+ await flush();+ // Both conversations claiming the stage is what made a click look like it+ // did nothing: the chat stage kept showing the previous one.+ expect(useEventStore.getState().activeThreadId).toBeNull();+ expect(useEventStore.getState().messages).toEqual([]);+ });++ it("loads a voice session onto the chat surface when that is where you are", async () => {useHomeStore.setState({ surface: "chat" });render(<RecentChats />);fireEvent.click(screen.getByTitle("Spoken thread"));await flush();expect(useHomeStore.getState().surface).toBe("chat");+ // Read on the chat stage (components/home/VoiceThreadStage), not seeded+ // into the voice lane — and the agent session is ended so it cannot keep+ // the stage.+ expect(useEventStore.getState().activeThreadId).toBe("v1");+ expect(useEventStore.getState().messages.map((m) => m.content)).toEqual(["hello", "Hi there."]);+ expect(useAgentChatStore.getState().newChat).toHaveBeenCalled();expect(useHomeStore.getState().transcript).toEqual([]);});++ it("offers the whole archive behind one button", async () => {+ render(<RecentChats />);+ fireEvent.click(screen.getByTestId("see-all-chats"));+ await flush();+ expect(screen.getByTestId("all-chats-dialog")).toBeTruthy();+ // Both kinds are listed there, whatever the sidebar had room for.+ const rows = screen.getAllByTestId("all-chats-row");+ expect(rows.map((r) => r.getAttribute("data-kind")).sort()).toEqual(["agent", "voice"]);+ });++ it("filters the archive by what you type", async () => {+ render(<RecentChats />);+ fireEvent.click(screen.getByTestId("see-all-chats"));+ await flush();+ fireEvent.change(screen.getByTestId("all-chats-search"), { target: { value: "spoken" } });+ const rows = screen.getAllByTestId("all-chats-row");+ expect(rows).toHaveLength(1);+ expect(rows[0].getAttribute("data-kind")).toBe("voice");+ });});diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsxindex 819be8fa96..a917973744 100644--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx@@ -1,14 +1,12 @@-import { useEffect, useMemo, useState } from "react";-import { MessageSquare, Mic, Trash2 } from "lucide-react";+import { useEffect, useState } from "react";+import { Archive, MessageSquare, Mic, Trash2 } from "lucide-react";-import { useConversations } from "@/hooks/useConversations";-import { useEventStore, type ConversationSummary } from "@/store/events";import { useAgentChatStore } from "@/store/agentChat";-import { useHomeStore } from "@/store/home";import { useT } from "@/i18n";-import { transcriptFromMessages } from "@/lib/homeTranscript";import { cn } from "@/lib/utils";import { SidebarGroup } from "@/components/home/SidebarGroup";+import { AllChatsDialog } from "@/components/home/AllChatsDialog";+import { formatChatWhen, useChatRows, type ChatRow } from "@/components/home/chatRows";import { CONVERSATIONS_REFRESH_MS } from "@/hooks/useConversations";export const RECENT_CHATS_FOLDED = 3;@@ -20,13 +18,17 @@ export const RECENT_CHATS_UNFOLDED = 15;* histories (`useConversations({ poll: true })` for the voice sessions,* the agent-chat store's session list for the typed ones).*+ * It is a shortcut, not the archive: it shows the handful you touched last+ * and hands everything else to "All chats" (components/home/AllChatsDialog),+ * where the whole history is searchable. Both open a row through the same+ * `useChatRows().open`, so a click behaves identically in either place.+ ** Opening a row resumes it and lands on the surface that fits (maintainer,* 2026-08-23): a VOICE session opened while the voice stage is up stays* there, its words loaded into the transcript lane, so you just keep- * talking. An agent chat goes to the chat surface, where the session is- * read and continued by typing — on the provider and model it was using,- * which the composer shows. Reading the surface at click time, not via a- * subscription, keeps the list from re-rendering on every switch.+ * talking. Opened from the chat surface it is read there as an archive.+ * An agent chat goes to the chat surface, where the session is read and+ * continued by typing — on the provider and model it was using.** The classic brain's text threads are no longer listed: since the chat* surface became the agent chat there is nowhere to open them; the data@@ -34,17 +36,10 @@ export const RECENT_CHATS_UNFOLDED = 15;*/export function RecentChats() {const t = useT();- const { conversations, openConversation } = useConversations({ poll: true });- const sessions = useAgentChatStore((s) => s.sessions);- const activeSessionId = useAgentChatStore((s) => s.activeSessionId);+ const { rows, isActive, open: openRow, remove } = useChatRows({ poll: true });const loadSessions = useAgentChatStore((s) => s.loadSessions);- const openSession = useAgentChatStore((s) => s.openSession);- const removeSession = useAgentChatStore((s) => s.removeSession);const [open, setOpen] = useState(false);- const setActive = useEventStore((s) => s.setActiveSection);- const activeVoiceId = useEventStore((s) => (s.activeKind === "voice" ? s.activeThreadId : null));- const setSurface = useHomeStore((s) => s.setSurface);- const seedTranscript = useHomeStore((s) => s.seedTranscript);+ const [archiveOpen, setArchiveOpen] = useState(false);useEffect(() => {void loadSessions();@@ -52,88 +47,74 @@ export function RecentChats() {return () => window.clearInterval(id);}, [loadSessions]);- const rows = useMemo<RecentRow[]>(() => {- const voice: RecentRow[] = conversations- .filter((c) => c.kind === "voice")- .map((c) => ({ kind: "voice", id: c.id, title: c.title || c.preview, updatedMs: c.updated_ms, raw: c }));- const agent: RecentRow[] = sessions.map((s) => ({- kind: "agent",- id: s.session_id,- title: s.title || s.preview,- updatedMs: s.updated_ms,- raw: null,- }));- return [...voice, ...agent].sort((a, b) => b.updatedMs - a.updatedMs);- }, [conversations, sessions]);-- const openRow = (row: RecentRow) => {- if (row.kind === "voice" && row.raw) {- const stayOnVoice = useHomeStore.getState().surface === "voice";- const opened = openConversation("voice", row.id);- if (stayOnVoice) {- void opened.then((messages) => seedTranscript(transcriptFromMessages(messages)));- } else {- void opened;- setSurface("chat");- }- } else {- openSession(row.id);- setSurface("chat");- }- setActive("chats");- };-const shown = rows.slice(0, open ? RECENT_CHATS_UNFOLDED : RECENT_CHATS_FOLDED);const canExpand = rows.length > RECENT_CHATS_FOLDED;+ // The archive earns its place only once the sidebar cannot show everything.+ const hidden = rows.length - shown.length;return (- <SidebarGroup- title={t("sidebar.recent_chats")}- action={- canExpand- ? {- label: open ? t("sidebar.show_less") : t("sidebar.show_all"),- onClick: () => setOpen((v) => !v),- expanded: open,- }- : undefined- }- testId="recent-chats"- >- {shown.length === 0 ? (- <p className="px-2 py-1 text-[11px] text-muted-foreground/70">{t("sidebar.no_chats")}</p>- ) : (- <ul className="space-y-px">- {shown.map((row) => (- <ChatRow- key={`${row.kind}-${row.id}`}- row={row}- active={row.kind === "agent" ? row.id === activeSessionId : row.id === activeVoiceId}- onOpen={() => openRow(row)}- onDelete={row.kind === "agent" ? () => void removeSession(row.id) : undefined}- />- ))}- </ul>- )}- </SidebarGroup>+ <>+ <SidebarGroup+ title={t("sidebar.recent_chats")}+ action={+ canExpand+ ? {+ label: open ? t("sidebar.show_less") : t("sidebar.show_all"),+ onClick: () => setOpen((v) => !v),+ expanded: open,+ }+ : undefined+ }+ testId="recent-chats"+ >+ {shown.length === 0 ? (+ <p className="px-2 py-1 text-[11px] text-muted-foreground/70">{t("sidebar.no_chats")}</p>+ ) : (+ <ul className="space-y-px">+ {shown.map((row) => (+ <ChatRowItem+ key={`${row.kind}-${row.id}`}+ row={row}+ active={isActive(row)}+ onOpen={() => openRow(row)}+ onDelete={row.kind === "agent" ? () => remove(row) : undefined}+ />+ ))}+ </ul>+ )}+ {rows.length > 0 && (+ <button+ type="button"+ onClick={() => setArchiveOpen(true)}+ data-testid="see-all-chats"+ className={cn(+ "mt-0.5 flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors",+ "text-muted-foreground hover:bg-background/60 hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ )}+ >+ <Archive aria-hidden className="h-3.5 w-3.5 shrink-0" />+ <span className="min-w-0 flex-1 truncate text-xs">{t("sidebar.see_all_chats")}</span>+ {hidden > 0 && (+ <span className="shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/70">+ +{hidden}+ </span>+ )}+ </button>+ )}+ </SidebarGroup>+ <AllChatsDialog open={archiveOpen} onOpenChange={setArchiveOpen} />+ </>);}-interface RecentRow {- kind: "voice" | "agent";- id: string;- title: string;- updatedMs: number;- raw: ConversationSummary | null;-}--function ChatRow({+function ChatRowItem({row,active,onOpen,onDelete,}: {- row: RecentRow;+ row: ChatRow;active: boolean;onOpen: () => void;onDelete?: () => void;@@ -162,7 +143,7 @@ function ChatRow({/><span className="min-w-0 flex-1 truncate text-xs text-foreground">{title}</span><span className="shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground">- {formatWhen(row.updatedMs)}+ {formatChatWhen(row.updatedMs)}</span></button>{onDelete && (@@ -182,14 +163,3 @@ function ChatRow({</li>);}--function formatWhen(ms: number): string {- if (!ms) return "";- const d = new Date(ms);- const today = new Date();- today.setHours(0, 0, 0, 0);- if (d.getTime() >= today.getTime()) {- return d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });- }- return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });-}diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceThreadStage.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceThreadStage.tsxnew file mode 100644index 0000000000..a6c80a43b9--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/home/VoiceThreadStage.tsx@@ -0,0 +1,143 @@+import { useEffect, useMemo, useRef } from "react";+import { AudioLines, Mic } from "lucide-react";++import { useEventStore, type ChatMessage } from "@/store/events";+import { useHomeStore } from "@/store/home";+import { ScrollArea } from "@/components/ui/scroll-area";+import { ThoughtTraceDisclosure } from "@/components/ThinkingTrace";+import { transcriptFromMessages } from "@/lib/homeTranscript";+import { fill, useT } from "@/i18n";+import { cn } from "@/lib/utils";++/**+ * A spoken conversation, read on the chat surface.+ *+ * The sidebar's history mixes voice sessions with agent chats, so a click+ * has to land somewhere for BOTH. An agent chat opens in the agent timeline+ * next door; a voice session opens here — the same centred column, the words+ * as they were said, the reasoning steps that were kept, and no composer,+ * because a spoken thread is continued by speaking. Until this existed,+ * clicking a voice row while the chat surface was up changed nothing on+ * screen: the words were loaded into a store the stage did not read.+ *+ * "Continue by voice" hands the thread to the voice stage with its words+ * already in the lane — the same seeding the sidebar does when you open a+ * voice session while standing on that stage.+ */+export function VoiceThreadStage() {+ const t = useT();+ const messages = useEventStore((s) => s.messages);+ const activeThreadId = useEventStore((s) => s.activeThreadId);+ const conversations = useEventStore((s) => s.conversations);+ const setSurface = useHomeStore((s) => s.setSurface);+ const seedTranscript = useHomeStore((s) => s.seedTranscript);++ const title = useMemo(+ () => conversations.find((c) => c.kind === "voice" && c.id === activeThreadId)?.title ?? "",+ [activeThreadId, conversations],+ );++ const endRef = useRef<HTMLDivElement | null>(null);+ // A reopened thread lands at its end, where the conversation stopped.+ useEffect(() => {+ endRef.current?.scrollIntoView({ block: "end" });+ }, [activeThreadId, messages.length]);++ const continueByVoice = () => {+ seedTranscript(transcriptFromMessages(messages));+ setSurface("voice");+ };++ return (+ <div+ className="flex min-h-0 flex-1 flex-col items-center"+ data-testid="voice-thread-stage"+ data-thread={activeThreadId ?? ""}+ >+ <ScrollArea className="min-h-0 w-full flex-1">+ <div className="mx-auto flex w-full max-w-[760px] flex-col gap-4 px-6 pb-6 pt-8">+ <header className="flex items-center gap-2.5 border-b border-border pb-3">+ <span className="flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary/50">+ <Mic aria-hidden className="h-3.5 w-3.5 text-primary" />+ </span>+ <span className="min-w-0 flex-1">+ <span className="block truncate font-display text-sm font-semibold tracking-tight text-foreground">+ {title || t("voice_thread.untitled")}+ </span>+ <span className="block text-[11px] text-muted-foreground">+ {fill(t("voice_thread.subtitle"), { count: String(messages.length) })}+ </span>+ </span>+ </header>++ {messages.length === 0 ? (+ <p className="py-10 text-center text-xs text-muted-foreground">+ {t("voice_thread.empty")}+ </p>+ ) : (+ messages.map((m) => <SpokenTurn key={m.id} message={m} />)+ )}+ <div ref={endRef} />+ </div>+ </ScrollArea>++ <div className="w-full max-w-[760px] px-6 pb-5 pt-2">+ <div className="flex items-center gap-3 rounded-2xl border border-border bg-card/60 px-4 py-3">+ <p className="min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground">+ {t("voice_thread.read_only")}+ </p>+ <button+ type="button"+ onClick={continueByVoice}+ data-testid="continue-by-voice"+ className={cn(+ "flex shrink-0 items-center gap-2 rounded-xl border border-primary/40 bg-primary/10 px-3 py-1.5",+ "text-xs font-medium text-primary transition-colors hover:bg-primary/20",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ )}+ >+ <AudioLines aria-hidden className="h-3.5 w-3.5" />+ {t("voice_thread.continue")}+ </button>+ </div>+ </div>+ </div>+ );+}++/** One spoken turn — heard words on the right, the answer on the left. */+function SpokenTurn({ message }: { message: ChatMessage }) {+ const assistantName = useEventStore((s) => s.assistantName);+ const trace = useEventStore((s) => s.thinkingTraces[message.id]);+ const isUser = message.role === "user";++ if (message.role === "system") {+ return (+ <div className="mx-auto max-w-[85%] rounded-lg border border-border px-3 py-2 text-center text-xs italic text-muted-foreground">+ {message.content}+ </div>+ );+ }++ return (+ <div className={cn("flex", isUser ? "justify-end" : "justify-start")}>+ <div+ className={cn(+ "max-w-[80%] px-4 py-3 text-sm leading-relaxed",+ isUser+ ? "rounded-2xl rounded-br-sm bg-primary text-primary-foreground"+ : "jarvis-message-surface rounded-2xl rounded-bl-sm border border-border text-foreground",+ )}+ >+ {!isUser && (+ <div className="flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-primary">+ <span aria-hidden className="h-1 w-1 rounded-full bg-primary" />+ {assistantName}+ </div>+ )}+ {!isUser && trace && <ThoughtTraceDisclosure trace={trace} />}+ <div className={cn("whitespace-pre-wrap", !isUser && "mt-1.5")}>{message.content}</div>+ </div>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.tsnew file mode 100644index 0000000000..538e0cc63c--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.ts@@ -0,0 +1,180 @@+import { useCallback, useMemo } from "react";++import { useConversations } from "@/hooks/useConversations";+import { useEventStore, type ConversationSummary } from "@/store/events";+import { useAgentChatStore } from "@/store/agentChat";+import { useHomeStore } from "@/store/home";+import { transcriptFromMessages } from "@/lib/homeTranscript";++/**+ * The one chat history the app has, and the one way to open a row of it.+ *+ * Two backends feed it — the voice sessions (`/api/chats`) and the agent+ * chats (`/api/agent-chat/sessions`) — merged into one list sorted by when+ * each was last touched. The sidebar block and the "All chats" dialog both+ * read THIS, so the two can never disagree about what exists or about what+ * a click does.+ *+ * The rule a click follows (the bug this file was extracted to fix): the+ * front page shows exactly ONE conversation, so opening a row must also+ * close the other kind. Opening an agent chat drops the voice thread from+ * the stage; opening a voice session ends the agent session's socket. Before+ * that, clicking a voice row while the chat surface was up loaded its words+ * into a store the chat stage does not read — the screen simply kept showing+ * the previous conversation.+ */++export interface ChatRow {+ kind: "voice" | "agent";+ id: string;+ title: string;+ preview: string;+ updatedMs: number;+ messageCount: number;+ /** The sub-agent an agent chat runs on; empty for a voice session. */+ provider: string;+ raw: ConversationSummary | null;+}++export interface ChatRowsApi {+ rows: ChatRow[];+ /** True for the row currently on the front page's stage. */+ isActive: (row: ChatRow) => boolean;+ open: (row: ChatRow) => void;+ /** Agent chats can be deleted; a voice session is a recording, not a draft. */+ remove: (row: ChatRow) => void;+}++export function useChatRows({ poll = false }: { poll?: boolean } = {}): ChatRowsApi {+ const { conversations, openConversation } = useConversations({ poll });+ const sessions = useAgentChatStore((s) => s.sessions);+ const activeSessionId = useAgentChatStore((s) => s.activeSessionId);+ const activeVoiceId = useEventStore((s) => (s.activeKind === "voice" ? s.activeThreadId : null));+ const setActiveSection = useEventStore((s) => s.setActiveSection);+ const setActiveConversation = useEventStore((s) => s.setActiveConversation);+ const setMessages = useEventStore((s) => s.setMessages);+ const seedTranscript = useHomeStore((s) => s.seedTranscript);+ const setSurface = useHomeStore((s) => s.setSurface);++ const rows = useMemo<ChatRow[]>(() => {+ const voice: ChatRow[] = conversations+ .filter((c) => c.kind === "voice")+ .map((c) => ({+ kind: "voice",+ id: c.id,+ title: c.title || c.preview,+ preview: c.preview,+ updatedMs: c.updated_ms,+ messageCount: c.message_count,+ provider: "",+ raw: c,+ }));+ const agent: ChatRow[] = sessions.map((s) => ({+ kind: "agent",+ id: s.session_id,+ title: s.title || s.preview,+ preview: s.preview,+ updatedMs: s.updated_ms,+ messageCount: s.message_count,+ provider: s.provider,+ raw: null,+ }));+ return [...voice, ...agent].sort((a, b) => b.updatedMs - a.updatedMs);+ }, [conversations, sessions]);++ const isActive = useCallback(+ (row: ChatRow) => (row.kind === "agent" ? row.id === activeSessionId : row.id === activeVoiceId),+ [activeSessionId, activeVoiceId],+ );++ const open = useCallback(+ (row: ChatRow) => {+ if (row.kind === "voice") {+ // End the agent session on stage first: the chat stage renders the+ // voice archive only while no agent chat is open, and its socket has+ // no business staying connected to a conversation nobody is looking at.+ useAgentChatStore.getState().newChat();+ const stayOnVoice = useHomeStore.getState().surface === "voice";+ const opened = openConversation("voice", row.id);+ if (stayOnVoice) {+ void opened.then((messages) => seedTranscript(transcriptFromMessages(messages)));+ } else {+ void opened;+ setSurface("chat");+ }+ } else {+ // Drop the voice thread so the stage shows the agent timeline, not a+ // stale archive underneath it.+ setActiveConversation("text", null);+ setMessages([]);+ useAgentChatStore.getState().openSession(row.id);+ setSurface("chat");+ }+ setActiveSection("chats");+ },+ [openConversation, seedTranscript, setActiveConversation, setActiveSection, setMessages, setSurface],+ );++ const remove = useCallback((row: ChatRow) => {+ if (row.kind !== "agent") return;+ void useAgentChatStore.getState().removeSession(row.id);+ }, []);++ return { rows, isActive, open, remove };+}++/** Short time for a row: clock today, day + month before that. */+export function formatChatWhen(ms: number): string {+ if (!ms) return "";+ const d = new Date(ms);+ const today = new Date();+ today.setHours(0, 0, 0, 0);+ if (d.getTime() >= today.getTime()) {+ return d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });+ }+ return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });+}++export type ChatDayBucket = "today" | "yesterday" | "week" | "month" | "older";++const BUCKET_ORDER: ChatDayBucket[] = ["today", "yesterday", "week", "month", "older"];++/**+ * Group rows the way a desktop mail client does — today, yesterday, the last+ * week, the last month, then everything older. Empty buckets are dropped, so+ * a fresh install shows one heading rather than five.+ */+export function groupChatRows(rows: ChatRow[], now = Date.now()): Array<{ bucket: ChatDayBucket; rows: ChatRow[] }> {+ const startOfDay = (ms: number) => {+ const d = new Date(ms);+ d.setHours(0, 0, 0, 0);+ return d.getTime();+ };+ const today = startOfDay(now);+ const yesterday = today - 86_400_000;+ const week = today - 7 * 86_400_000;+ const month = today - 30 * 86_400_000;++ const buckets = new Map<ChatDayBucket, ChatRow[]>();+ for (const row of rows) {+ const day = startOfDay(row.updatedMs);+ const bucket: ChatDayBucket =+ day >= today ? "today" : day >= yesterday ? "yesterday" : day >= week ? "week" : day >= month ? "month" : "older";+ const list = buckets.get(bucket);+ if (list) list.push(row);+ else buckets.set(bucket, [row]);+ }+ return BUCKET_ORDER.filter((b) => (buckets.get(b)?.length ?? 0) > 0).map((bucket) => ({+ bucket,+ rows: buckets.get(bucket) ?? [],+ }));+}++/** Case-insensitive match over title and preview. An empty query keeps everything. */+export function filterChatRows(rows: ChatRow[], query: string): ChatRow[] {+ const q = query.trim().toLowerCase();+ if (!q) return rows;+ return rows.filter(+ (r) => r.title.toLowerCase().includes(q) || r.preview.toLowerCase().includes(q),+ );+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 2e849ab8e4..01e136efe1 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -462,6 +462,7 @@"show_all": "Alle anzeigen","show_less": "Weniger anzeigen","no_chats": "Noch keine Unterhaltungen",+ "see_all_chats": "Alle Chats ansehen","collapse": "Navigation einklappen","expand": "Navigation ausklappen","wake_hint": "Sag dein Wake-Word…",@@ -5036,5 +5037,28 @@"free": "Kostenlos","unknown": "Ohne Preis"}+ },+ "all_chats": {+ "title": "Alle Chats",+ "description": "Jede Unterhaltung — gesprochen und getippt. Durchsuchen oder dort weitermachen, wo du aufgehört hast.",+ "close": "Schließen",+ "search_placeholder": "Chats durchsuchen…",+ "filter_all": "Alle",+ "filter_chats": "Chats",+ "filter_voice": "Sprache",+ "empty": "Noch keine Unterhaltungen. Sag etwas oder starte einen Chat.",+ "no_match": "Nichts passt zu dieser Suche.",+ "group_today": "Heute",+ "group_yesterday": "Gestern",+ "group_week": "Letzte 7 Tage",+ "group_month": "Letzte 30 Tage",+ "group_older": "Älter"+ },+ "voice_thread": {+ "untitled": "Sprachsitzung",+ "subtitle": "Gesprochene Unterhaltung · {count} Beiträge",+ "empty": "In dieser Sitzung wurde nichts aufgezeichnet.",+ "read_only": "Eine gesprochene Unterhaltung. Sprich weiter, um sie fortzusetzen.",+ "continue": "Per Sprache fortsetzen"}}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 31067b476e..d356720654 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -462,6 +462,7 @@"show_all": "Show all","show_less": "Show less","no_chats": "No conversations yet",+ "see_all_chats": "See all chats","collapse": "Collapse the navigation","expand": "Expand the navigation","wake_hint": "Say your wake word…",@@ -5036,5 +5037,28 @@"free": "Free","unknown": "Unpriced"}+ },+ "all_chats": {+ "title": "All chats",+ "description": "Every conversation — spoken and typed. Search it, or pick up where you left off.",+ "close": "Close",+ "search_placeholder": "Search chats…",+ "filter_all": "All",+ "filter_chats": "Chats",+ "filter_voice": "Voice",+ "empty": "No conversations yet. Say something, or start a chat.",+ "no_match": "Nothing matches that search.",+ "group_today": "Today",+ "group_yesterday": "Yesterday",+ "group_week": "Previous 7 days",+ "group_month": "Previous 30 days",+ "group_older": "Older"+ },+ "voice_thread": {+ "untitled": "Voice session",+ "subtitle": "Spoken conversation · {count} turns",+ "empty": "Nothing was recorded in this session.",+ "read_only": "A spoken conversation. Continue it by talking.",+ "continue": "Continue by voice"}}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 463cd1ebc3..94cf0068a5 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -462,6 +462,7 @@"show_all": "Mostrar todo","show_less": "Mostrar menos","no_chats": "Aún no hay conversaciones",+ "see_all_chats": "Ver todos los chats","collapse": "Contraer la navegación","expand": "Expandir la navegación","wake_hint": "Di tu palabra de activación…",@@ -5036,5 +5037,28 @@"free": "Gratis","unknown": "Sin precio"}+ },+ "all_chats": {+ "title": "Todos los chats",+ "description": "Todas las conversaciones, habladas y escritas. Búscalas o retoma donde lo dejaste.",+ "close": "Cerrar",+ "search_placeholder": "Buscar chats…",+ "filter_all": "Todos",+ "filter_chats": "Chats",+ "filter_voice": "Voz",+ "empty": "Aún no hay conversaciones. Di algo o empieza un chat.",+ "no_match": "Nada coincide con esa búsqueda.",+ "group_today": "Hoy",+ "group_yesterday": "Ayer",+ "group_week": "Últimos 7 días",+ "group_month": "Últimos 30 días",+ "group_older": "Anteriores"+ },+ "voice_thread": {+ "untitled": "Sesión de voz",+ "subtitle": "Conversación hablada · {count} turnos",+ "empty": "No se grabó nada en esta sesión.",+ "read_only": "Una conversación hablada. Continúala hablando.",+ "continue": "Continuar por voz"}}diff --git a/jarvis/ui/web/frontend/src/lib/chatsApi.ts b/jarvis/ui/web/frontend/src/lib/chatsApi.tsindex be9a07a6b3..12d2348523 100644--- a/jarvis/ui/web/frontend/src/lib/chatsApi.ts+++ b/jarvis/ui/web/frontend/src/lib/chatsApi.ts@@ -30,9 +30,15 @@ export class ChatsApiError extends Error {}}-export async function fetchConversations(days = 0): Promise<ConversationSummary[]> {- const q = days > 0 ? `?days=${days}` : "";- const res = await fetch(`/api/chats${q}`);+/**+ * The voice/text history. `limit` is deliberately generous: the sidebar shows+ * a handful, but the "All chats" archive promises everything, and a cap that+ * quietly hides old conversations reads as data loss.+ */+export async function fetchConversations(days = 0, limit = 500): Promise<ConversationSummary[]> {+ const params = new URLSearchParams({ limit: String(limit) });+ if (days > 0) params.set("days", String(days));+ const res = await fetch(`/api/chats?${params.toString()}`);if (!res.ok) throw new ChatsApiError("list-failed", res.status);return (await res.json()) as ConversationSummary[];}diff --git a/jarvis/ui/web/frontend/src/store/agentChat.ts b/jarvis/ui/web/frontend/src/store/agentChat.tsindex 333ca31b50..7d322728bf 100644--- a/jarvis/ui/web/frontend/src/store/agentChat.ts+++ b/jarvis/ui/web/frontend/src/store/agentChat.ts@@ -43,6 +43,8 @@ import { EMPTY_TIMELINE, reduceEvent, reduceEvents, type Timeline } from "@/compconst DRAFT_KEY = "jarvis.agentChat.draft.v1";const RECONNECT_MS = 1500;+/** How many sessions the list holds — the "All chats" archive shows them all. */+const SESSION_LIST_LIMIT = 500;export interface ComposerDraft {provider: string;@@ -314,7 +316,7 @@ export const useAgentChatStore = create<AgentChatStore>((set, get) => {loadSessions: async () => {try {- const sessions = await fetchAgentChatSessions();+ const sessions = await fetchAgentChatSessions(SESSION_LIST_LIMIT);set({ sessions });} catch {/* offline / headless — keep the list as-is */