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(agentic-ide): fold a finished thread turn behind "Worked for …"

rubenluetke10-beepa6a359a1c0ca
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
index 364d850980..2410e6e279 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.test.tsx
@@ -23,6 +23,10 @@ afterEach(cleanup);
describe("thread work log", () => {
it("folds a finished stretch to one counted line that opens to its steps", () => {
show(turn([thought("r1", "**Checking the build**"), tool("c1", "npm run build"), tool("c2", "npm test"), { kind: "text", id: "n1", text: "All green." }]));
+ // A finished turn folds its work behind one "Worked for" line; the answer stays.
+ expect(screen.getByText("All green.")).toBeTruthy();
+ expect(screen.queryByRole("button", { name: /Ran 2 commands/ })).toBeNull();
+ fireEvent.click(screen.getByTestId("thread-worked-for"));
const header = screen.getByRole("button", { name: /Ran 2 commands/ });
expect(screen.queryByText("npm test")).toBeNull();
fireEvent.click(header);
@@ -34,6 +38,7 @@ describe("thread work log", () => {
it("opens a thought to its full text under a timed heading", () => {
show(turn([thought("r1", "First idea.\n\nSecond idea.")]));
+ fireEvent.click(screen.getByTestId("thread-worked-for"));
fireEvent.click(screen.getByRole("button", { name: /First idea\. Second idea\./ }));
expect(screen.getByText("Thought for 4.2s")).toBeTruthy();
expect(screen.getByText("Second idea.")).toBeTruthy();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
index 2bdfda2a57..fcaa83a7f7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTimeline.tsx
@@ -8,7 +8,7 @@ import { readableOutput, traceDuration, type Call } from "@/components/agentchat
import { useT } from "@/i18n";
import { robustCopy } from "@/lib/clipboard";
import { cn } from "@/lib/utils";
-import { buildThreadRows, isFailed, liveItem, thoughtPreview, type WorkGroup, type WorkItem } from "./threadWork";
+import { buildThreadRows, isFailed, liveItem, thoughtPreview, type ThreadRow, type WorkGroup, type WorkItem } from "./threadWork";
/**
* A thread's conversation: the person's messages on the right, the agent's
@@ -505,19 +505,48 @@ function pendingLabel(block: ToolBlock): { icon: ReactNode; text: string } | nul
return null;
}
+/**
+ * A finished turn read the short way: everything up to its last step folds
+ * behind one "Worked for …" line, and the text written after that step — the
+ * answer — stays in view. A turn with no step at all has nothing to fold.
+ */
+export function foldFinished(rows: ThreadRow[]): { work: ThreadRow[]; answer: ThreadRow[] } {
+ let last = -1;
+ rows.forEach((row, index) => { if (row.kind !== "text") last = index; });
+ return { work: rows.slice(0, last + 1), answer: rows.slice(last + 1) };
+}
+
const TurnView = memo(function TurnView({ turn }: { turn: TurnItem }) {
const t = useT();
const lang = t("trace_report.locale");
const running = turn.status === "running";
const rows = useMemo(() => buildThreadRows(turn.blocks, { t, lang, status: turn.status }), [turn.blocks, t, lang, turn.status]);
const answer = answerText(turn);
+ const [workOpen, setWorkOpen] = useState(false);
+ // Finished: every step and thought folds behind one "Worked for …" line; the answer stays.
+ const { work, answer: tail } = useMemo(() => (running ? { work: rows, answer: [] } : foldFinished(rows)), [rows, running]);
+ const folded = !running && work.length > 0;
+ const duration = turn.durationMs != null ? traceDuration(turn.durationMs) : "";
+ const foldLabel = turn.status === "cancelled" ? `Stopped${duration ? ` after ${duration}` : ""}`
+ : turn.status === "error" ? `Failed${duration ? ` after ${duration}` : ""}`
+ : `Worked${duration ? ` for ${duration}` : ""}`;
+ const renderRow = (row: ThreadRow) => {
+ if (row.kind === "work") return <WorkGroupView key={row.id} group={row} running={running} />;
+ if (row.kind === "text") return <div key={row.id} className={PROSE}><ChatMarkdown text={row.text} /></div>;
+ const pending = pendingLabel(row.block);
+ return pending ? <WorkRow key={row.id} icon={pending.icon} label={pending.text} live /> : null;
+ };
return <div className="space-y-1.5" data-testid="thread-turn" data-status={turn.status}>
- {rows.map((row) => {
- if (row.kind === "work") return <WorkGroupView key={row.id} group={row} running={running} />;
- if (row.kind === "text") return <div key={row.id} className={PROSE}><ChatMarkdown text={row.text} /></div>;
- const pending = pendingLabel(row.block);
- return pending ? <WorkRow key={row.id} icon={pending.icon} label={pending.text} live /> : null;
- })}
+ {folded && <div>
+ <button type="button" aria-expanded={workOpen} onClick={() => setWorkOpen((value) => !value)} data-testid="thread-worked-for"
+ className="flex h-7 items-center gap-1 rounded-md px-1 text-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <span className="tabular-nums">{foldLabel}</span>
+ <ChevronRight aria-hidden className={cn("h-3.5 w-3.5 transition-transform duration-150", workOpen && "rotate-90")} />
+ </button>
+ {workOpen && <div className="space-y-1.5 pb-2 pt-1" data-testid="thread-worked-steps">{work.map(renderRow)}</div>}
+ <div aria-hidden className="mt-1 border-b border-border/70" />
+ </div>}
+ {(folded ? tail : rows).map(renderRow)}
{running
? <div className="flex h-6 min-w-0 items-center px-1 text-sm leading-relaxed text-muted-foreground" data-testid="thread-working">
<span className="whitespace-nowrap">Working for <Elapsed since={turn.startedMs} /></span>
@@ -526,10 +555,11 @@ const TurnView = memo(function TurnView({ turn }: { turn: TurnItem }) {
{turn.status === "error" && turn.error && <p role="alert" className="rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">{turn.error}</p>}
<ChangedFiles turn={turn} />
<div className="flex items-center gap-1.5 pt-1 text-xs text-muted-foreground">
- <span>
+ {!folded && <span>
{turn.status === "cancelled" ? "Stopped" : turn.status === "error" ? "Failed" : answer ? "" : "Finished without an answer"}
- {turn.durationMs != null && <>{turn.status === "done" && answer ? "Worked for " : " after "}{traceDuration(turn.durationMs)}</>}
- </span>
+ {duration && <>{turn.status === "done" && answer ? "Worked for " : " after "}{duration}</>}
+ </span>}
+ {folded && !answer && <span>Finished without an answer</span>}
{answer && <CopyButton text={answer} label="Copy answer" />}
</div>
</>}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx
index 4f526c13dc..41fd9b9630 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.test.tsx
@@ -145,8 +145,12 @@ describe("ThreadView", () => {
expect(screen.getByText("The test passes now.")).toBeTruthy();
expect(screen.getByTestId("thread-turn").getAttribute("data-status")).toBe("done");
expect(screen.getByText(/Worked for/)).toBeTruthy();
- // Two calls fold to one line until opened.
+ // A finished turn folds every step behind one line; the answer stays in view.
+ expect(screen.getByTestId("thread-worked-for").textContent).toContain("Worked for 3.0s");
+ expect(screen.queryByTestId("thread-worked-steps")).toBeNull();
expect(screen.queryByText("npm test")).toBeNull();
+ fireEvent.click(screen.getByTestId("thread-worked-for"));
+ expect(screen.getByTestId("thread-worked-steps")).toBeTruthy();
});
});