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
feat(trace): fold a finished turn's work behind "Thought for …" above the reply
rubenluetke10-beepdd5110e7f062
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsxindex e899d62ec0..4a0fd4a086 100644--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx@@ -15,6 +15,11 @@ const props = { startedMs: 1000, durationMs: 12000, status: "done" as TurnStatusconst rows = { ...props, look: "classic" as const };afterEach(() => { cleanup(); vi.useRealTimers(); });+/** A finished, answered turn folds its work behind "Thought for …"; open every fold. */+const openWork = () => {+ for (const toggle of Array.from(document.querySelectorAll<HTMLElement>("[data-testid='conversation-work-fold'][data-open='false'] > button"))) fireEvent.click(toggle);+};+describe("work trace", () => {it("summarizes integrations and mutations in first-use order with original logos", () => {const blocks = [tool("linear", {name:"mcp__codex_apps__linear_list_issues"}), tool("edit", {name:"apply_patch"}), tool("shell", {name:"exec_command"}), tool("again", {name:"linear/get_issue"})];@@ -59,6 +64,7 @@ describe("work trace", () => {it("preserves reasoning, call, next step and final answer order", () => {const blocks = [thought, tool("a"), { kind: "text" as const, id: "next", text: "Next, check the tests." }, tool("b"), { kind: "text" as const, id: "final", text: "Everything is ready." }];render(<WorkTrace {...props} blocks={blocks} />);+ openWork();const text = screen.getByTestId("work-trace").textContent!;expect(text.indexOf("Check the input")).toBeLessThan(text.indexOf("a.ts"));expect(text.indexOf("a.ts")).toBeLessThan(text.indexOf("Next, check"));@@ -260,10 +266,10 @@ describe("rail look", () => {expect(screen.getByRole("status").className).toMatch(/border-t/);});- it("shows a plugin call by its own logo, with nothing folded", () => {+ it("shows a plugin call by its own logo once the folded work opens", () => {const blocks = [tool("linear", { name: "mcp__codex_apps__linear_list_issues" }), reply("done", "Three issues are open.")];render(<WorkTrace {...props} conversation blocks={blocks} />);- expect(screen.queryByTestId("conversation-work-fold")).toBeNull();+ openWork();const line = screen.getByRole("button", { name: /^Linear/ });expect(line.querySelector("img, [data-logo]")).toBeTruthy();expect(screen.getByText("Three issues are open.")).toBeTruthy();diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsxindex fb6408f9c9..d2f046f6e4 100644--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx@@ -503,8 +503,10 @@ function ActivityIcon({ blocks, live }: { blocks: TurnBlock[]; live: boolean })}/** Small chevron that hides finished work so the reply can stand alone. */-function ConversationWorkFold({ durationMs, attention, children }: {+function ConversationWorkFold({ durationMs, attention, children, expandInner = true }: {durationMs: number | null; attention?: ReactNode; children: ReactNode;+ /** Classic rows open every inner disclosure with the fold; the rail keeps its one-line stretches. */+ expandInner?: boolean;}) {const t = useT();const id = useId();@@ -526,7 +528,7 @@ function ConversationWorkFold({ durationMs, attention, children }: {<ChevronRight aria-hidden className={cn("h-3 w-3 shrink-0 opacity-70 transition-transform group-hover/fold:opacity-100", open && "rotate-90")} /><span className="truncate">{label}</span></button>- {open ? <div id={id}><FoldExpandContext.Provider value={seq}>{children}</FoldExpandContext.Provider></div> : attention}+ {open ? <div id={id}><FoldExpandContext.Provider value={expandInner ? seq : 0}>{children}</FoldExpandContext.Provider></div> : attention}</div>);}@@ -630,10 +632,10 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, errorconst blocks = useMemo(() => withoutQuestionPolls(rawBlocks), [rawBlocks]);const live = status === "running";const elapsed = useClock(startedMs, live);- // A finished turn is split into its work and its answer. The classic look- // folds conversation work behind "Thought for …"; the rail look never folds- // — like the Codex app, the narration and one quiet line per stretch of- // calls stay in view above the answer (TraceTimeline).+ // A finished turn is split into its work and its answer. Both looks fold+ // the work behind "Thought for …" once the turn has answered (maintainer,+ // 2026-10-03): the chat then reads as message and reply, and one tap+ // brings the whole trace back.const split = useMemo(() => (conversation || rail) && !live ? splitConversationTurn(blocks) : null, [blocks, conversation, rail, live]);// A finished conversation turn shows the reply and nothing else. All work// — tools, thoughts, intermediate replies, failures, interruptions, and@@ -710,7 +712,7 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, errorlet extraAt = work.length;if (!split) while (extraAt > 0 && !work[extraAt - 1].rail) extraAt--;const extraItems: RailItem[] = (extras ?? []).map((extra) => ({ key: `extra:${extra.key}`, node: extra.node, rail: true }));- const items: RailItem[] = [+ const workItems: RailItem[] = [...work.slice(0, extraAt),...extraItems,...work.slice(extraAt),@@ -718,8 +720,26 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error// reply, which is always the last thing the turn shows (maintainer,// 2026-10-03 — nobody should scroll back up to find the answer)....timelineItems(afterAnswer, renderers),- ...(answerGroups ? traceGroupItems({ groups: answerGroups, ...groupProps }) : []),];+ const answerItems = answerGroups ? traceGroupItems({ groups: answerGroups, ...groupProps }) : [];+ // A finished, answered turn folds its work; a pending approval or open+ // question stays outside the fold, because it waits for the person.+ const railFold = split && answerItems.length > 0 && workItems.length > 0;+ if (railFold) {+ const waiting = [...split.work, ...split.after].filter(isPendingApproval);+ const items: RailItem[] = [...answerItems];+ if (visibleError) items.push(errorItem(visibleError, "trace:error"));+ items.push(statusItem);+ return <div className={cn("min-w-0", conversation && "w-full max-w-[44rem] self-start", className)} data-testid="work-trace" data-look="rail" data-state={status} {...(conversation ? { "data-conversation": "" } : {})}>+ <ConversationWorkFold durationMs={durationMs} expandInner={false} attention={waiting.length ? <Rail items={waiting.map((block) => ({+ key: block.callId, rail: !block.question, node: <TraceTool block={block} status={status} onDecide={onDecide} />,+ }))} /> : undefined}>+ <Rail items={workItems} />+ </ConversationWorkFold>+ <Rail items={items} />+ </div>;+ }+ const items: RailItem[] = [...workItems, ...answerItems];if (visibleError) items.push(errorItem(visibleError, "trace:error"));items.push(statusItem);return <div className={cn("min-w-0", conversation && "w-full max-w-[44rem] self-start", className)} data-testid="work-trace" data-look="rail" data-state={status} {...(conversation ? { "data-conversation": "" } : {})}>diff --git a/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsxindex 564f532f03..bf2d61f6f5 100644--- a/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx@@ -3,6 +3,11 @@ import { afterEach, describe, expect, it } from "vitest";import type { AgentChatEvent } from "@/lib/agentChatApi";import { AgentTimeline } from "./AgentTimeline";import { EMPTY_TIMELINE, reduceEvents } from "./reduce";++/** A finished, answered turn folds its work behind "Thought for …"; open every fold. */+const openWork = () => {+ for (const toggle of Array.from(document.querySelectorAll<HTMLElement>("[data-testid='conversation-work-fold'][data-open='false'] > button"))) fireEvent.click(toggle);+};import { attachTurnMessages } from "./turnMessages";let seq = 0;@@ -47,6 +52,7 @@ describe("agent messages inside the turn that asked for them", () => {it("draws the answers as quiet trace lines and keeps Jarvis's reply last", () => {const { container } = render(<AgentTimeline items={reduceEvents(EMPTY_TIMELINE, auditTurn()).items} assistantName="Jarvis"providerLabel={(id) => id} onDecide={() => undefined} bubbles traceLook="rail" />);+ openWork();// No full-text cards: one line per answer, inside the turn.const lines = Array.from(container.querySelectorAll<HTMLElement>("[data-trace-entry='message']"));expect(lines.map((line) => line.textContent)).toEqual([diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsxindex c71606867f..07cf074019 100644--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx@@ -3,6 +3,11 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { ChatStage } from "@/components/home/ChatStage";++/** A finished, answered turn folds its work behind "Thought for …"; open every fold. */+const openWork = () => {+ for (const toggle of Array.from(document.querySelectorAll<HTMLElement>("[data-testid='conversation-work-fold'][data-open='false'] > button"))) fireEvent.click(toggle);+};import { EMPTY_TIMELINE, reduceEvents } from "@/components/agentchat/reduce";import type { AgentChatCatalog, AgentChatEvent } from "@/lib/agentChatApi";import { AgentChatStoreProvider } from "@/components/agentchat/AgentChatStoreContext";@@ -764,7 +769,8 @@ describe("ChatStage (agent chat)", () => {render(<ChatStage />);const trace = screen.getByTestId("work-trace");- // Like the Codex app, the finished turn keeps its work in view.+ // The finished turn folds its work; one tap brings it back in order.+ openWork();const text = trace.textContent!;expect(text.indexOf("First the port.")).toBeLessThan(text.indexOf("Get-NetTCPConnection"));expect(text.indexOf("Get-NetTCPConnection")).toBeLessThan(text.indexOf("It is listening."));@@ -836,6 +842,7 @@ describe("ChatStage (agent chat)", () => {]);useAgentChatStore.setState({ activeSessionId: "s9", timeline });render(<ChatStage />);+ openWork();// The plugin the turn used shows on its line by its own logo.const stretch = screen.getByRole("button", { name: /^Ran a command, used GitHub/ });expect(stretch.querySelector("img, [data-logo]")).toBeTruthy();diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsxindex 63a6e9ce6e..6eac22b4d5 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx@@ -8,6 +8,11 @@ import type { InternalMessageItem, ReasoningBlock, ToolBlock } from "@/componentbeforeAll(() => loadLocaleChunk("society"));afterEach(cleanup);+/** A finished, answered turn folds its work behind "Thought for …"; open every fold. */+const openWork = () => {+ for (const toggle of Array.from(document.querySelectorAll<HTMLElement>("[data-testid='conversation-work-fold'][data-open='false'] > button"))) fireEvent.click(toggle);+};+const envelope = "Scheduled routine task-123. Follow your CURRENT standing instructions and permissions.\nUse your memory and conversation archive for prior results. For information watches, check sources and dates, remember last-seen items, and report only meaningful new findings.\n\n";it("folds only a full scheduler envelope, preserving ordinary user messages", () => {@@ -61,8 +66,9 @@ it("keeps live and interrupted conversation tools in the left lane", () => {{ kind: "text", id: "reply", text: "I will send the mail next." },live,]} />);- // Like the Codex app, nothing folds: the model's words, the call that- // never returned and the reply all stay in view — the reply last.+ // The stopped turn folds its work; opened, the model's words, the call+ // that never returned and the reply read in order — the reply last.+ openWork();const text = screen.getByTestId("work-trace").textContent!;expect(text.indexOf("Inspect archive.")).toBeLessThan(text.indexOf("Searched for archive"));expect(text.indexOf("Searched for archive")).toBeLessThan(text.indexOf("I will send the mail next."));@@ -71,15 +77,16 @@ it("keeps live and interrupted conversation tools in the left lane", () => {expect(screen.getByTestId("work-trace").className).toMatch(/self-start/);});-it("keeps a failure in view beside the reply, its reason under its line", () => {+it("folds a failure with the work, its reason under its line once opened", () => {const tool: ToolBlock = { kind: "tool", callId: "a", name: "read_file", input: { path: "report.csv" }, output: "Report contents", isError: false, durationMs: 100, approval: null, startedMs: 0 };render(<WorkTrace conversation status="done" startedMs={0} durationMs={2000} blocks={[tool,{ ...tool, callId: "error", isError: true, output: "Upload failed" },{ kind: "text", id: "reply", text: "I could not finish." },]} />);- expect(screen.queryByTestId("conversation-work-fold")).toBeNull();expect(screen.getByText("I could not finish.")).toBeTruthy();+ expect(screen.queryByText(/: Upload failed/)).toBeNull();+ openWork();// One quiet line for the stretch; it opens to the calls, and the failed// one says why under its own line.fireEvent.click(screen.getByRole("button", { name: /^Read files$/ }));@@ -121,6 +128,9 @@ it("keeps the reply last, even when work followed it", () => {// While it runs, finished calls already read as their line.expect(screen.getByRole("button", { name: /^Read a file, created a file/ })).toBeTruthy();rerender(<WorkTrace conversation status="done" startedMs={0} durationMs={1000} blocks={blocks} />);+ // Finished: only the reply shows until the work is opened.+ expect(screen.queryByRole("button", { name: /^Read a file, created a file/ })).toBeNull();+ openWork();const text = screen.getByTestId("work-trace").textContent ?? "";expect(text.indexOf("Read a file, created a file")).toBeLessThan(text.indexOf("Your report is ready."));// The call after the reply is drawn above it: nobody scrolls back up for the answer.@@ -153,9 +163,29 @@ it("tells intermediate replies as narration once the turn completes", () => {const { container, rerender } = render(<WorkTrace conversation status="running" startedMs={0} durationMs={null} blocks={blocks} />);expect(screen.getByText("I will inspect the files first.")).toBeTruthy();rerender(<WorkTrace conversation status="done" startedMs={0} durationMs={4000} blocks={blocks} />);+ openWork();// The words between calls read as narration, not as a second answer.const narration = container.querySelector("[data-trace-entry='narration']");expect(narration?.textContent).toContain("I will inspect the files first.");expect(screen.getByText("The report is ready.")).toBeTruthy();+});++it("folds a finished turn to the reply and opens the whole trace again", () => {+ const tool: ToolBlock = { kind: "tool", callId: "a", name: "read_file", input: { path: "report.csv" }, output: "Report contents", isError: false, durationMs: 100, approval: null, startedMs: 0 };+ const thought: ReasoningBlock = { kind: "reasoning", id: "r", text: "Check the report first.", live: false, durationMs: 2000, startedMs: 0 };+ const blocks = [thought, tool, { kind: "text" as const, id: "final", text: "The report is ready." }];+ const { rerender } = render(<WorkTrace conversation status="running" startedMs={0} durationMs={null} blocks={blocks} />);+ // While the turn works, its work stays in view.expect(screen.queryByTestId("conversation-work-fold")).toBeNull();+ rerender(<WorkTrace conversation status="done" startedMs={0} durationMs={65_000} blocks={blocks} />);+ const toggle = screen.getByRole("button", { name: /^Thought for/ });+ expect(toggle.getAttribute("aria-expanded")).toBe("false");+ expect(screen.queryByText(/Check the report first/)).toBeNull();+ expect(screen.getByText("The report is ready.")).toBeTruthy();+ fireEvent.click(toggle);+ expect(screen.getByText(/Check the report first/)).toBeTruthy();+ const text = screen.getByTestId("work-trace").textContent!;+ expect(text.indexOf("Check the report first")).toBeLessThan(text.indexOf("The report is ready."));+ fireEvent.click(toggle);+ expect(screen.queryByText(/Check the report first/)).toBeNull();});diff --git a/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsxindex 5819024e56..aa64ed397f 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx@@ -1,4 +1,4 @@-import { cleanup, render, screen } from "@testing-library/react";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, describe, expect, it } from "vitest";import { WorkTrace } from "@/components/agentchat/WorkTrace";import type { NoticeItem, TimelineItem, TurnBlock, TurnItem } from "@/components/agentchat/reduce";@@ -11,6 +11,11 @@ const notice = (id: string, kind = "memory_updated"): NoticeItem => ({const user = (id: string): TimelineItem => ({ type: "user", id, text: "hi", attachments: [], tsMs: 1 } as unknown as TimelineItem);afterEach(cleanup);+/** A finished, answered turn folds its work behind "Thought for …"; open every fold. */+const openWork = () => {+ for (const toggle of Array.from(document.querySelectorAll<HTMLElement>("[data-testid='conversation-work-fold'][data-open='false'] > button"))) fireEvent.click(toggle);+};+describe("memory receipts", () => {it("move into the nearest earlier turn and never stay below it", () => {const items: TimelineItem[] = [user("u1"), turn("t1"), notice("m1"), user("u2"), notice("m2"), turn("t2"), notice("m3"), notice("r", "society_result")];@@ -35,6 +40,9 @@ describe("memory receipts", () => {return [html.indexOf("Plan."), html.indexOf("MEMORY-STEP"), html.indexOf("Final reply.")];};const { rerender } = render(<WorkTrace conversation blocks={[thought, answer]} status="done" startedMs={1} durationMs={2000} extras={extras} />);+ // Finished, the receipt folds with the rest of the work.+ expect(screen.queryByText("MEMORY-STEP")).toBeNull();+ openWork();expect(screen.getByText("MEMORY-STEP")).toBeTruthy();let [plan, memory, reply] = order();expect(memory).toBeGreaterThan(-1);