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(society): the agent card's reasoning trace reads like the Claude and ChatGPT apps
rubenluetke10-beep471a8255c33b
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex 83a2eaec45..c47dff67d7 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -7,8 +7,8 @@* voice stage use (`useAgentChatStore`, the "jarvis" surface): one history,* whatever a person said or typed anywhere. A "@Name" in the message hands* the task to that agent — Jarvis delegates through its router tool and- * reports back here. The reasoning trail stays readable: a folded- * "Thinking · 4 s" line above the answer, never a second wall of text.+ * reports back here. The reasoning trail stays readable: a centred+ * "Thought for 4s" pill above the answer, never a second wall of text.** Jarvis' card alone also has a `Voice | Chat` switch (maintainer,* 2026-09-02): Jarvis is the one agent a person talks to by voice, so the@@ -19,8 +19,8 @@* the voice runs on the realtime tier (`[brain.realtime]`), which no text* runner can drive. The header says so while voice is showing.*/-import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { MessageSquare, Mic, MicOff, Paperclip, Plus, RotateCcw, Send, Square } from "lucide-react";+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { Brain, ChevronRight, MessageSquare, Mic, MicOff, Paperclip, Plus, RotateCcw, Send, Square } from "lucide-react";import ReactMarkdown from "react-markdown";import remarkGfm from "remark-gfm";@@ -29,7 +29,9 @@ import { ChatAttachmentStrip } from "@/components/agentchat/ChatAttachmentStrip"import { useChatAttachments } from "@/components/agentchat/useChatAttachments";import { useComposerDictation } from "@/components/agentchat/useComposerDictation";import type { ReasoningBlock, TimelineItem, ToolBlock, TurnItem, UserItem } from "@/components/agentchat/reduce";+import { formatThoughtDuration } from "@/components/home/TurnSteps";import { VoiceStage } from "@/components/home/VoiceStage";+import { LiveCore } from "@/components/LiveCore";import { ProviderLogo } from "@/components/providers/ProviderLogo";import { useT } from "@/i18n";import { cn } from "@/lib/utils";@@ -570,53 +572,190 @@ function TurnBubble({const t = useT();const running = item.status === "running";return (- <div className="flex max-w-[88%] flex-col gap-1.5 self-start">+ <div className="flex w-full flex-col gap-1.5">{item.blocks.map((block) => {- if (block.kind === "reasoning") return <Thinking key={block.id} block={block} />;+ if (block.kind === "reasoning") return <ReasoningTrace key={block.id} block={block} turnLive={running} />;if (block.kind === "tool") return <ToolLine key={block.callId} block={block} onDecide={onDecide} />;if (!block.text.trim()) return null;return (<divkey={block.id}- className="society-prose rounded-2xl rounded-bl-md bg-popover px-3.5 py-2 text-sm leading-relaxed text-foreground"+ className="max-w-[88%] self-start rounded-2xl rounded-bl-md bg-popover px-3.5 py-2 text-foreground">- <ReactMarkdown remarkPlugins={[remarkGfm]}>{block.text}</ReactMarkdown>+ <Prose text={block.text} /></div>);})}{running && item.blocks.every((b) => b.kind !== "text") ? (- <div className="flex items-center gap-1 rounded-2xl rounded-bl-md bg-popover px-3.5 py-2.5" aria-label={t("society.chat.thinking")}>+ <div+ className="flex items-center gap-1 self-start rounded-2xl rounded-bl-md bg-popover px-3.5 py-2.5"+ aria-label={t("society.chat.thinking")}+ ><span className="h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground" /><span className="h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground [animation-delay:150ms]" /><span className="h-1.5 w-1.5 animate-pulse rounded-full bg-muted-foreground [animation-delay:300ms]" /></div>) : null}- {item.error ? <p className="text-xs text-destructive">{item.error}</p> : null}+ {item.error ? <p className="self-start text-xs text-destructive">{item.error}</p> : null}+ </div>+ );+}++/**+ * Markdown as prose, not as marks.+ *+ * Models write in Markdown — an answer or a thought rendered without a+ * typography scale shows raw `**like this**` and runs its lists together.+ * One scale serves both here: the answer inherits the bubble's ink, the+ * thought passes `muted`, and nothing else differs.+ */+function Prose({ text, muted }: { text: string; muted?: boolean }) {+ return (+ <div+ className={cn(+ "prose prose-neutral max-w-none dark:prose-invert [overflow-wrap:anywhere]",+ muted ? "text-xs leading-relaxed text-muted-foreground" : "text-sm leading-relaxed text-foreground",+ "prose-p:my-1.5 first:prose-p:mt-0 last:prose-p:mb-0",+ "prose-headings:my-2 prose-headings:text-[1em] prose-headings:font-semibold prose-headings:text-foreground",+ "prose-strong:font-semibold prose-strong:text-foreground",+ "prose-ul:my-1.5 prose-ol:my-1.5 prose-li:my-0.5",+ "prose-a:text-foreground prose-a:underline prose-a:underline-offset-2",+ "prose-code:rounded prose-code:bg-secondary prose-code:px-1 prose-code:py-0.5 prose-code:font-mono",+ "prose-code:text-[0.9em] prose-code:font-normal prose-code:before:hidden prose-code:after:hidden",+ "prose-pre:my-2 prose-pre:rounded-xl prose-pre:bg-secondary prose-pre:p-3 prose-pre:text-xs",+ "prose-hr:my-3 prose-blockquote:border-l-2 prose-blockquote:pl-3 prose-blockquote:not-italic",+ )}+ >+ <ReactMarkdown remarkPlugins={[remarkGfm]}>{text}</ReactMarkdown></div>);}-function Thinking({ block }: { block: ReasoningBlock }) {+/** Live elapsed readout for a running thought; 1 s is fine — the label shows whole seconds. */+function useElapsedMs(startedMs: number | null): number {+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ if (startedMs === null) return;+ setNow(Date.now());+ const id = window.setInterval(() => setNow(Date.now()), 1000);+ return () => window.clearInterval(id);+ }, [startedMs]);+ return startedMs === null ? 0 : Math.max(0, now - startedMs);+}++/**+ * The reasoning trace — the model's thinking, centred above the answer.+ *+ * Modelled on the Claude and ChatGPT desktop apps (maintainer, 2026-09-02:+ * the old `<details>` row was a bare summary with a wall of pre-wrapped text+ * under it). Three states, one shape:+ *+ * WHILE IT THINKS a centred live line — the product's one live core, a+ * shimmering "Thinking for 8s" and a ticking clock — sits over an open card+ * whose text is anchored to its NEWEST lines, so the reader watches the+ * thought arrive instead of chasing a scrollbar. Older lines fade out at the+ * top rather than being cut.+ *+ * ONCE IT CLOSES the line becomes a centred pill: a brain mark, "Thought for+ * 8s", a chevron. It stays open while the turn still works — watching the+ * work is the point of a running turn — and folds itself the moment the turn+ * lands, because a finished conversation should read as its answer.+ *+ * A REDACTED thought (the vendor hides its reasoning) is the same pill+ * without a chevron and without a card: it still says the thinking happened.+ *+ * The trace is centred on purpose: it is not the agent speaking, it is the+ * turn's own state, and the column already places its meta rows — the time+ * stamps — down the middle.+ */+export function ReasoningTrace({ block, turnLive }: { block: ReasoningBlock; turnLive: boolean }) {const t = useT();- const seconds = block.durationMs !== null ? Math.max(1, Math.round(block.durationMs / 1000)) : null;- const label = block.live- ? t("society.chat.thinking")- : seconds !== null- ? t("society.chat.thought_for").replace("{0}", String(seconds))+ // `null` until the person decides; until then the turn's own state decides.+ const [manual, setManual] = useState<boolean | null>(null);+ const text = block.text.trim();+ const live = block.live;+ const elapsed = useElapsedMs(live ? block.startedMs : null);+ const open = live || (text !== "" && (manual ?? turnLive));++ const label = live+ ? t("society.chat.thinking_for").replace("{0}", formatThoughtDuration(elapsed))+ : block.durationMs !== null && block.durationMs > 0+ ? t("society.chat.thought_for").replace("{0}", formatThoughtDuration(block.durationMs)): t("society.chat.thought");+return (- <details className="group text-xs text-muted-foreground">- <summary className="cursor-pointer select-none list-none px-1 hover:text-foreground">- <span className={cn(block.live && "animate-pulse")}>{label}</span>- </summary>- {block.text.trim() ? (- <div className="mt-1 whitespace-pre-wrap rounded-xl border border-border px-3 py-2 text-xs leading-relaxed">- {block.text}+ <div+ className="my-0.5 flex flex-col items-center gap-1.5"+ data-testid="society-reasoning"+ data-state={live ? "live" : text === "" ? "silent" : open ? "open" : "folded"}+ >+ {live ? (+ <div className="flex items-center gap-2 text-xs" role="status" aria-live="polite">+ <LiveCore />+ <span className="thinking-shimmer font-medium tabular-nums">{label}</span></div>) : (- <p className="px-3 py-1 text-xs italic">{t("society.chat.thought_hidden")}</p>+ <button+ type="button"+ onClick={() => setManual(!open)}+ aria-expanded={open}+ disabled={text === ""}+ title={text === "" ? t("society.chat.thought_hidden") : undefined}+ className={cn(+ "inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-secondary/40 px-2.5 py-1",+ "text-xs text-muted-foreground transition-colors",+ text === "" ? "cursor-default" : "hover:border-border hover:bg-secondary hover:text-foreground",+ )}+ >+ <Brain className="h-3.5 w-3.5 shrink-0 opacity-70" aria-hidden />+ <span className="tabular-nums">{label}</span>+ {text === "" ? null : (+ <ChevronRight className={cn("h-3.5 w-3.5 shrink-0 transition-transform", open && "rotate-90")} aria-hidden />+ )}+ </button>)}- </details>++ {open ? (+ <div className="w-full rounded-2xl border border-border/60 bg-secondary/25 px-4 py-3">+ {live ? <ThoughtTail text={text} /> : <Prose text={text} muted />}+ </div>+ ) : null}+ </div>+ );+}++/**+ * The streaming thought, pinned to its newest lines.+ *+ * A fixed window with the text against its bottom edge: new words push the+ * old ones up and out. Once more has been written than fits, the top fades+ * so the clipping reads as depth rather than as a cut; a thought that fits+ * shows whole and unfaded.+ */+function ThoughtTail({ text }: { text: string }) {+ const outer = useRef<HTMLDivElement>(null);+ const inner = useRef<HTMLDivElement>(null);+ const [clipped, setClipped] = useState(false);+ useLayoutEffect(() => {+ const box = outer.current;+ const body = inner.current;+ if (!box || !body) return;+ setClipped(body.offsetHeight > box.clientHeight + 1);+ }, [text]);+ return (+ <div+ ref={outer}+ className={cn(+ "flex max-h-40 flex-col justify-end overflow-hidden",+ clipped && "[mask-image:linear-gradient(to_bottom,transparent,black_2.5rem)]",+ )}+ data-testid="society-reasoning-tail"+ data-clipped={clipped ? "true" : undefined}+ >+ <div ref={inner}>+ {text ? <Prose text={text} muted /> : null}+ </div>+ </div>);}diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ReasoningTrace.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ReasoningTrace.test.tsxnew file mode 100644index 0000000000..8b513988b1--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/chat/ReasoningTrace.test.tsx@@ -0,0 +1,86 @@+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it } from "vitest";++import { ReasoningTrace } from "@/components/society/chat/AgentChatPanel";+import type { ReasoningBlock } from "@/components/agentchat/reduce";++/**+ * The agent card's reasoning trace — what the maintainer asked for on+ * 2026-09-02: the bare `<details>` summary over a wall of pre-wrapped text+ * was replaced by the Claude/ChatGPT shape — a centred live line, a centred+ * "Thought for 8s" pill, and the thought itself as prose.+ *+ * The rules this file holds: the trace is CENTRED, it renders Markdown as+ * prose rather than as marks, it stays open while the turn still works and+ * folds when the turn lands, and a redacted thought still says it happened+ * without pretending there is something to open.+ */++function block(over: Partial<ReasoningBlock> = {}): ReasoningBlock {+ return {+ kind: "reasoning",+ id: "r1",+ text: "**Plan:** add the minutes first, then the two stops.",+ durationMs: 8_000,+ live: false,+ startedMs: 1_000,+ ...over,+ };+}++afterEach(cleanup);++describe("society reasoning trace", () => {+ it("centres itself instead of hanging off the bubble's edge", () => {+ render(<ReasoningTrace block={block()} turnLive={false} />);+ expect(screen.getByTestId("society-reasoning").className).toContain("items-center");+ });++ it("shows the live core and a running clock while the thought streams", () => {+ // `startedMs` is a wall clock, so a live block has to start about now.+ render(<ReasoningTrace block={block({ live: true, durationMs: null, startedMs: Date.now() })} turnLive />);+ const trace = screen.getByTestId("society-reasoning");+ expect(trace.dataset.state).toBe("live");+ expect(screen.getByTestId("live-core")).toBeTruthy();+ expect(screen.getByRole("status").textContent).toMatch(/Thinking for \d+s/);+ // A live thought is open, and anchored to its newest lines.+ expect(screen.getByTestId("society-reasoning-tail")).toBeTruthy();+ });++ it("reads the thought as prose, not as Markdown marks", () => {+ render(<ReasoningTrace block={block()} turnLive />);+ expect(screen.getByText("Plan:").tagName).toBe("STRONG");+ expect(screen.queryByText(/\*\*Plan/)).toBeNull();+ });++ it("stays open while the turn still works and folds once it lands", () => {+ const { rerender } = render(<ReasoningTrace block={block()} turnLive />);+ expect(screen.getByTestId("society-reasoning").dataset.state).toBe("open");+ rerender(<ReasoningTrace block={block()} turnLive={false} />);+ expect(screen.getByTestId("society-reasoning").dataset.state).toBe("folded");+ });++ it("names the duration on the folded pill and opens on a click", () => {+ render(<ReasoningTrace block={block()} turnLive={false} />);+ const pill = screen.getByRole("button", { name: /Thought for 8s/ });+ expect(pill.getAttribute("aria-expanded")).toBe("false");+ fireEvent.click(pill);+ expect(screen.getByTestId("society-reasoning").dataset.state).toBe("open");+ expect(screen.getByRole("button").getAttribute("aria-expanded")).toBe("true");+ });++ it("says a redacted thought happened without offering a fold", () => {+ render(<ReasoningTrace block={block({ text: "" })} turnLive={false} />);+ const trace = screen.getByTestId("society-reasoning");+ expect(trace.dataset.state).toBe("silent");+ const pill = screen.getByRole("button", { name: /Thought for 8s/ });+ expect((pill as HTMLButtonElement).disabled).toBe(true);+ fireEvent.click(pill);+ expect(screen.getByTestId("society-reasoning").dataset.state).toBe("silent");+ });++ it("falls back to a bare label when the vendor sent no duration", () => {+ render(<ReasoningTrace block={block({ durationMs: null, text: "" })} turnLive={false} />);+ expect(screen.getByRole("button").textContent).toBe("Thought");+ });+});