Skip to content

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.

feat(chat): the front page's chat is Jarvis with a keyboard again, not a coding agent

rubenluetke10-beep5456ad5088b4
diff --git a/jarvis/ui/web/frontend/src/components/ChatInput.tsx b/jarvis/ui/web/frontend/src/components/ChatInput.tsx
index 3e348af607..48b610ed93 100644
--- a/jarvis/ui/web/frontend/src/components/ChatInput.tsx
+++ b/jarvis/ui/web/frontend/src/components/ChatInput.tsx
@@ -6,10 +6,12 @@ import { useEventStore } from "@/store/events";
import { cn } from "@/lib/utils";
import { useT } from "@/i18n";
-// Safety net: if the brain doesn't respond within 60s (no reply, no error event),
-// we revert the indicator. A backend hang must not leave the UI stuck in the
-// wait state permanently.
-const THINKING_TIMEOUT_MS = 60_000;
+// Safety net: a backend hang must not leave the UI waiting forever. This is a
+// SILENCE window, not a turn budget — every sign of life (a reasoning step, a
+// streamed piece of the answer) re-arms it. A turn that reads the calendar,
+// runs a skill and then writes three paragraphs takes well over a minute and
+// is perfectly healthy; only a turn that goes quiet is one nobody is having.
+const THINKING_SILENCE_MS = 60_000;
/**
* The composer — a card with the text box and, on its bottom row, dictation,
@@ -32,6 +34,9 @@ export function ChatInput() {
// column renders the live steps (components/home/TurnSteps) as the
// in-progress assistant turn. The composer only arms the wait state.
const setChatThinking = useEventStore((s) => s.setChatThinking);
+ const chatThinking = useEventStore((s) => s.chatThinking);
+ const stepCount = useEventStore((s) => s.thinkingSteps.length);
+ const liveLength = useEventStore((s) => s.liveReply?.text.length ?? 0);
// Mic-dictation: live transcript streams into the box as the user speaks.
const dictating = useEventStore((s) => s.dictating);
const dictationText = useEventStore((s) => s.dictationText);
@@ -50,11 +55,24 @@ export function ChatInput() {
const mirroringRef = useRef(false);
const lastCommitSeqRef = useRef(dictationCommitSeq);
+ // Arm the silence window while a turn is in flight, and re-arm it whenever
+ // the turn shows a sign of life. `stepCount`/`liveLength` are the two live
+ // signals the brain produces; either one moving means the turn is alive.
useEffect(() => {
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
+ if (!chatThinking) {
+ timeoutRef.current = null;
+ return;
+ }
+ timeoutRef.current = setTimeout(() => {
+ setChatThinking(false);
+ timeoutRef.current = null;
+ }, THINKING_SILENCE_MS);
return () => {
if (timeoutRef.current) clearTimeout(timeoutRef.current);
+ timeoutRef.current = null;
};
- }, []);
+ }, [chatThinking, stepCount, liveLength, setChatThinking]);
// While dictating, mirror the live interim tail into the textarea in real time.
useEffect(() => {
@@ -118,11 +136,6 @@ export function ChatInput() {
payload: { content },
});
setChatThinking(true);
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
- timeoutRef.current = setTimeout(() => {
- setChatThinking(false);
- timeoutRef.current = null;
- }, THINKING_TIMEOUT_MS);
setValue("");
}
diff --git a/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx b/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx
index 37d00a24c7..04bb3c539d 100644
--- a/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/AllChatsDialog.tsx
@@ -16,14 +16,15 @@ import {
* "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
+ * archive: every conversation with Jarvis, typed or spoken, 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.
+ * The list is whatever the sidebar's poller already holds, so opening the
+ * dialog costs no request.
*/
export function AllChatsDialog({
open,
@@ -35,7 +36,7 @@ export function AllChatsDialog({
const t = useT();
const { rows, isActive, open: openRow, remove } = useChatRows();
const [query, setQuery] = useState("");
- const [kind, setKind] = useState<"all" | "agent" | "voice">("all");
+ const [kind, setKind] = useState<"all" | "text" | "voice">("all");
const searchRef = useRef<HTMLInputElement | null>(null);
// A reopened dialog starts clean — a stale filter hiding the chat someone
@@ -56,7 +57,7 @@ export function AllChatsDialog({
const counts = useMemo(
() => ({
all: rows.length,
- agent: rows.filter((r) => r.kind === "agent").length,
+ text: rows.filter((r) => r.kind === "text").length,
voice: rows.filter((r) => r.kind === "voice").length,
}),
[rows],
@@ -128,9 +129,9 @@ export function AllChatsDialog({
/>
<FilterChip
label={t("all_chats.filter_chats")}
- count={counts.agent}
- selected={kind === "agent"}
- onClick={() => setKind("agent")}
+ count={counts.text}
+ selected={kind === "text"}
+ onClick={() => setKind("text")}
/>
<FilterChip
label={t("all_chats.filter_voice")}
@@ -162,7 +163,7 @@ export function AllChatsDialog({
openRow(row);
onOpenChange(false);
}}
- onDelete={row.kind === "agent" ? () => remove(row) : undefined}
+ onDelete={row.kind === "text" ? () => remove(row) : undefined}
/>
))}
</ul>
diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
index 241381c524..7ed634daf1 100644
--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
@@ -1,63 +1,22 @@
-import { act, cleanup, fireEvent, render as rtlRender, screen, within } from "@testing-library/react";
+import { cleanup, render as rtlRender, screen, within } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { ChatStage } from "@/components/home/ChatStage";
-import { EMPTY_TIMELINE, reduceEvents } from "@/components/agentchat/reduce";
-import type { AgentChatCatalog, AgentChatEvent } from "@/lib/agentChatApi";
-import { useAgentChatStore } from "@/store/agentChat";
import { useEventStore } from "@/store/events";
-const CATALOG: AgentChatCatalog = {
- default_cwd: "C:\\work",
- shell: "pwsh",
- providers: [
- {
- id: "claude-api",
- label: "Anthropic Claude",
- family: "claude",
- runner: "claude-cli",
- models_source: "curated",
- curated_models: [
- { id: "claude-opus-5", label: "Claude Opus 5" },
- { id: "claude-sonnet-5", label: "Claude Sonnet 5" },
- ],
- default_model: "",
- keyless: false,
- native_resume: true,
- effort_levels: ["low", "medium", "high", "xhigh", "max"],
- default_effort: "high",
- permission_modes: [
- { id: "default", label: "Ask before acting", description: "" },
- { id: "acceptEdits", label: "Auto-accept edits", description: "" },
- { id: "plan", label: "Plan", description: "" },
- { id: "bypassPermissions", label: "Bypass permissions", description: "" },
- ],
- default_permission_mode: "acceptEdits",
- cli_installed: true,
- },
- {
- id: "openai-codex",
- label: "OpenAI Codex",
- family: "openai",
- runner: "codex-cli",
- models_source: "curated",
- curated_models: [{ id: "gpt-5.4", label: "GPT-5.4" }],
- default_model: "",
- keyless: false,
- native_resume: true,
- effort_levels: ["minimal", "low", "medium", "high", "xhigh"],
- default_effort: "medium",
- permission_modes: [
- { id: "read-only", label: "Read only", description: "" },
- { id: "auto", label: "Auto", description: "" },
- { id: "full-access", label: "Full access", description: "" },
- ],
- default_permission_mode: "auto",
- cli_installed: false,
- },
- ],
-};
+/**
+ * The front page's chat is JARVIS with a keyboard — the same assistant the
+ * microphone talks to, reading the same store the voice path fills. These
+ * tests pin exactly that: the composer that sends on the app socket, the
+ * brain's own reasoning steps, its answer streaming in, and a spoken session
+ * read in the same column.
+ *
+ * What must NOT be here is a provider / model / effort / permission picker:
+ * those belong to a coding-agent session, which is a different surface
+ * (components/agentchat/AgentChatStage). A picker appearing on this stage is
+ * the exact regression this file exists to catch.
+ */
// The greeting reads the profile name (a query), so the stage mounts under a
// query client like the app.
@@ -68,329 +27,137 @@ function render(ui: React.ReactElement) {
return rtlRender(<QueryClientProvider client={client}>{ui}</QueryClientProvider>);
}
-let seq = 0;
-function ev(kind: string, payload: Record<string, unknown>): AgentChatEvent {
- seq += 1;
- return { seq, ts_ms: 1_000 + seq, kind, payload };
-}
-
-describe("ChatStage (agent chat)", () => {
- let scrollTo: ReturnType<typeof vi.fn>;
+const IDLE = {
+ connected: true,
+ wsWarming: false,
+ assistantName: "Jarvis",
+ activeKind: "text" as const,
+ activeThreadId: null,
+ messages: [],
+ chatThinking: false,
+ thinkingSteps: [],
+ thinkingStartedTs: null,
+ thinkingTraces: {},
+ liveReply: null,
+ conversations: [],
+};
+describe("ChatStage (Jarvis, typed)", () => {
beforeEach(() => {
- scrollTo = vi.fn();
Object.defineProperty(HTMLElement.prototype, "scrollTo", {
configurable: true,
writable: true,
- value: scrollTo,
+ value: vi.fn(),
});
- // 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({
- catalog: CATALOG,
- connections: [
- { jarvis: "claude-api", key_set: true, is_active_brain: true },
- { jarvis: "openai-codex", key_set: true, is_active_brain: false },
- ],
- catalogError: null,
- backendOutdated: false,
- liveModels: {},
- sessions: [],
- activeSessionId: null,
- activeSession: null,
- timeline: EMPTY_TIMELINE,
- draft: {
- provider: "claude-api",
- model: "",
- effort: "high",
- permissionMode: "acceptEdits",
- buildMode: "acceptEdits",
- cwd: "C:\\work",
- },
- busy: false,
- lastError: null,
- // The stage's mount effects fetch; keep them inert here.
- loadCatalog: async () => {},
- loadSessions: async () => {},
- loadModels: async () => {},
- });
+ useEventStore.setState(IDLE);
});
afterEach(() => {
cleanup();
});
- it("shows the greeting and the composer with the four picks when there is nothing yet", () => {
+ it("opens on the greeting and Jarvis' own composer — no agent picks", () => {
render(<ChatStage />);
- expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("true");
- const composer = screen.getByTestId("agent-composer");
- expect(within(composer).getByTestId("composer-provider").getAttribute("data-value")).toBe("claude-api");
- expect(within(composer).getByTestId("composer-model")).toBeTruthy();
- expect(within(composer).getByTestId("composer-effort").getAttribute("data-value")).toBe("high");
- expect(within(composer).getByTestId("composer-permission").getAttribute("data-value")).toBe("acceptEdits");
- // Claude Code has a plan entry, so the Build | Plan switch is drawn.
- expect(within(composer).getByTestId("composer-plan").getAttribute("aria-checked")).toBe("false");
- });
- it("hides the Build | Plan switch for a provider whose ladder has no plan entry", () => {
- useAgentChatStore.setState((s) => ({ draft: { ...s.draft, provider: "openai-codex", permissionMode: "auto" } }));
- render(<ChatStage />);
+ expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("true");
+ expect(screen.getByTestId("home-greeting")).toBeTruthy();
+ expect(screen.getByTestId("chat-composer")).toBeTruthy();
+ // The four coding-session picks have no business on this surface.
+ expect(screen.queryByTestId("agent-composer")).toBeNull();
+ expect(screen.queryByTestId("composer-provider")).toBeNull();
+ expect(screen.queryByTestId("composer-effort")).toBeNull();
+ expect(screen.queryByTestId("composer-permission")).toBeNull();
expect(screen.queryByTestId("composer-plan")).toBeNull();
});
- it("groups the provider list by what stands behind a row: coding CLIs, API keys, local servers", async () => {
- const apiRow = {
- ...CATALOG.providers[0],
- id: "openai",
- label: "OpenAI",
- family: "openai",
- runner: "api",
- models_source: "live" as const,
- curated_models: [],
- cli_installed: null,
- };
- const localRow = { ...apiRow, id: "ollama", label: "Ollama", family: "ollama", keyless: true };
- useAgentChatStore.setState({
- catalog: { ...CATALOG, providers: [...CATALOG.providers, apiRow, localRow] },
- connections: [
- { jarvis: "claude-api", key_set: true, is_active_brain: false },
- { jarvis: "openai-codex", key_set: false, is_active_brain: false },
- { jarvis: "openai", key_set: true, is_active_brain: true },
- ],
- });
- render(<ChatStage />);
- fireEvent.click(screen.getByTestId("composer-provider"));
- const panel = await screen.findByTestId("composer-provider-panel");
- // The headings, in catalog order — never "connected / not connected".
- const headings = Array.from(panel.querySelectorAll("div.uppercase")).map((el) => el.textContent);
- expect(headings).toEqual(["Coding CLIs", "API keys", "On your own hardware"]);
- expect(within(panel).queryByText("Connected")).toBeNull();
- // Only what the Agents tab has set up is listed: Codex (no login) is not
- // there at all, and the voice sub-agent's "active" word is not shown.
- const options = within(panel).getAllByRole("option").map((el) => el.textContent ?? "");
- expect(options.map((o) => o.replace(/\s+/g, " ").trim())).toEqual(["Anthropic Claude", "OpenAI", "Ollama"]);
- expect(within(panel).queryByText("active")).toBeNull();
- });
-
- it("with nothing connected yet, lists every provider greyed with its connect hint", async () => {
- useAgentChatStore.setState({
- connections: [
- { jarvis: "claude-api", key_set: false, is_active_brain: false },
- { jarvis: "openai-codex", key_set: false, is_active_brain: false },
+ it("renders a turn: the person's bubble, then Jarvis' answer as prose", () => {
+ useEventStore.setState({
+ activeThreadId: "t1",
+ messages: [
+ { id: "m1", role: "user", content: "What is on today?", ts: 1 },
+ {
+ id: "m2",
+ role: "assistant",
+ content: "Two meetings:\n\n- **10:00** standup\n- 14:00 review",
+ ts: 2,
+ },
],
});
render(<ChatStage />);
- fireEvent.click(screen.getByTestId("composer-provider"));
- const panel = await screen.findByTestId("composer-provider-panel");
- const options = within(panel).getAllByRole("option");
- expect(options).toHaveLength(2);
- expect(options[0].textContent).toContain("connect");
- // Codex is not installed on this box: the hint says so instead of "connect".
- expect(options[1].textContent).toContain("not installed");
- });
-
- it("says when the backend is older than this window and offers the restart", async () => {
- const fetchMock = vi.fn(async () => new Response(null, { status: 200 }));
- vi.stubGlobal("fetch", fetchMock);
- try {
- useAgentChatStore.setState({ backendOutdated: true });
- render(<ChatStage />);
- const notice = screen.getByTestId("composer-backend-outdated");
- expect(notice.textContent).toContain("older version");
- fireEvent.click(within(notice).getByRole("button"));
- await act(async () => {});
- expect(fetchMock).toHaveBeenCalledWith("/api/settings/restart-app", { method: "POST" });
- } finally {
- vi.unstubAllGlobals();
- }
- });
-
- it("draws a different glyph per permission mode in the pill and the list", async () => {
- render(<ChatStage />);
- const pill = screen.getByTestId("composer-permission");
- // acceptEdits wears the pen, not the column's shield.
- expect(pill.querySelector("svg.lucide-file-pen")).not.toBeNull();
- expect(pill.querySelector("svg.lucide-shield-check")).toBeNull();
- fireEvent.click(pill);
- const panel = await screen.findByTestId("composer-permission-panel");
- const glyphs = within(panel)
- .getAllByRole("option")
- .map((el) => el.querySelector("svg")?.getAttribute("class") ?? "");
- // default → question shield, acceptEdits → pen, bypass → shield off; plan lives on the switch.
- expect(glyphs.some((c) => c.includes("lucide-shield-question"))).toBe(true);
- expect(glyphs.some((c) => c.includes("lucide-file-pen"))).toBe(true);
- expect(glyphs.some((c) => c.includes("lucide-shield-off"))).toBe(true);
- expect(new Set(glyphs).size).toBe(glyphs.length);
- });
-
- it("grows the text box with the typed text and caps it at its max height", () => {
- render(<ChatStage />);
- const box = screen.getByPlaceholderText("Ask anything…") as HTMLTextAreaElement;
- // jsdom has no layout: stand in for scrollHeight and the max-height rule.
- let scrollHeight = 48;
- Object.defineProperty(box, "scrollHeight", { configurable: true, get: () => scrollHeight });
- const computed = vi.spyOn(window, "getComputedStyle").mockImplementation(
- () => ({ maxHeight: "192px" }) as CSSStyleDeclaration,
- );
- try {
- scrollHeight = 120;
- fireEvent.change(box, { target: { value: "one two three four five" } });
- expect(box.style.height).toBe("120px");
- expect(box.style.overflowY).toBe("hidden");
- scrollHeight = 400;
- fireEvent.change(box, { target: { value: "a much longer prompt".repeat(40) } });
- expect(box.style.height).toBe("192px");
- expect(box.style.overflowY).toBe("auto");
- } finally {
- computed.mockRestore();
- }
- });
- it("shows no restart notice when the catalog carries the permission ladders", () => {
- render(<ChatStage />);
- expect(screen.queryByTestId("composer-backend-outdated")).toBeNull();
+ expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("false");
+ expect(screen.getByTestId("chat-message-user").textContent).toContain("What is on today?");
+ const answer = screen.getByTestId("chat-message-assistant");
+ expect(answer.textContent).toContain("Jarvis");
+ // Markdown is rendered, not printed: the list is a list and the bold is bold.
+ expect(within(answer).getAllByRole("listitem")).toHaveLength(2);
+ expect(within(answer).getByText("10:00").tagName).toBe("STRONG");
+ // The composer stays with the conversation.
+ expect(screen.getByTestId("chat-composer")).toBeTruthy();
});
- it("greys out a provider that is not connected and says how to fix it", () => {
- useAgentChatStore.setState({
- connections: [{ jarvis: "claude-api", key_set: false, is_active_brain: true }],
+ it("shows the turn while it runs: the brain's steps and the answer as it is written", () => {
+ useEventStore.setState({
+ activeThreadId: "t1",
+ messages: [{ id: "m1", role: "user", content: "Turn on the lights", ts: 1 }],
+ chatThinking: true,
+ thinkingStartedTs: Date.now() - 4_000,
+ thinkingSteps: [
+ {
+ id: "s1",
+ kind: "tool",
+ labelKey: "thinking.step_tool",
+ detail: "living room",
+ status: "active",
+ startedTs: Date.now() - 3_000,
+ },
+ ],
+ liveReply: { text: "On, in the living room", threadId: "t1", done: false, ts: 2 },
});
render(<ChatStage />);
- const hint = screen.getByTestId("composer-connect-hint");
- expect(hint.textContent).toContain("Anthropic Claude");
- // Send stays off until the provider is usable.
- expect((screen.getByTestId("composer-send") as HTMLButtonElement).disabled).toBe(true);
- });
- it("renders the folded timeline: user bubble, byline with provider + model, tool row, answer", () => {
- const timeline = reduceEvents(EMPTY_TIMELINE, [
- ev("user_message", { text: "list the files" }),
- ev("turn_started", { turn_id: "t1", provider: "claude-api", model: "claude-opus-5", effort: "high", runner: "claude-cli" }),
- ev("tool_call", { turn_id: "t1", call_id: "c1", name: "Bash", input: { command: "ls" } }),
- ev("tool_result", { turn_id: "t1", call_id: "c1", output: "a.py\nb.py", is_error: false, duration_ms: 40 }),
- ev("assistant_text", { turn_id: "t1", message_id: "m1", text: "Two files: **a.py** and b.py." }),
- ev("turn_finished", { turn_id: "t1", status: "done", duration_ms: 1200, usage: {} }),
- ]);
- useAgentChatStore.setState({ activeSessionId: "s1", timeline });
- render(<ChatStage />);
- expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("false");
- expect(screen.getByTestId("agent-message-user").textContent).toContain("list the files");
- const turn = screen.getByTestId("agent-turn");
- expect(turn.textContent).toContain("Anthropic Claude");
- expect(turn.textContent).toContain("claude-opus-5");
- const tool = within(turn).getByTestId("agent-tool");
- expect(tool.getAttribute("data-tool")).toBe("Bash");
- expect(tool.getAttribute("data-state")).toBe("done");
- // The row opens to show input and output.
- fireEvent.click(within(tool).getByRole("button"));
- expect(tool.textContent).toContain("a.py");
- expect(within(turn).getByTestId("agent-text").querySelector("strong")?.textContent).toBe("a.py");
- // The person's message was pinned to the top of the scroll area.
- expect(scrollTo).toHaveBeenCalled();
+ const live = screen.getByTestId("chat-turn-live");
+ expect(live.textContent).toContain("living room");
+ expect(screen.getByTestId("chat-live-text").textContent).toContain("On, in the living room");
});
- it("shows the approval card while the runner waits and routes the click to the store", () => {
- const decide = vi.fn(async () => {});
- const timeline = reduceEvents(EMPTY_TIMELINE, [
- ev("user_message", { text: "delete it" }),
- ev("turn_started", { turn_id: "t2", provider: "openai", model: "", effort: "", runner: "api" }),
- ev("approval_required", { turn_id: "t2", approval_id: "a1", call_id: "c2", name: "RunCommand", input: { command: "rm x" }, summary: "rm x" }),
- ]);
- useAgentChatStore.setState({ activeSessionId: "s2", timeline, decide });
- render(<ChatStage />);
- const card = screen.getByTestId("agent-approval");
- expect(card.textContent).toContain("rm x");
- act(() => {
- fireEvent.click(within(card).getByTestId("approval-allow"));
+ it("keeps the steps a finished reply came with when it is replayed from the history", () => {
+ useEventStore.setState({
+ activeThreadId: "t1",
+ messages: [
+ {
+ id: "m2",
+ role: "assistant",
+ content: "Sent.",
+ ts: 2,
+ trace: {
+ durationMs: 3_200,
+ steps: [
+ {
+ id: "s1",
+ kind: "tool",
+ labelKey: "thinking.step_tool",
+ detail: "mailbox",
+ status: "done",
+ startedTs: 1,
+ durationMs: 900,
+ },
+ ],
+ },
+ },
+ ],
});
- expect(decide).toHaveBeenCalledWith("a1", "allow");
- // The composer offers Stop while the turn runs.
- expect(screen.getByTestId("composer-stop")).toBeTruthy();
- });
-
- it("always shows that the turn is alive: glyph, a word, the clock and the tokens", () => {
- vi.useFakeTimers();
- try {
- const started = Date.now();
- const timeline = reduceEvents(EMPTY_TIMELINE, [
- ev("user_message", { text: "dig into it" }),
- { seq: 2, ts_ms: started, kind: "turn_started", payload: { turn_id: "t1", provider: "claude-api", model: "claude-opus-5", effort: "high", runner: "claude-cli" } },
- { seq: 0, ts_ms: started, kind: "reasoning_started", payload: { turn_id: "t1", message_id: "m1" } },
- { seq: 0, ts_ms: started, kind: "usage_delta", payload: { turn_id: "t1", usage: { input_tokens: 12, output_tokens: 4800 } } },
- ]);
- useAgentChatStore.setState({ activeSessionId: "s1", timeline });
- render(<ChatStage />);
-
- // The redacted thought is a row of its own — thinking you cannot read
- // is still thinking you can see.
- const reasoning = screen.getByTestId("agent-reasoning");
- expect(reasoning.getAttribute("data-live")).toBe("true");
-
- const live = screen.getByTestId("agent-turn-live");
- expect(within(live).getByTestId("agent-glyph")).toBeTruthy();
- expect(live.textContent).toMatch(/4\.8k/);
- // The clock moves on its own.
- act(() => {
- vi.advanceTimersByTime(12_000);
- });
- expect(live.textContent).toMatch(/1[0-9]s|12s/);
- // The rail marks the whole block as running.
- expect(screen.getByTestId("agent-turn-rail").className).toContain("agent-rail-live");
- // A running turn shows no receipt yet.
- expect(screen.queryByTestId("agent-turn-footer")).toBeNull();
- } finally {
- vi.useRealTimers();
- }
- });
-
- it("names tools the way the agent's log does and closes with time and tokens", () => {
- const timeline = reduceEvents(EMPTY_TIMELINE, [
- ev("user_message", { text: "check the repo" }),
- ev("turn_started", { turn_id: "t9", provider: "claude-api", model: "claude-opus-5", effort: "high", runner: "claude-cli" }),
- ev("tool_call", { turn_id: "t9", call_id: "c1", name: "PowerShell", input: { command: "Get-ChildItem -Path 'C:\\Users'" } }),
- ev("tool_result", { turn_id: "t9", call_id: "c1", output: "ok", is_error: false }),
- ev("tool_call", { turn_id: "t9", call_id: "c2", name: "mcp__github__create_issue", input: { title: "Bug" } }),
- ev("tool_result", { turn_id: "t9", call_id: "c2", output: "#12", is_error: false }),
- ev("reasoning", { turn_id: "t9", text: "", duration_ms: 8585 }),
- ev("assistant_text", { turn_id: "t9", message_id: "m1", text: "Done." }),
- ev("turn_finished", { turn_id: "t9", status: "done", duration_ms: 12_000, usage: { input_tokens: 2, output_tokens: 219 }, cost_usd: 0.8483 }),
- ]);
- useAgentChatStore.setState({ activeSessionId: "s9", timeline });
render(<ChatStage />);
- const tools = screen.getAllByTestId("agent-tool");
- expect(tools[0].getAttribute("data-tool")).toBe("PowerShell");
- expect(tools[0].textContent).toContain("PowerShell");
- expect(tools[0].textContent).toContain("Get-ChildItem");
- // An MCP call is named after its server, and wears its mark.
- expect(tools[1].getAttribute("data-family")).toBe("mcp");
- expect(tools[1].textContent).toContain("GitHub");
-
- // Thinking with no readable text still shows its time and does not open.
- const reasoning = screen.getByTestId("agent-reasoning");
- expect(reasoning.textContent).toMatch(/9s|8\.6s|8s/);
- expect(within(reasoning).getByRole("button").hasAttribute("disabled")).toBe(true);
-
- const footer = screen.getByTestId("agent-turn-footer");
- expect(footer.textContent).toContain("12s");
- expect(footer.textContent).toContain("219");
- expect(footer.textContent).toContain("$0.8483");
+ expect(screen.getByTestId("chat-message-assistant").textContent).toContain("mailbox");
});
- 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 });
+ it("reads a spoken session in the same column, without a composer", () => {
useEventStore.setState({
activeKind: "voice",
activeThreadId: "v1",
@@ -409,24 +176,14 @@ describe("ChatStage (agent chat)", () => {
{ 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();
+ // A spoken thread is continued by talking.
+ expect(screen.queryByTestId("chat-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.tsx
index 13de25e3f7..2a3ea6118a 100644
--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
@@ -1,69 +1,60 @@
-import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
+import ReactMarkdown from "react-markdown";
+import remarkGfm from "remark-gfm";
-import { useEventStore } from "@/store/events";
-import { useAgentChatStore } from "@/store/agentChat";
+import { useEventStore, type ChatMessage } from "@/store/events";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { AgentComposer } from "@/components/agentchat/AgentComposer";
-import { AgentTimeline } from "@/components/agentchat/AgentTimeline";
+import { ChatInput } from "@/components/ChatInput";
+import { TurnSteps } from "@/components/home/TurnSteps";
import { Greeting } from "@/components/home/Greeting";
import { VoiceThreadStage } from "@/components/home/VoiceThreadStage";
-import type { ApprovalDecision } from "@/lib/agentChatApi";
import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
/**
- * The chat stage — the typed half of the front page.
+ * The chat stage — Jarvis with a keyboard.
*
- * Since 2026-08-23 this is the AGENT chat (jarvis/agent_chat): a coding-agent
- * session on whichever sub-agent — Claude Code, Codex, Antigravity, Grok
- * Build, or an API-key provider — the composer picks, with the model, the
- * reasoning effort and the permission mode dialled in the composer itself.
- * The voice stage next door still talks to the voice brain; this stage does
- * not (AP-9: nothing here touches the voice path).
+ * This is the SAME assistant the microphone talks to, on the same brain, with
+ * the same tools, the same memory and the same conversation history. The only
+ * difference from the voice stage next door is the input: here the person
+ * types and reads instead of speaking and listening. Everything a spoken turn
+ * can do — open an app, read the calendar, run a skill, ask back before a
+ * consequential action — a typed turn does too, because it is literally the
+ * same turn (jarvis/ui/desktop_app.py::_on_user_message → BrainManager).
*
- * One centred column, like a document: the greeting and the composer sit
- * in the middle of an empty page; once there are messages the column
- * scrolls and the composer docks to the bottom. The history is the
- * sidebar's (components/home/RecentChats), visible from every section.
+ * What it is NOT, and was between 2026-08-23 and 2026-08-24: a coding-agent
+ * session that happened to run in the Jarvis folder, picked by provider,
+ * model, reasoning effort and permission mode. Coding agents are a real thing
+ * this app has — they are the Agentic IDE's sessions, where a workspace
+ * folder is the whole point. On the front page that was the wrong assistant
+ * wearing the right name (maintainer, 2026-08-24).
*
- * 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.
+ * The wiring, end to end:
+ * composer (components/ChatInput) sends a `message` frame on the app socket
+ * → MessageSent on the event bus
+ * → the brain answers, streaming its text as AssistantTextDelta("chat")
+ * and its progress as the reasoning steps this column shows live
+ * → the finished reply arrives as the assistant message and is stored in
+ * the thread, so the sidebar's history holds it like any other.
*
- * 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.
- * A spacer under the last turn makes that possible even when the turn is
- * short; it shrinks as the answer fills the viewport. Nothing jumps on
- * assistant output.
+ * A spoken session opened from that history is READ here, in
+ * components/home/VoiceThreadStage: the same column, no composer, because a
+ * spoken thread is continued by speaking.
+ *
+ * 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. A spacer
+ * under the last turn makes that possible even when the turn is short; it
+ * shrinks as the answer fills the viewport, so a finished answer never trails
+ * a screen of blank paper. Nothing jumps on assistant output.
*/
export function ChatStage() {
const t = useT();
- const assistantName = useEventStore((s) => s.assistantName);
- const items = useAgentChatStore((s) => s.timeline.items);
- const activeSessionId = useAgentChatStore((s) => s.activeSessionId);
- const catalog = useAgentChatStore((s) => s.catalog);
- 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(() => {
- if (!catalog) void loadCatalog();
- void loadSessions();
- }, [catalog, loadCatalog, loadSessions]);
-
- const providerLabel = useCallback(
- (id: string) => catalog?.providers.find((p) => p.id === id)?.label ?? id,
- [catalog],
- );
- const onDecide = useCallback(
- (approvalId: string, decision: ApprovalDecision) => void decide(approvalId, decision),
- [decide],
- );
+ const messages = useEventStore((s) => s.messages);
+ const chatThinking = useEventStore((s) => s.chatThinking);
+ const activeThreadId = useEventStore((s) => s.activeThreadId);
+ const isVoiceThread = useEventStore((s) => s.activeKind === "voice" && s.activeThreadId !== null);
+ const hasContent = messages.length > 0 || chatThinking;
const rootRef = useRef<HTMLDivElement | null>(null);
const columnRef = useRef<HTMLDivElement | null>(null);
@@ -72,8 +63,8 @@ export function ChatStage() {
// turn. Null until the person sends in this mounted column — opening an
// old conversation lands at its end like before, with no spacer.
const anchorIdRef = useRef<string | null>(null);
- const lastItemIdRef = useRef<string | null>(null);
- const sessionRef = useRef<string | null>(activeSessionId);
+ const lastMessageIdRef = useRef<string | null>(null);
+ const threadRef = useRef<string | null>(activeThreadId);
// Refs, not state, on purpose: the spacer must be sized BEFORE the scroll
// that relies on it, in the same layout pass — a state round-trip would
@@ -87,39 +78,44 @@ export function ChatStage() {
spacer.style.minHeight = "0px";
return;
}
+ // Everything from the anchored message down to the spacer is the turn.
const turnHeight = spacer.getBoundingClientRect().top - anchor.getBoundingClientRect().top;
const room = viewport.clientHeight - turnHeight - TURN_BOTTOM_PAD_PX;
spacer.style.minHeight = `${Math.max(0, Math.round(room))}px`;
};
- const lastItem = items[items.length - 1];
- const lastItemId = lastItem?.id ?? null;
- const lastItemIsUser = lastItem?.type === "user";
-
+ // React to the newest message: a user line is the start of a turn and gets
+ // pinned to the top; anything else, with no turn in flight, keeps the old
+ // "follow the end" behaviour (first render of a conversation). Switching
+ // conversations resets the anchor: the new thread is read from its end, not
+ // from wherever the previous turn left the scroll position.
useLayoutEffect(() => {
- if (sessionRef.current !== activeSessionId) {
- sessionRef.current = activeSessionId;
+ if (threadRef.current !== activeThreadId) {
+ threadRef.current = activeThreadId;
anchorIdRef.current = null;
- lastItemIdRef.current = null;
+ lastMessageIdRef.current = null;
}
const viewport = viewportOf(rootRef.current);
- const isNew = lastItemId !== lastItemIdRef.current;
- lastItemIdRef.current = lastItemId;
- if (!viewport || !lastItemId) return;
- if (isNew && lastItemIsUser) {
- anchorIdRef.current = lastItemId;
+ const last = messages[messages.length - 1];
+ const lastId = last?.id ?? null;
+ const isNew = lastId !== lastMessageIdRef.current;
+ lastMessageIdRef.current = lastId;
+ if (!viewport || !last) return;
+ if (isNew && last.role === "user") {
+ anchorIdRef.current = last.id;
applySpacer();
- scrollMessageToTop(viewport, lastItemId);
+ scrollMessageToTop(viewport, last.id);
return;
}
applySpacer();
if (isNew && anchorIdRef.current === null) scrollToEnd(viewport);
// `applySpacer` reads refs only and is recreated per render by design.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [lastItemId, lastItemIsUser, activeSessionId, items.length]);
+ }, [messages, activeThreadId, chatThinking]);
- // The live blocks grow without a new item; the spacer follows the
- // column's size where the platform has ResizeObserver.
+ // The live turn grows without a new message (steps arrive, the answer
+ // streams in), so the spacer also follows the column's own size where the
+ // platform has ResizeObserver.
useEffect(() => {
const column = columnRef.current;
const viewport = viewportOf(rootRef.current);
@@ -131,41 +127,45 @@ export function ChatStage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasContent]);
- 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 />;
+ // the composer would otherwise own.
+ if (isVoiceThread) return <VoiceThreadStage />;
if (!hasContent) {
return (
- <div className="flex min-h-0 flex-1 flex-col items-center" data-testid="chat-stage" data-empty="true">
+ <div
+ className="flex min-h-0 flex-1 flex-col items-center"
+ data-testid="chat-stage"
+ data-empty="true"
+ >
<div className="flex w-full max-w-[760px] flex-1 flex-col justify-center gap-8 px-6 pb-20">
- <Greeting subtitle={subtitle} />
- <AgentComposer autoFocus />
+ <Greeting subtitle={t("home.chat_empty_title")} />
+ <ChatInput />
</div>
</div>
);
}
return (
- <div className="flex min-h-0 flex-1 flex-col items-center" data-testid="chat-stage" data-empty="false">
+ <div
+ className="flex min-h-0 flex-1 flex-col items-center"
+ data-testid="chat-stage"
+ data-empty="false"
+ >
<ScrollArea ref={rootRef} className="min-h-0 w-full flex-1">
<div
ref={columnRef}
className="relative mx-auto flex w-full max-w-[760px] flex-col gap-5 px-6 pb-6 pt-8"
>
- <AgentTimeline
- items={items}
- assistantName={assistantName}
- providerLabel={providerLabel}
- onDecide={onDecide}
- />
+ {messages.map((m) => (
+ <MessageRow key={m.id} message={m} />
+ ))}
+ {chatThinking && <LiveTurn />}
<div ref={spacerRef} aria-hidden data-testid="chat-bottom-spacer" className="shrink-0" />
</div>
</ScrollArea>
<div className="w-full max-w-[760px] px-6 pb-5 pt-2">
- <AgentComposer />
+ <ChatInput />
</div>
</div>
);
@@ -181,8 +181,8 @@ function viewportOf(root: HTMLElement | null): HTMLElement | null {
}
function messageElement(viewport: HTMLElement, id: string): HTMLElement | null {
- // Attribute compare instead of a selector: ids carry characters a CSS
- // selector would need escaping for.
+ // Attribute compare instead of a selector: message ids carry characters
+ // (":" , ".") a CSS selector would need escaping for.
for (const el of Array.from(viewport.querySelectorAll<HTMLElement>("[data-message-id]"))) {
if (el.dataset.messageId === id) return el;
}
@@ -213,3 +213,143 @@ function scrollMessageToTop(viewport: HTMLElement, id: string) {
function scrollToEnd(viewport: HTMLElement) {
scrollViewport(viewport, viewport.scrollHeight);
}
+
+/** Elapsed wall-clock since `startedTs`, ticking once a second while set. */
+function useElapsedMs(startedTs: number | null): number {
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (startedTs === null) return;
+ setNow(Date.now());
+ const id = window.setInterval(() => setNow(Date.now()), 1000);
+ return () => window.clearInterval(id);
+ }, [startedTs]);
+ return startedTs === null ? 0 : Math.max(0, now - startedTs);
+}
+
+/**
+ * The assistant turn still in progress: byline, the live steps, and the
+ * answer as it is being written.
+ *
+ * The streaming text is the half that was missing while this column showed
+ * only the steps: the brain publishes the answer as cumulative
+ * AssistantTextDelta snapshots on the "chat" channel several times a second
+ * (jarvis/core/text_stream.py), so a long reply reads as it arrives instead
+ * of appearing at once when the turn ends. The store clears it the moment the
+ * finished message lands, so the two never show the same words twice.
+ *
+ * Reads the store itself so the column does not re-render on every delta —
+ * only this block does.
+ */
+function LiveTurn() {
+ const assistantName = useEventStore((s) => s.assistantName);
+ const steps = useEventStore((s) => s.thinkingSteps);
+ const startedTs = useEventStore((s) => s.thinkingStartedTs);
+ const liveText = useEventStore((s) => s.liveReply?.text ?? "");
+ const elapsed = useElapsedMs(startedTs);
+ return (
+ <div className="flex flex-col gap-1.5 px-1" data-testid="chat-turn-live">
+ <Byline name={assistantName} />
+ <TurnSteps steps={steps} live durationMs={elapsed} />
+ {liveText.trim() !== "" && <Prose text={liveText} testId="chat-live-text" />}
+ </div>
+ );
+}
+
+function Byline({ name }: { name: string }) {
+ return (
+ <div className="flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-primary">
+ <span className="h-1 w-1 rounded-full bg-primary" aria-hidden />
+ {name}
+ </div>
+ );
+}
+
+/**
+ * An assistant answer, rendered as Markdown.
+ *
+ * Jarvis writes lists, short headings and the odd bit of code, and typed
+ * answers are read rather than heard — so an answer is rendered, not printed
+ * as source. Colours come from theme tokens (`prose-neutral` +
+ * `dark:prose-invert`), so it reads correctly in light and dark. The person's
+ * own lines stay plain text: they typed characters, not markup.
+ */
+function Prose({ text, testId }: { text: string; testId?: string }) {
+ return (
+ <div
+ data-testid={testId}
+ className={cn(
+ "prose prose-neutral max-w-none text-[15px] leading-relaxed dark:prose-invert [overflow-wrap:anywhere]",
+ "prose-p:my-2 prose-headings:font-display prose-headings:tracking-tight prose-h1:text-xl prose-h2:text-lg prose-h3:text-base",
+ "prose-a:text-primary prose-a:no-underline hover:prose-a:underline",
+ "prose-code:rounded prose-code:bg-muted/60 prose-code:px-1 prose-code:py-0.5 prose-code:font-mono prose-code:text-[0.85em] prose-code:font-normal prose-code:before:hidden prose-code:after:hidden",
+ "prose-pre:my-2 prose-pre:border prose-pre:border-border prose-pre:bg-card/80 prose-pre:text-[13px]",
+ "prose-li:my-0.5 prose-ul:my-2 prose-ol:my-2",
+ )}
+ >
+ <ReactMarkdown remarkPlugins={[remarkGfm]}>{text}</ReactMarkdown>
+ </div>
+ );
+}
+
+/**
+ * One message in the column. The person's lines sit right in a quiet bubble;
+ * the assistant's run flush-left with a byline and, when there is one, the
+ * turn's steps ("Thought for Ns" + tool calls) above the answer — prose on
+ * the page, not a bubble.
+ */
+function MessageRow({ message }: { message: ChatMessage }) {
+ const assistantName = useEventStore((s) => s.assistantName);
+ const liveTrace = useEventStore((s) => s.thinkingTraces[message.id]);
+ // A replayed conversation carries its steps on the message itself; a reply
+ // that happened in this session has them in the store's live map.
+ const trace = liveTrace ?? message.trace;
+ const isUser = message.role === "user";
+
+ if (message.role === "system") {
+ return (
+ <div
+ data-message-id={message.id}
+ data-testid="chat-message-system"
+ className="mx-auto max-w-[85%] rounded-lg border border-border bg-secondary/50 px-3 py-2 text-center text-xs italic text-muted-foreground"
+ >
+ {message.content}
+ </div>
+ );
+ }
+
+ if (message.role === "preamble") {
+ return (
+ <div
+ data-message-id={message.id}
+ className="flex flex-col gap-1 text-xs italic leading-relaxed text-muted-foreground"
+ >
+ <span className="font-mono text-[10px] not-italic uppercase tracking-[0.14em] text-muted-foreground">
+ {assistantName} · pre-ack
+ </span>
+ <div className="whitespace-pre-wrap">{message.content}</div>
+ </div>
+ );
+ }
+
+ if (isUser) {
+ return (
+ <div className="flex justify-end" data-testid="chat-message-user" data-message-id={message.id}>
+ <div className="max-w-[78%] rounded-2xl rounded-br-md border border-border bg-secondary px-4 py-2.5 text-[15px] leading-relaxed text-foreground">
+ <div className="whitespace-pre-wrap">{message.content}</div>
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <div
+ className="flex flex-col gap-1.5 px-1"
+ data-testid="chat-message-assistant"
+ data-message-id={message.id}
+ >
+ <Byline name={assistantName} />
+ {trace && <TurnSteps steps={trace.steps} durationMs={trace.durationMs} className="mb-1" />}
+ <Prose text={message.content} />
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx
index e8f69ae5ad..b0eb9826df 100644
--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.test.tsx
@@ -2,17 +2,23 @@ import { act, cleanup, fireEvent, render, screen } from "@testing-library/react"
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { RecentChats } from "@/components/home/RecentChats";
-import { useAgentChatStore } from "@/store/agentChat";
import { useEventStore, type ConversationSummary } from "@/store/events";
import { useHomeStore } from "@/store/home";
+/**
+ * The sidebar history lists Jarvis' own conversations — the ones you spoke and
+ * the ones you typed — because both are the same assistant. The Agentic IDE's
+ * agent chats are listed in the IDE, next to the folder they belong to; a row
+ * for one here would open a surface the front page does not have.
+ */
+
function row(kind: ConversationSummary["kind"], id: string, title: string): ConversationSummary {
return { 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 = {
+const VOICE_DETAIL = {
kind: "voice",
id: "v1",
title: "Voice session",
@@ -23,6 +29,17 @@ const DETAIL = {
seeded_turns: 2,
};
+const TEXT_DETAIL = {
+ kind: "text",
+ id: "t1",
+ title: "Typed thread",
+ messages: [
+ { role: "user", text: "was steht an", ts_ms: 1_000 },
+ { role: "assistant", text: "Zwei Termine.", ts_ms: 2_000 },
+ ],
+ seeded_turns: 2,
+};
+
async function flush() {
await act(async () => {
await Promise.resolve();
@@ -34,43 +51,25 @@ describe("RecentChats", () => {
beforeEach(() => {
vi.stubGlobal(
"fetch",
- vi.fn(async (url: string) =>
- String(url).endsWith("/resume")
- ? new Response(JSON.stringify(DETAIL), { 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 }),
- ),
+ vi.fn(async (url: string) => {
+ const href = String(url);
+ if (href.endsWith("/resume")) {
+ const detail = href.includes("/t1/") ? TEXT_DETAIL : VOICE_DETAIL;
+ return new Response(JSON.stringify(detail), { 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.
+ return new Response(JSON.stringify(CONVERSATIONS), { status: 200 });
+ }),
);
useEventStore.setState({
conversations: CONVERSATIONS,
activeThreadId: null,
+ activeKind: "text",
messages: [],
activeSection: "board",
});
useHomeStore.setState({ surface: "voice", transcript: [] });
- useAgentChatStore.setState({
- sessions: [
- {
- session_id: "s1",
- title: "Agent chat",
- provider: "claude-api",
- model: "",
- effort: "high",
- cwd: "C:\work",
- permission_mode: "acceptEdits",
- vendor_session: null,
- created_ms: 500,
- updated_ms: 900,
- message_count: 2,
- preview: "Agent chat",
- },
- ],
- activeSessionId: null,
- loadSessions: async () => {},
- newChat: vi.fn(),
- openSession: vi.fn((id: string) => useAgentChatStore.setState({ activeSessionId: id })),
- });
});
afterEach(() => {
cleanup();
@@ -90,30 +89,22 @@ describe("RecentChats", () => {
]);
});
- it("opens an agent chat on the chat surface even from the voice stage", async () => {
+ it("opens a typed thread on the chat surface, even from the voice stage", async () => {
render(<RecentChats />);
- // The classic brain's text threads are no longer listed — the chat
- // surface is the agent chat now (components/home/ChatStage).
- expect(screen.queryByTitle("Typed thread")).toBeNull();
- fireEvent.click(screen.getByTitle("Agent chat"));
+ fireEvent.click(screen.getByTitle("Typed thread"));
await flush();
expect(useHomeStore.getState().surface).toBe("chat");
expect(useEventStore.getState().activeSection).toBe("chats");
- expect(useAgentChatStore.getState().openSession).toHaveBeenCalledWith("s1");
+ expect(useEventStore.getState().activeThreadId).toBe("t1");
+ expect(useEventStore.getState().activeKind).toBe("text");
+ expect(useEventStore.getState().messages.map((m) => m.content)).toEqual([
+ "was steht an",
+ "Zwei Termine.",
+ ]);
+ // A typed thread is read on the chat stage, not spoken back into the lane.
expect(useHomeStore.getState().transcript).toEqual([]);
});
- 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 />);
@@ -121,11 +112,9 @@ describe("RecentChats", () => {
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.
+ // into the voice lane.
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([]);
});
@@ -136,7 +125,7 @@ describe("RecentChats", () => {
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"]);
+ expect(rows.map((r) => r.getAttribute("data-kind")).sort()).toEqual(["text", "voice"]);
});
it("filters the archive by what you type", async () => {
diff --git a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
index a917973744..9edd311ab7 100644
--- a/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/RecentChats.tsx
@@ -1,22 +1,19 @@
-import { useEffect, useState } from "react";
+import { useState } from "react";
import { Archive, MessageSquare, Mic, Trash2 } from "lucide-react";
-import { useAgentChatStore } from "@/store/agentChat";
import { useT } from "@/i18n";
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;
export const RECENT_CHATS_UNFOLDED = 15;
/**
- * The last conversations — agent chats and voice sessions in one list —
- * from the sidebar. This block is the one long-lived poller of both
- * histories (`useConversations({ poll: true })` for the voice sessions,
- * the agent-chat store's session list for the typed ones).
+ * The last conversations — the ones you typed and the ones you spoke, in one
+ * list — from the sidebar. This block is the app's one long-lived poller of
+ * that history (`useChatRows({ poll: true })`).
*
* It is a shortcut, not the archive: it shows the handful you touched last
* and hands everything else to "All chats" (components/home/AllChatsDialog),
@@ -27,26 +24,18 @@ export const RECENT_CHATS_UNFOLDED = 15;
* 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. 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.
+ * A typed thread goes to the chat surface and is continued by typing.
*
- * 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
- * stays on disk.
+ * Both are Jarvis, which is why they share one list. The Agentic IDE's agent
+ * chats are not here — they belong to a workspace folder and are listed where
+ * that folder is (components/agentic/WorkspaceChats).
*/
export function RecentChats() {
const t = useT();
const { rows, isActive, open: openRow, remove } = useChatRows({ poll: true });
- const loadSessions = useAgentChatStore((s) => s.loadSessions);
const [open, setOpen] = useState(false);
const [archiveOpen, setArchiveOpen] = useState(false);
- useEffect(() => {
- void loadSessions();
- const id = window.setInterval(() => void loadSessions(), CONVERSATIONS_REFRESH_MS);
- return () => window.clearInterval(id);
- }, [loadSessions]);
-
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.
@@ -77,7 +66,7 @@ export function RecentChats() {
row={row}
active={isActive(row)}
onOpen={() => openRow(row)}
- onDelete={row.kind === "agent" ? () => remove(row) : undefined}
+ onDelete={row.kind === "text" ? () => remove(row) : undefined}
/>
))}
</ul>
diff --git a/jarvis/ui/web/frontend/src/components/home/chatRows.ts b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
index 538e0cc63c..197c27f640 100644
--- a/jarvis/ui/web/frontend/src/components/home/chatRows.ts
+++ b/jarvis/ui/web/frontend/src/components/home/chatRows.ts
@@ -2,38 +2,42 @@ 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.
+ * The one chat history the front page has, and the one way to open a row.
*
- * 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.
+ * Both kinds in it are the SAME assistant: the voice sessions you spoke and
+ * the chats you typed, from `/api/chats`, merged into one list sorted by when
+ * each was last touched. That is the point of the front page — one Jarvis,
+ * two ways to reach it — and it is why a typed thread can pick up where a
+ * spoken one stopped. 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.
+ * The Agentic IDE's agent chats are deliberately NOT here (maintainer,
+ * 2026-08-24). They belong to a workspace folder and are opened where that
+ * folder is — components/agentic/WorkspaceChats. Listing them next to Jarvis'
+ * own conversations was the visible half of the mix-up this file's history
+ * records: for a day, opening the front page's chat opened a coding agent.
+ *
+ * The rule a click follows: the front page shows exactly ONE conversation, so
+ * opening a row replaces whatever was on stage. A spoken session opened while
+ * the voice stage is up stays there with its words in the lane; opened from
+ * the chat surface it is read there as an archive
+ * (components/home/VoiceThreadStage).
*/
export interface ChatRow {
- kind: "voice" | "agent";
+ /** "voice" was spoken, "text" was typed — both are Jarvis. */
+ kind: "voice" | "text";
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;
+ raw: ConversationSummary;
}
export interface ChatRowsApi {
@@ -41,59 +45,45 @@ export interface ChatRowsApi {
/** 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. */
+ /** A typed thread 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 { conversations, openConversation, removeConversation } = useConversations({ poll });
+ const activeThreadId = useEventStore((s) => s.activeThreadId);
+ const activeKind = useEventStore((s) => s.activeKind);
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 rows = useMemo<ChatRow[]>(
+ () =>
+ conversations
+ .map((c) => ({
+ kind: c.kind === "voice" ? ("voice" as const) : ("text" as const),
+ id: c.id,
+ title: c.title || c.preview,
+ preview: c.preview,
+ updatedMs: c.updated_ms,
+ messageCount: c.message_count,
+ raw: c,
+ }))
+ .sort((a, b) => b.updatedMs - a.updatedMs),
+ [conversations],
+ );
const isActive = useCallback(
- (row: ChatRow) => (row.kind === "agent" ? row.id === activeSessionId : row.id === activeVoiceId),
- [activeSessionId, activeVoiceId],
+ (row: ChatRow) => row.id === activeThreadId && row.kind === activeKind,
+ [activeKind, activeThreadId],
);
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();
+ // Standing on the voice stage, a spoken session is resumed there with
+ // its words in the lane — you just keep talking. From the chat
+ // surface it is read as an archive instead.
const stayOnVoice = useHomeStore.getState().surface === "voice";
const opened = openConversation("voice", row.id);
if (stayOnVoice) {
@@ -103,22 +93,21 @@ export function useChatRows({ poll = false }: { poll?: boolean } = {}): ChatRows
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);
+ void openConversation("text", row.id);
setSurface("chat");
}
setActiveSection("chats");
},
- [openConversation, seedTranscript, setActiveConversation, setActiveSection, setMessages, setSurface],
+ [openConversation, seedTranscript, setActiveSection, setSurface],
);
- const remove = useCallback((row: ChatRow) => {
- if (row.kind !== "agent") return;
- void useAgentChatStore.getState().removeSession(row.id);
- }, []);
+ const remove = useCallback(
+ (row: ChatRow) => {
+ if (row.kind !== "text") return;
+ void removeConversation(row.id);
+ },
+ [removeConversation],
+ );
return { rows, isActive, open, remove };
}
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index d1ff505b69..bb5768ef9d 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -26,7 +26,6 @@ import { SurfaceSwitch } from "@/components/home/SurfaceSwitch";
import { RecentChats } from "@/components/home/RecentChats";
import { useConversations } from "@/hooks/useConversations";
import { useHomeStore } from "@/store/home";
-import { useAgentChatStore } from "@/store/agentChat";
import { useIdeChatStore } from "@/store/ideChat";
import { WorkspaceChats } from "@/components/agentic/WorkspaceChats";
import { PRODUCT_NAME } from "@/lib/branding";
@@ -129,11 +128,11 @@ export function Sidebar({
const appInstance = useAppInstance();
const devTag = appInstance?.isDev ? appInstance.name.toUpperCase() : null;
// "+ New" starts a new conversation of the KIND you are looking at: on the
- // chat surface an empty agent chat, on the voice stage a fresh voice run.
- // Sending someone standing in Voice to the chat page is what the one button
- // used to do, and it read as the button being broken.
+ // chat surface an empty chat with Jarvis, on the voice stage a fresh voice
+ // run. Sending someone standing in Voice to the chat page is what the one
+ // button used to do, and it read as the button being broken. The Agentic
+ // IDE's chats have their own button in their own column (WorkspaceChats).
const { newChat, newVoiceRun } = useConversations();
- const newAgentChat = useAgentChatStore((s) => s.newChat);
const setSurface = useHomeStore((s) => s.setSurface);
// The front page's nav row names the face the switch picked (Voice / Chat),
// see `presentNavItem`.
@@ -167,11 +166,11 @@ export function Sidebar({
void newVoiceRun();
setActive("chats");
};
- // On the chat surface: an empty agent chat. The voice thread is cleared as
- // well so a reopened voice session does not linger behind the fresh page.
+ // On the chat surface: an empty page for a new chat with Jarvis. `newChat`
+ // drops the open thread whichever kind it was, so a reopened voice session
+ // does not linger behind the fresh page either.
const startNewChat = () => {
newChat();
- newAgentChat();
setSurface("chat");
setActive("chats");
};