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): redesign reasoning traces as a threaded rail

rubenluetke10-beep6174b2d4074b
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx b/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
index c736f1534e..0b1f10ed0a 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
@@ -5,7 +5,7 @@ import { InternalMessageBubble, type InternalParticipant } from "./InternalMessa
import { MessageWithChips } from "./ToolChoiceChips";
import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { effortLabel } from "./AgentComposer";
-import { TurnTrace, type Decide } from "./WorkTrace";
+import { TurnTrace, type Decide, type TraceLook } from "./WorkTrace";
import type { TimelineItem, TurnItem, TextBlock } from "./reduce";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -19,6 +19,7 @@ export function AgentTimeline({
recipientName,
agentsById,
bubbles = false,
+ traceLook = "rail",
}: {
items: TimelineItem[];
assistantName: string;
@@ -36,6 +37,8 @@ export function AgentTimeline({
* keeps the labelled document look (the default).
*/
bubbles?: boolean;
+ /** How turns draw their work; the Agentic IDE keeps the classic rows. */
+ traceLook?: TraceLook;
}) {
const t = useT();
const stamps = bubbles ? timeStamps(items) : null;
@@ -192,6 +195,7 @@ export function AgentTimeline({
providerLabel={providerLabel(item.provider)}
onDecide={onDecide}
bubbles={bubbles}
+ traceLook={traceLook}
/>
);
}
@@ -232,8 +236,8 @@ function stampLabel(at: Date, now: Date): string {
return `${date}, ${time}`;
}
-const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide, bubbles = false }: {
- turn: TurnItem; assistantName: string; providerLabel: string; onDecide: Decide; bubbles?: boolean;
+const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide, bubbles = false, traceLook }: {
+ turn: TurnItem; assistantName: string; providerLabel: string; onDecide: Decide; bubbles?: boolean; traceLook: TraceLook;
}) {
const t = useT();
return <div className="flex min-w-0 flex-col gap-3" data-testid="agent-turn" data-message-id={turn.id} data-status={turn.status}>
@@ -245,7 +249,7 @@ const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide,
{turn.effort ? <span>{effortLabel(turn.effort, t)}</span> : null}
</div>
)}
- <TurnTrace turn={turn} onDecide={onDecide} renderText={(text, id) => <Prose block={{ kind: "text", text, id }} />} />
+ <TurnTrace turn={turn} look={traceLook} onDecide={onDecide} renderText={(text, id) => <Prose block={{ kind: "text", text, id }} />} />
</div>;
});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.css b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.css
index 010c065ad3..417d0d3b0f 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.css
+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.css
@@ -14,3 +14,117 @@
margin-right: 0;
width: 100%;
}
+
+/* ── The rail look (2026-10-01) ─────────────────────────────────────────
+ Every step of a turn hangs on one hairline thread. A step's node sits in
+ a 16 px column centred on its first line: rows are 4 px + a 24 px line, so
+ the node's centre is 16 px down. The thread runs in two segments per step
+ — above the node and from below the node to the step's end — so it leaves
+ a small gap around every node and passes behind opened details without a
+ frame of its own. Only colour tokens; both themes read the same ladder. */
+.trace-rail {
+ display: flex;
+ min-width: 0;
+ flex-direction: column;
+}
+.trace-rail > .trace-step {
+ position: relative;
+ min-width: 0;
+}
+.trace-rail > .trace-step::before,
+.trace-rail > .trace-step::after {
+ content: "";
+ position: absolute;
+ left: 7.5px;
+ width: 1px;
+ background: hsl(var(--border-strong));
+ pointer-events: none;
+}
+.trace-rail > .trace-step::before {
+ top: 0;
+ height: 6px;
+}
+.trace-rail > .trace-step::after {
+ top: 26px;
+ bottom: 0;
+}
+.trace-rail > .trace-step:first-child::before,
+.trace-rail > .trace-step:last-child::after {
+ display: none;
+}
+
+.trace-node {
+ display: flex;
+ height: 1.5rem;
+ width: 1rem;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+ color: hsl(var(--muted-foreground));
+}
+.trace-node-live {
+ color: hsl(var(--accent));
+}
+.trace-dot {
+ display: block;
+ height: 5px;
+ width: 5px;
+ border-radius: 9999px;
+ background: currentColor;
+ opacity: 0.6;
+}
+.trace-node-live .trace-dot {
+ opacity: 1;
+ box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.18);
+ animation: trace-node-pulse 1.6s ease-in-out infinite;
+}
+
+/* The words of the step that is working: a slow light sweep over muted ink,
+ the way the Claude app marks "Thinking". */
+.trace-shimmer {
+ background-image: linear-gradient(
+ 90deg,
+ hsl(var(--muted-foreground)) 0%,
+ hsl(var(--muted-foreground)) 38%,
+ hsl(var(--foreground-strong)) 50%,
+ hsl(var(--muted-foreground)) 62%,
+ hsl(var(--muted-foreground)) 100%
+ );
+ background-size: 250% 100%;
+ -webkit-background-clip: text;
+ background-clip: text;
+ color: transparent;
+ animation: trace-shimmer 2.4s linear infinite;
+}
+
+/* A live scratchpad that has outgrown its box fades in from the top: the
+ newest line stays pinned at the bottom, older lines dissolve upward. */
+.trace-scratch-live {
+ -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 2.5rem);
+ mask-image: linear-gradient(to bottom, transparent 0, black 2.5rem);
+}
+
+/* The opened conversation fold lines its thread up under the pill's mark. */
+.trace-fold-open {
+ padding-left: 5px;
+}
+
+@keyframes trace-shimmer {
+ from { background-position: 100% 0; }
+ to { background-position: -150% 0; }
+}
+@keyframes trace-node-pulse {
+ 0%, 100% { box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / 0.12); }
+ 50% { box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 0.24); }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .trace-shimmer {
+ animation: none;
+ background-image: none;
+ color: hsl(var(--foreground));
+ }
+ .trace-node-live .trace-dot {
+ animation: none;
+ }
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
index eca4fc4b5b..44453d5b14 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
@@ -183,3 +183,50 @@ describe("work trace", () => {
expect(splitConversationTurn([tool("a")])).toEqual({ work: [tool("a")], answer: [], after: [] });
});
});
+
+describe("rail look", () => {
+ it("threads thoughts, tools and the state line on one rail by default", () => {
+ const { container } = render(<WorkTrace {...props} blocks={[thought, tool("a", { name: "exec_command" })]} />);
+ expect(screen.getByTestId("work-trace").getAttribute("data-look")).toBe("rail");
+ const rails = container.querySelectorAll(".trace-rail");
+ expect(rails).toHaveLength(1);
+ const steps = rails[0].querySelectorAll(":scope > .trace-step");
+ expect(steps).toHaveLength(3);
+ expect(steps[2].querySelector("[role='status']")?.textContent).toContain("Done");
+ });
+
+ it("breaks the rail around a reply so narration stands on its own", () => {
+ const { container } = render(<WorkTrace {...props} blocks={[tool("a", { name: "exec_command" }), reply("mid", "Halfway there."), tool("b", { name: "exec_command" })]} />);
+ const rails = container.querySelectorAll(".trace-rail");
+ expect(rails).toHaveLength(2);
+ expect(rails[0].textContent).not.toContain("Halfway there.");
+ });
+
+ it("marks the working step and the live state line with the shimmer", () => {
+ const { container } = render(<WorkTrace {...props} status="running" durationMs={null} blocks={[tool("a", { name: "exec_command", output: null })]} />);
+ const running = container.querySelector('[data-state="running"]')!;
+ expect(running.querySelector(".trace-shimmer")?.textContent).toBe("Run command");
+ expect(running.querySelector(".trace-node-live")).toBeTruthy();
+ expect(screen.getByRole("status").querySelector(".trace-shimmer")?.textContent).toBe("Working");
+ });
+
+ it("drops the shimmer once the turn is finished", () => {
+ const { container } = render(<WorkTrace {...props} blocks={[tool("a", { name: "exec_command" })]} />);
+ expect(container.querySelector(".trace-shimmer")).toBeNull();
+ expect(container.querySelector(".trace-node-live")).toBeNull();
+ });
+
+ it("keeps the classic rows for the Agentic IDE", () => {
+ const { container } = render(<WorkTrace {...props} look="classic" blocks={[thought, tool("a")]} />);
+ expect(screen.getByTestId("work-trace").hasAttribute("data-look")).toBe(false);
+ expect(container.querySelector(".trace-rail")).toBeNull();
+ expect(screen.getByRole("status").className).toMatch(/border-t/);
+ });
+
+ it("shows the services a folded conversation turn used on its toggle", () => {
+ const blocks = [tool("linear", { name: "mcp__codex_apps__linear_list_issues" }), reply("done", "Three issues are open.")];
+ render(<WorkTrace {...props} conversation blocks={blocks} />);
+ const toggle = screen.getByRole("button", { name: "Thought for 12s" });
+ expect(toggle.querySelector("img, [data-logo]")).toBeTruthy();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
index 991c3772c2..bd89ca48fa 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
@@ -1,4 +1,4 @@
-import { createContext, memo, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
+import { createContext, Fragment, memo, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { Brain, Check, ChevronRight, CircleAlert, CircleDashed, FilePenLine, FileText, FolderSearch, MessageCircleQuestion, ShieldQuestion, Terminal } from "lucide-react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
@@ -12,12 +12,26 @@ import { toolDiff } from "./toolDiff";
import { formatTokens, outputTokens } from "./toolView";
import { activityParts, traceToolIdentity, traceToolName } from "./traceActivity";
import { ToolChoiceIcon } from "./ToolChoiceChips";
+import type { ToolChoice } from "./toolChoices";
import { toolIdentityStyle } from "./toolIdentity";
import "./WorkTrace.css";
export type Decide = (id: string, decision: ApprovalDecision) => void | Promise<void>;
type Group = { id: string; blocks: TurnBlock[]; family: string | null };
+/**
+ * How a trace is drawn.
+ *
+ * "rail" (the default since 2026-10-01) threads every step of a turn on one
+ * quiet vertical line: each thought or tool call is a node on it, the live
+ * step shimmers, and the turn's state line closes the thread. "classic" is
+ * the earlier row list, kept only for the Agentic IDE, whose coding panes
+ * mirror Claude Code and Codex and were left as they are on purpose.
+ */
+export type TraceLook = "rail" | "classic";
+const TraceLookContext = createContext<TraceLook>("rail");
+const useRail = () => useContext(TraceLookContext) === "rail";
+
export function traceDuration(ms: number): string {
// Keep short, measured calls visible instead of rounding 49 ms to "0.0s".
if (ms > 0 && ms < 100) return `${Math.ceil(ms)}ms`;
@@ -146,7 +160,49 @@ function pretty(value: unknown): string {
}
const rowButton = "group/trace flex w-full min-w-0 items-start gap-2.5 rounded-md py-2 text-left text-[13px] leading-6 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground";
+const railRowButton = "group/trace flex w-full min-w-0 items-start gap-3 rounded-md py-1 text-left text-sm leading-6 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground disabled:cursor-default";
const iconClass = "mt-0.5 h-4 w-4 shrink-0";
+/** A glyph sitting in a rail node: the node box centres it on the first line. */
+const nodeIcon = "h-3.5 w-3.5 shrink-0";
+
+/**
+ * One item of a rail. Steps on the thread (thoughts, tool calls, the live
+ * state line) set `rail`; replies and question cards break the thread, so
+ * the work around them reads as separate stretches.
+ */
+type RailItem = { key: string; node: ReactNode; rail: boolean };
+
+/** Draw consecutive rail items as one thread; everything else stands alone. */
+function Rail({ items }: { items: RailItem[] }) {
+ const out: ReactNode[] = [];
+ let run: RailItem[] = [];
+ const flush = () => {
+ if (!run.length) return;
+ out.push(<div key={`rail:${run[0].key}`} className="trace-rail">
+ {run.map((item) => <div key={item.key} className="trace-step">{item.node}</div>)}
+ </div>);
+ run = [];
+ };
+ for (const item of items) {
+ if (item.rail) run.push(item);
+ else {
+ flush();
+ out.push(<Fragment key={item.key}>{item.node}</Fragment>);
+ }
+ }
+ flush();
+ return <>{out}</>;
+}
+
+/** The node a step hangs on: a 16 px column centred on the row's first line. */
+function Node({ children, live = false }: { children: ReactNode; live?: boolean }) {
+ return <span aria-hidden className={cn("trace-node", live && "trace-node-live")}>{children}</span>;
+}
+
+/** The words of whatever is happening right now, with a slow light sweep. */
+function Live({ on, children }: { on: boolean; children: ReactNode }) {
+ return on ? <span className="trace-shimmer">{children}</span> : <>{children}</>;
+}
/**
* While a conversation work fold is open, every disclosure inside it starts
@@ -157,16 +213,33 @@ const iconClass = "mt-0.5 h-4 w-4 shrink-0";
*/
const FoldExpandContext = createContext(0);
-function Disclosure({ label, children, forced = false, initiallyOpen = false, icon, trailing, tone, summary, resetKey = "" }: {
+function Disclosure({ label, children, forced = false, initiallyOpen = false, icon, trailing, tone, summary, resetKey = "", live = false }: {
label: ReactNode; children?: ReactNode; forced?: boolean; initiallyOpen?: boolean;
icon: ReactNode; trailing?: ReactNode; tone?: string; summary?: ReactNode; resetKey?: string;
+ /** Rail look only: the node glows while this step is the one working. */
+ live?: boolean;
}) {
const id = useId();
+ const rail = useRail();
const foldSeq = useContext(FoldExpandContext);
// A manual choice during a live turn must not prevent completion folding.
const phase = `${initiallyOpen}:${resetKey}:${foldSeq}`;
const [choice, setChoice] = useState<{ phase: string; open: boolean } | null>(null);
const open = forced || (choice?.phase === phase ? choice.open : foldSeq > 0 || initiallyOpen);
+ if (rail) return (
+ <div className={cn("min-w-0 text-muted-foreground", tone)}>
+ <button type="button" className={railRowButton} aria-expanded={children ? open : undefined}
+ aria-controls={children ? id : undefined} disabled={!children || forced}
+ onClick={() => setChoice({ phase, open: !open })}>
+ <Node live={live}>{icon}</Node>
+ <span className="min-w-0 flex-1 [overflow-wrap:anywhere]">{label}</span>
+ {trailing ? <span className="shrink-0 text-xs tabular-nums text-muted-foreground">{trailing}</span> : null}
+ {children && !forced ? <ChevronRight aria-hidden className={cn("mt-[5px] h-3.5 w-3.5 shrink-0 opacity-40 transition group-hover/trace:opacity-90", open && "rotate-90")} /> : null}
+ </button>
+ {summary}
+ {children && open ? <div id={id} className="min-w-0 pb-1.5 pl-7">{children}</div> : null}
+ </div>
+ );
return (
<div className={cn("min-w-0 text-muted-foreground", tone)}>
<button type="button" className={rowButton} aria-expanded={children ? open : undefined}
@@ -185,16 +258,23 @@ function Disclosure({ label, children, forced = false, initiallyOpen = false, ic
function ReasoningBody({ text, live }: { text: string; live: boolean }) {
const ref = useRef<HTMLDivElement>(null);
+ const rail = useRail();
+ // The fade at the top only means "there is more above" — a thought that
+ // still fits its box keeps its first line crisp.
+ const [clipped, setClipped] = useState(false);
useLayoutEffect(() => {
const el = ref.current;
if (!el || !live) return;
el.scrollTop = el.scrollHeight;
- }, [text, live]);
+ if (rail) setClipped(el.scrollHeight > el.clientHeight + 1);
+ }, [text, live, rail]);
return (
<div
ref={ref}
data-testid="reasoning-body"
- className="prose prose-sm max-h-64 max-w-none overflow-auto text-xs leading-6 text-muted-foreground dark:prose-invert [overflow-wrap:anywhere] prose-p:my-1 prose-pre:overflow-auto"
+ className={rail
+ ? cn("prose prose-sm max-h-60 max-w-none overflow-auto pb-1 text-sm leading-6 text-foreground-secondary dark:prose-invert [overflow-wrap:anywhere] prose-p:my-1 prose-p:text-foreground-secondary prose-li:text-foreground-secondary prose-strong:text-foreground prose-pre:overflow-auto", live && clipped && "trace-scratch-live")
+ : "prose prose-sm max-h-64 max-w-none overflow-auto text-xs leading-6 text-muted-foreground dark:prose-invert [overflow-wrap:anywhere] prose-p:my-1 prose-pre:overflow-auto"}
>
<ReactMarkdown remarkPlugins={[remarkGfm]}>{text}</ReactMarkdown>
</div>
@@ -203,6 +283,7 @@ function ReasoningBody({ text, live }: { text: string; live: boolean }) {
export function ReasoningTrace({ block, turnLive, compact = false }: { block: ReasoningBlock; turnLive: boolean; compact?: boolean }) {
const t = useT();
+ const rail = useRail();
const live = turnLive && block.live;
const elapsed = useClock(block.startedMs, live);
const text = block.text.trim();
@@ -210,24 +291,32 @@ export function ReasoningTrace({ block, turnLive, compact = false }: { block: Re
const label = duration === null ? t("work_trace.thought")
: t(live ? "work_trace.thinking_for" : "work_trace.thought_for").replace("{duration}", traceDuration(duration));
const gist = text.replace(/```[\s\S]*?```/g, " ").replace(/[`*_#>~]/g, "").replace(/\s+/g, " ").trim();
+ const showGist = !compact && !turnLive && gist;
+ if (rail) return <Disclosure label={<Live on={live}>{label}</Live>} icon={<span className="trace-dot" />}
+ live={live} forced={live} initiallyOpen={compact ? live : turnLive}
+ resetKey={compact ? String(turnLive) : ""}
+ summary={showGist ? <p className="mb-1.5 pl-7 line-clamp-2 text-sm leading-6 text-foreground-secondary">{gist.slice(0, 280)}</p> : undefined}>
+ {text ? <ReasoningBody text={text} live={live} /> : undefined}
+ </Disclosure>;
return <Disclosure label={label} icon={<Brain aria-hidden className={cn(iconClass, live && "motion-safe:animate-pulse")} />}
forced={live} initiallyOpen={compact ? live : turnLive}
resetKey={compact ? String(turnLive) : ""}
- summary={!compact && !turnLive && gist ? <p className="mb-2 ml-6 line-clamp-2 text-xs leading-5">{gist.slice(0, 240)}</p> : undefined}>
+ summary={showGist ? <p className="mb-2 ml-6 line-clamp-2 text-xs leading-5">{gist.slice(0, 240)}</p> : undefined}>
{text ? <ReasoningBody text={text} live={live} /> : undefined}
</Disclosure>;
}
function ToolDetails({ block }: { block: ToolBlock }) {
const t = useT();
+ const rail = useRail();
const diff = useMemo(() => toolDiff(block.name, block.input, block.output), [block.name, block.input, block.output]);
const memoryFile = useMemo(() => memoryFileFromBlock(block), [block]);
const [memoryOpen, setMemoryOpen] = useState(false);
- return <div className="space-y-3 py-1 text-xs">
+ return <div className={cn("text-xs", rail ? "space-y-2.5 pb-1 pt-0.5" : "space-y-3 py-1")}>
<Detail label={t("work_trace.tool")} text={block.name} />
{block.input !== undefined && block.input !== null ? <Detail label={t("work_trace.input")} text={pretty(block.input)} /> : null}
- {diff ? <div aria-label={t("work_trace.diff")} className="max-h-72 overflow-auto font-mono text-xs">
- {diff.map((file, i) => <div key={i} className="mb-2">
+ {diff ? <div aria-label={t("work_trace.diff")} className={cn("max-h-72 overflow-auto font-mono text-xs", rail && "rounded-md bg-muted/60 px-3 py-2")}>
+ {diff.map((file, i) => <div key={i} className="mb-2 last:mb-0">
<div className="mb-1 flex items-center gap-2 [overflow-wrap:anywhere]">
<p className="min-w-0 flex-1">{file.path}</p>
{memoryFile && file.path === memoryFile.path ? <button
@@ -292,6 +381,10 @@ function MemoryFileDialog({ path, before, after, onClose }: { path: string; befo
}
function Detail({ label, text }: { label: string; text: string }) {
+ const rail = useRail();
+ if (rail) return <div><p className="mb-1 text-xs font-medium text-muted-foreground">{label}</p>
+ <pre tabIndex={0} className="max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted/60 px-3 py-2 font-mono text-xs leading-5 text-foreground-secondary [overflow-wrap:anywhere] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">{text}</pre>
+ </div>;
return <div><p className="mb-1 font-medium text-foreground">{label}</p>
<pre tabIndex={0} className="max-h-64 overflow-auto whitespace-pre-wrap font-mono text-xs leading-5 [overflow-wrap:anywhere] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">{text}</pre>
</div>;
@@ -304,6 +397,7 @@ export const TraceTool = memo(function TraceTool({ block, status, onDecide }: {
function TraceToolRow({ block, status, onDecide }: { block: ToolBlock; status: TurnStatus; onDecide?: Decide }) {
const t = useT();
+ const rail = useRail();
const pending = Boolean(block.approval && block.approval.decision === null);
const denied = block.approval?.decision === "deny";
const running = status === "running" && block.output === null && !pending && !denied;
@@ -330,9 +424,41 @@ function TraceToolRow({ block, status, onDecide }: { block: ToolBlock; status: T
catch (err) { setError(err instanceof Error ? err.message : String(err)); }
finally { submitting.current = false; setBusy(false); }
};
+ const branded = view.identity.logo && !pending && !block.isError;
+ const approvalUi = pending ? <div className={cn("space-y-2 text-sm", rail ? "mb-2 pl-7" : "mb-3 ml-6")} role="group" aria-label={t("work_trace.approval")}>
+ <p className={cn("[overflow-wrap:anywhere]", rail && "text-foreground")}>{block.approval?.summary}</p>
+ {onDecide ? <div className="flex flex-wrap gap-2">
+ {(["allow", "allow_always", "deny"] as const).map(decision => <button key={decision} type="button" disabled={busy}
+ onClick={() => void decide(decision)} className={cn("rounded-md px-3 py-1.5 text-xs focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
+ rail && decision === "allow" ? "bg-primary text-primary-foreground hover:opacity-90" : "border border-border text-foreground hover:bg-secondary")}>
+ {t(`work_trace.${decision}`)}
+ </button>)}
+ </div> : <p className="text-xs text-muted-foreground">{t("work_trace.approval_elsewhere")}</p>}
+ {error ? <p role="alert" className="text-xs text-destructive">{error}</p> : null}
+ </div> : null;
+ if (rail) return <div data-trace-tool={block.callId} data-state={state}>
+ <Disclosure
+ label={<span className="flex min-w-0 items-baseline gap-2">
+ <span className={cn("shrink-0", block.isError ? "text-destructive" : pending ? "text-foreground" : "text-foreground-secondary", view.integration && "font-medium")}><Live on={running}>{label}</Live></span>
+ {detail ? <span className="min-w-0 truncate font-mono text-xs text-muted-foreground">{" "}{detail}</span> : null}
+ </span>}
+ icon={branded
+ ? <span className="tool-identity inline-flex" style={toolIdentityStyle(view.row)} data-trace-brand={view.identity.key}><ToolChoiceIcon row={view.row} size={14} /></span>
+ : <Icon className={nodeIcon} />}
+ live={running}
+ trailing={running ? traceDuration(elapsed) : block.durationMs !== null ? traceDuration(block.durationMs) : null}
+ tone={block.isError ? "text-destructive" : pending ? "text-foreground" : undefined}
+ summary={<>
+ {state !== "completed" && state !== "running" && state !== "approval" ? <p className={cn("mb-1 pl-7 text-xs", block.isError && "text-destructive")}>{t(`work_trace.${state}`)}</p> : null}
+ {block.isError && block.output ? <p className="mb-1.5 pl-7 line-clamp-4 whitespace-pre-wrap font-mono text-xs leading-5 text-destructive [overflow-wrap:anywhere]">{block.output.slice(0, 500)}</p> : null}
+ </>}>
+ <ToolDetails block={block} />
+ </Disclosure>
+ {approvalUi}
+ </div>;
return <div data-trace-tool={block.callId} data-state={state}>
<Disclosure label={<><span className={view.integration ? "font-medium" : undefined}>{label}</span>{detail ? <span className="ml-2 text-xs text-muted-foreground">{" "}{detail}</span> : null}</>}
- icon={view.identity.logo && !pending && !block.isError ? <span className={cn("tool-identity mt-1 shrink-0", running && "motion-safe:animate-pulse")} style={toolIdentityStyle(view.row)} data-trace-brand={view.identity.key}><ToolChoiceIcon row={view.row} size={16} /></span> : <Icon aria-hidden className={cn(iconClass, "mt-1", running && "motion-safe:animate-pulse")} />}
+ icon={branded ? <span className={cn("tool-identity mt-1 shrink-0", running && "motion-safe:animate-pulse")} style={toolIdentityStyle(view.row)} data-trace-brand={view.identity.key}><ToolChoiceIcon row={view.row} size={16} /></span> : <Icon aria-hidden className={cn(iconClass, "mt-1", running && "motion-safe:animate-pulse")} />}
trailing={<span className="inline-flex items-center gap-1.5">{running ? <CircleDashed aria-hidden className="h-3 w-3 motion-safe:animate-spin" /> : null}{running ? traceDuration(elapsed) : block.durationMs !== null ? traceDuration(block.durationMs) : null}</span>}
tone={block.isError ? "text-destructive" : pending ? "text-foreground" : undefined}
summary={<>
@@ -341,93 +467,139 @@ function TraceToolRow({ block, status, onDecide }: { block: ToolBlock; status: T
</>}>
<ToolDetails block={block} />
</Disclosure>
- {pending ? <div className="mb-3 ml-6 space-y-2 text-sm" role="group" aria-label={t("work_trace.approval")}>
- <p className="[overflow-wrap:anywhere]">{block.approval?.summary}</p>
- {onDecide ? <div className="flex flex-wrap gap-2">
- {(["allow", "allow_always", "deny"] as const).map(decision => <button key={decision} type="button" disabled={busy}
- onClick={() => void decide(decision)} className="rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-secondary focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50">
- {t(`work_trace.${decision}`)}
- </button>)}
- </div> : <p className="text-xs text-muted-foreground">{t("work_trace.approval_elsewhere")}</p>}
- {error ? <p role="alert" className="text-xs text-destructive">{error}</p> : null}
- </div> : null}
+ {approvalUi}
</div>;
}
function ActivitySummary({ blocks, live }: { blocks: TurnBlock[]; live: boolean }) {
const t = useT();
+ const rail = useRail();
const parts = activityParts(blocks.filter((block): block is ToolBlock => block.kind === "tool"));
- if (!parts.length) return <>{t("work_trace.thought")}</>;
- return <span className="inline-flex flex-wrap items-center gap-x-1.5 gap-y-1">
+ if (!parts.length) return <Live on={rail && live}>{t("work_trace.thought")}</Live>;
+ return <span className={cn("inline-flex flex-wrap items-center gap-x-1.5 gap-y-1", rail && "text-foreground-secondary")}>
{parts.map((part, index) => <span key={`${part.key}:${part.service ?? ""}`} className="inline-flex items-center gap-1.5">
{index > 0 ? <span aria-hidden className="text-muted-foreground/50">·</span> : null}
{part.row && index > 0 ? <span className="tool-identity inline-flex" style={toolIdentityStyle(part.row)}><ToolChoiceIcon row={part.row} size={14} /></span> : null}
- <span>{t(`work_trace.${live ? "live_" : ""}${part.key}`).replace("{service}", part.service ?? "")}</span>
+ <Live on={rail && live}>{t(`work_trace.${live ? "live_" : ""}${part.key}`).replace("{service}", part.service ?? "")}</Live>
</span>)}
</span>;
}
function ActivityIcon({ blocks, live }: { blocks: TurnBlock[]; live: boolean }) {
+ const rail = useRail();
const first = activityParts(blocks.filter((block): block is ToolBlock => block.kind === "tool"))[0];
- if (first?.row) return <span className={cn("tool-identity mt-1 shrink-0", live && "motion-safe:animate-pulse")} style={toolIdentityStyle(first.row)}><ToolChoiceIcon row={first.row} size={16} /></span>;
- const Icon = live ? CircleDashed : first?.key === "activity_command" ? Terminal
+ if (first?.row) return <span className={cn("tool-identity shrink-0", rail ? "inline-flex" : "mt-1", !rail && live && "motion-safe:animate-pulse")} style={toolIdentityStyle(first.row)}><ToolChoiceIcon row={first.row} size={rail ? 14 : 16} /></span>;
+ if (rail && !first) return <span className="trace-dot" />;
+ const Icon = live && !rail ? CircleDashed : first?.key === "activity_command" ? Terminal
: first?.key === "activity_edit" || first?.key === "activity_write" || first?.key === "activity_memory" ? FilePenLine : first ? FileText : Brain;
- return <Icon aria-hidden className={cn(iconClass, "mt-1", live && "motion-safe:animate-spin")} />;
+ return <Icon aria-hidden className={rail ? nodeIcon : cn(iconClass, "mt-1", live && "motion-safe:animate-spin")} />;
+}
+
+/** Up to three brand marks of the services a stretch of work touched. */
+function traceLogos(blocks: TurnBlock[]): ToolChoice[] {
+ const rows: ToolChoice[] = [];
+ const seen = new Set<string>();
+ for (const block of blocks) {
+ if (block.kind !== "tool") continue;
+ const view = traceToolIdentity(block);
+ const key = view.identity.key || view.service || block.name;
+ if (!view.identity.logo || seen.has(key)) continue;
+ seen.add(key);
+ rows.push(view.row);
+ if (rows.length === 3) break;
+ }
+ return rows;
}
/** Small chevron that hides finished work so the reply can stand alone. */
-function ConversationWorkFold({ durationMs, attention, children }: {
- durationMs: number | null; attention?: ReactNode; children: ReactNode;
+function ConversationWorkFold({ durationMs, attention, blocks, children }: {
+ durationMs: number | null; attention?: ReactNode; blocks: TurnBlock[]; children: ReactNode;
}) {
const t = useT();
+ const rail = useRail();
const id = useId();
const [open, setOpen] = useState(false);
// Counts openings so inner disclosures expand all at once, every time.
const [seq, setSeq] = useState(0);
+ const logos = useMemo(() => rail ? traceLogos(blocks) : [], [rail, blocks]);
const label = durationMs !== null && durationMs > 0
? t("work_trace.thought_for").replace("{duration}", traceDuration(durationMs))
: t("work_trace.thought");
+ const toggle = () => {
+ if (!open) setSeq((s) => s + 1);
+ setOpen(!open);
+ };
return (
<div className="min-w-0" data-testid="conversation-work-fold" data-open={open ? "true" : "false"}>
- <button type="button" aria-expanded={open} aria-controls={id}
+ {rail ? <button type="button" aria-expanded={open} aria-controls={id} onClick={toggle}
+ className="group/fold mb-1.5 inline-flex max-w-full items-center gap-2 rounded-full border border-border py-1 pl-2.5 pr-2 text-left text-xs leading-5 text-muted-foreground transition-colors hover:border-border-strong hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ {logos.length ? <span aria-hidden className="flex shrink-0 items-center">
+ {logos.map((row, i) => <span key={i} className={cn("tool-identity inline-flex rounded-full bg-background ring-2 ring-background", i > 0 && "-ml-1")} style={toolIdentityStyle(row)}><ToolChoiceIcon row={row} size={14} /></span>)}
+ </span> : <span aria-hidden className="trace-dot shrink-0" />}
+ <span className="truncate">{label}</span>
+ <ChevronRight aria-hidden className={cn("h-3 w-3 shrink-0 opacity-60 transition-transform group-hover/fold:opacity-100", open && "rotate-90")} />
+ </button> : <button type="button" aria-expanded={open} aria-controls={id}
className="group/fold mb-1 inline-flex max-w-full items-center gap-1 rounded-md px-1.5 py-1 text-left text-xs leading-5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- onClick={() => {
- if (!open) setSeq((s) => s + 1);
- setOpen(!open);
- }}>
+ onClick={toggle}>
<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}
+ </button>}
+ {open ? <div id={id} className={rail ? "trace-fold-open pb-1" : undefined}><FoldExpandContext.Provider value={seq}>{children}</FoldExpandContext.Provider></div> : attention}
</div>
);
}
-function TraceGroups({ groups, live, status, onDecide, renderText, conversation }: {
+function traceGroupItems({ groups, live, status, onDecide, renderText, conversation, rail, t }: {
groups: Group[]; live: boolean; status: TurnStatus; onDecide?: Decide;
- renderText?: (text: string, id: string) => ReactNode; conversation: boolean;
-}) {
- const t = useT();
- return groups.map(group => {
+ renderText?: (text: string, id: string) => ReactNode; conversation: boolean; rail: boolean; t: (key: string) => string;
+}): RailItem[] {
+ const items: RailItem[] = [];
+ for (const group of groups) {
const first = group.blocks[0];
- if (group.family === "activity" && group.blocks.length > 1) return <div key={group.id} className={cn("py-1", conversation && "w-full")} data-trace-summary>
- <Disclosure label={<ActivitySummary blocks={group.blocks} live={live} />}
+ if (group.family === "activity" && group.blocks.length > 1) {
+ const inner = group.blocks.map(block => block.kind === "tool"
+ ? <TraceTool key={block.callId} block={block} status={status} onDecide={onDecide} />
+ : block.kind === "reasoning" ? <ReasoningTrace key={block.id} block={block} turnLive={live} compact /> : null);
+ const disclosure = <Disclosure label={<ActivitySummary blocks={group.blocks} live={live} />}
icon={<ActivityIcon blocks={group.blocks} live={live} />} initiallyOpen={live}
- forced={live}>
- {group.blocks.map(block => block.kind === "tool"
- ? <TraceTool key={block.callId} block={block} status={status} onDecide={onDecide} />
- : block.kind === "reasoning" ? <ReasoningTrace key={block.id} block={block} turnLive={live} compact /> : null)}
- </Disclosure>
- </div>;
- if (group.blocks.length > 1) return <Disclosure key={group.id}
- label={t(`work_trace.group_${group.family}`).replace("{count}", String(group.blocks.length))}
- icon={<Check aria-hidden className={iconClass} />} initiallyOpen={live}>
- {group.blocks.map(block => <TraceTool key={(block as ToolBlock).callId} block={block as ToolBlock} status={status} onDecide={onDecide} />)}
- </Disclosure>;
- if (first.kind === "tool") return <div key={group.id} className={conversation ? "w-full py-1 text-xs [&_button]:text-xs" : undefined}><TraceTool block={first} status={status} onDecide={onDecide} /></div>;
- if (first.kind === "reasoning") return <div key={group.id} className={conversation ? "w-full text-xs [&_button]:text-xs" : undefined}><ReasoningTrace block={first} turnLive={live} compact={conversation} /></div>;
- return first.text.trim() ? <div key={group.id} className={cn("min-w-0 py-2", conversation && "w-fit max-w-[min(85%,42rem)] rounded-2xl rounded-bl-md bg-secondary px-4 py-2.5")}>{renderText ? renderText(first.text, first.id) : <div className="prose prose-sm max-w-none text-foreground dark:prose-invert [overflow-wrap:anywhere]"><ChatMarkdown text={first.text} /></div>}</div> : null;
- });
+ forced={live} live={live}>
+ {rail ? <Rail items={group.blocks.map((block, i) => ({
+ key: block.kind === "tool" ? block.callId : block.id,
+ node: inner[i],
+ rail: !(block.kind === "tool" && block.question),
+ }))} /> : inner}
+ </Disclosure>;
+ items.push({ key: group.id, rail: true, node: rail ? <div data-trace-summary>{disclosure}</div>
+ : <div className={cn("py-1", conversation && "w-full")} data-trace-summary>{disclosure}</div> });
+ continue;
+ }
+ if (group.blocks.length > 1) {
+ const tools = group.blocks.map(block => <TraceTool key={(block as ToolBlock).callId} block={block as ToolBlock} status={status} onDecide={onDecide} />);
+ items.push({ key: group.id, rail: true, node: <Disclosure
+ label={rail ? <span className="text-foreground-secondary">{t(`work_trace.group_${group.family}`).replace("{count}", String(group.blocks.length))}</span>
+ : t(`work_trace.group_${group.family}`).replace("{count}", String(group.blocks.length))}
+ icon={rail ? group.family === "read" ? <FileText className={nodeIcon} /> : <FolderSearch className={nodeIcon} /> : <Check aria-hidden className={iconClass} />}
+ initiallyOpen={live}>
+ {rail ? <Rail items={tools.map((node, i) => ({ key: (group.blocks[i] as ToolBlock).callId, node, rail: true }))} /> : tools}
+ </Disclosure> });
+ continue;
+ }
+ if (first.kind === "tool") {
+ const tool = <TraceTool block={first} status={status} onDecide={onDecide} />;
+ items.push({ key: group.id, rail: !first.question, node: rail ? tool
+ : <div className={conversation ? "w-full py-1 text-xs [&_button]:text-xs" : undefined}>{tool}</div> });
+ continue;
+ }
+ if (first.kind === "reasoning") {
+ const thought = <ReasoningTrace block={first} turnLive={live} compact={conversation} />;
+ items.push({ key: group.id, rail: true, node: rail ? thought
+ : <div className={conversation ? "w-full text-xs [&_button]:text-xs" : undefined}>{thought}</div> });
+ continue;
+ }
+ if (!first.text.trim()) continue;
+ items.push({ key: group.id, rail: false, node: <div className={cn("min-w-0 py-2", conversation && "w-fit max-w-[min(85%,42rem)] rounded-2xl rounded-bl-md bg-secondary px-4 py-2.5")}>{renderText ? renderText(first.text, first.id) : <div className="prose prose-sm max-w-none text-foreground dark:prose-invert [overflow-wrap:anywhere]"><ChatMarkdown text={first.text} /></div>}</div> });
+ }
+ return items;
}
/**
@@ -440,12 +612,19 @@ function withoutQuestionPolls(blocks: TurnBlock[]): TurnBlock[] {
return kept.length === blocks.length ? blocks : kept;
}
-export function WorkTrace({ blocks: rawBlocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel, conversation = false }: {
+export function WorkTrace({ look = "rail", ...props }: WorkTraceProps & { look?: TraceLook }) {
+ return <TraceLookContext.Provider value={look}><WorkTraceBody {...props} /></TraceLookContext.Provider>;
+}
+
+type WorkTraceProps = {
blocks: TurnBlock[]; status: TurnStatus; startedMs: number; durationMs: number | null; error?: string | null;
onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; className?: string;
receipt?: ReactNode; completionLabel?: string; conversation?: boolean;
-}) {
+};
+
+function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel, conversation = false }: WorkTraceProps) {
const t = useT();
+ const rail = useRail();
const blocks = useMemo(() => withoutQuestionPolls(rawBlocks), [rawBlocks]);
const live = status === "running";
const elapsed = useClock(startedMs, live);
@@ -471,33 +650,72 @@ export function WorkTrace({ blocks: rawBlocks, status, startedMs, durationMs, er
const pending = asking || blocks.some(block => block.kind === "tool" && block.approval?.decision === null);
const outcome = asking ? "question" : pending ? "approval" : live ? "working" : status === "error" ? "failed" : status === "cancelled" ? "stopped" : "done";
const Icon = asking ? MessageCircleQuestion : pending ? ShieldQuestion : live ? CircleDashed : status === "error" ? CircleAlert : Check;
- const groupProps = { live, status, onDecide, renderText, conversation };
+ const groupProps = { live, status, onDecide, renderText, conversation, rail, t };
// A turn-level error next to a reply folds with the work — it stays one
// tap away behind the toggle. With no reply the error IS the outcome, so
// it stays out where it always was.
const answered = fold ? fold.answer.length > 0 : blocks.some((block) => block.kind === "text" && block.text.trim());
const foldedError = fold && answered && error ? error : null;
const visibleError = error && !foldedError ? error : null;
+ const outcomeLabel = outcome === "done" && completionLabel ? completionLabel : t(`work_trace.${outcome}`);
+ const receiptNode = receipt ? conversation ? <details className="ml-1"><summary className="cursor-pointer rounded-sm focus-visible:ring-2 focus-visible:ring-ring">{t("society.chat.activity_details")}</summary><div className="flex flex-wrap gap-2 py-1">{receipt}</div></details> : receipt : null;
+
+ if (rail) {
+ const working = live && !pending;
+ // The state line is the thread's last node while work is under way (or
+ // whenever the trace has no reply between it and the work); a finished
+ // conversation turn closes with a quiet line under its reply instead.
+ const statusOnRail = !conversation || live;
+ const statusLine = <div role="status" aria-live="polite" data-trace-status={outcome}
+ className={cn("flex min-w-0 flex-wrap items-start gap-x-3 text-xs leading-6 text-muted-foreground",
+ statusOnRail ? "py-1" : "pb-2 pt-1", status === "error" && "text-destructive", pending && "text-foreground")}>
+ <Node live={working}><Icon className={cn(nodeIcon, working && "motion-safe:animate-spin")} /></Node>
+ <span className="inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2">
+ <span><Live on={working}>{outcomeLabel}</Live></span>
+ {(live || durationMs !== null) ? <span aria-live="off" className="tabular-nums">{traceDuration(live ? elapsed : durationMs ?? 0)}</span> : null}
+ {receiptNode ? <span aria-hidden className="text-muted-foreground/50">·</span> : null}
+ {receiptNode}
+ </span>
+ </div>;
+ const statusItem: RailItem = { key: "trace:status", node: statusLine, rail: statusOnRail };
+ const errorItem = (text: string, key: string): RailItem => ({ key, rail: false,
+ node: <p role="alert" className="py-1.5 pl-7 text-sm text-destructive [overflow-wrap:anywhere]">{text}</p> });
+ const main = traceGroupItems({ groups, ...groupProps });
+ const rest = restGroups ? traceGroupItems({ groups: restGroups, ...groupProps }) : [];
+ const items: RailItem[] = fold
+ ? [{ key: "trace:fold", rail: false, node: <ConversationWorkFold durationMs={durationMs} blocks={fold.workAll}
+ attention={<Rail items={fold.approvals.map(block => ({ key: block.callId, rail: !block.question, node: <TraceTool block={block} status={status} onDecide={onDecide} /> }))} />}>
+ <Rail items={[...main, ...(foldedError ? [errorItem(foldedError, "trace:folded-error")] : [])]} />
+ </ConversationWorkFold> }, ...rest]
+ : main;
+ if (visibleError) items.push(errorItem(visibleError, "trace:error"));
+ items.push(statusItem);
+ return <div className={cn("min-w-0", conversation && "w-full max-w-xl self-start", className)} data-testid="work-trace" data-look="rail" data-state={status} {...(conversation ? { "data-conversation": "" } : {})}>
+ <Rail items={items} />
+ </div>;
+ }
+
+ const classicGroups = (list: Group[]) => <>{traceGroupItems({ groups: list, ...groupProps }).map(item => <Fragment key={item.key}>{item.node}</Fragment>)}</>;
return <div className={cn("min-w-0 space-y-0.5", conversation && "w-full max-w-xl self-start", className)} data-testid="work-trace" data-state={status} {...(conversation ? { "data-conversation": "" } : {})}>
- {fold ? <ConversationWorkFold durationMs={durationMs} attention={fold.approvals.map(block =>
+ {fold ? <ConversationWorkFold durationMs={durationMs} blocks={fold.workAll} attention={fold.approvals.map(block =>
<div key={block.callId} className="w-full py-1 text-xs [&_button]:text-xs">
<TraceTool block={block} status={status} onDecide={onDecide} />
</div>)}>
- <TraceGroups groups={groups} {...groupProps} />
+ {classicGroups(groups)}
{foldedError ? <p role="alert" className="py-2 text-sm text-destructive [overflow-wrap:anywhere]">{foldedError}</p> : null}
- </ConversationWorkFold> : <TraceGroups groups={groups} {...groupProps} />}
- {restGroups ? <TraceGroups groups={restGroups} {...groupProps} /> : null}
+ </ConversationWorkFold> : classicGroups(groups)}
+ {restGroups ? classicGroups(restGroups) : null}
{visibleError ? <p role="alert" className="py-2 text-sm text-destructive [overflow-wrap:anywhere]">{visibleError}</p> : null}
<div role="status" aria-live="polite" className={cn("flex flex-wrap items-center gap-2 text-xs text-muted-foreground", conversation ? "px-1 pb-2 pt-1" : "border-t border-border pt-3", status === "error" && "text-destructive")}>
<Icon aria-hidden className={cn("h-3.5 w-3.5", live && !pending && "motion-safe:animate-spin")} />
- <span>{outcome === "done" && completionLabel ? completionLabel : t(`work_trace.${outcome}`)}</span>
+ <span>{outcomeLabel}</span>
{(live || durationMs !== null) ? <span aria-live="off" className="tabular-nums">{traceDuration(live ? elapsed : durationMs ?? 0)}</span> : null}
- {receipt ? conversation ? <details className="ml-1"><summary className="cursor-pointer rounded-sm focus-visible:ring-2 focus-visible:ring-ring">{t("society.chat.activity_details")}</summary><div className="flex flex-wrap gap-2 py-1">{receipt}</div></details> : receipt : null}
+ {receiptNode}
</div>
</div>;
}
-export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; conversation?: boolean }) {
+export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; conversation?: boolean; look?: TraceLook }) {
const t = useT();
const tokens = outputTokens(turn.usage ?? turn.liveUsage);
const answered = turn.blocks.some(block => block.kind === "text" && block.text.trim());
diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
index c7a05d0195..97c38ffbcb 100644
--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
@@ -234,6 +234,9 @@ function ChatStageContent() {
providerLabel={providerLabel}
onDecide={onDecide}
bubbles={isJarvis}
+ // The Agentic IDE mirrors Claude Code and Codex, whose own traces
+ // the maintainer kept; every other surface draws the rail.
+ traceLook={isJarvis ? "rail" : "classic"}
/>
<div ref={spacerRef} aria-hidden data-testid="chat-bottom-spacer" className="shrink-0" />
</div>
diff --git a/jarvis/ui/web/frontend/src/components/local-models/AssistantSteps.tsx b/jarvis/ui/web/frontend/src/components/local-models/AssistantSteps.tsx
index 895a0ce04c..ea1535590b 100644
--- a/jarvis/ui/web/frontend/src/components/local-models/AssistantSteps.tsx
+++ b/jarvis/ui/web/frontend/src/components/local-models/AssistantSteps.tsx
@@ -23,6 +23,7 @@ import type { ReasoningBlock, ToolBlock, TurnBlock } from "@/components/agentcha
import { fill, useT } from "@/i18n";
import type { ApprovalDecision } from "@/lib/agentChatApi";
import { cn } from "@/lib/utils";
+import "@/components/agentchat/WorkTrace.css";
/** Tool name → i18n key of its sentence. Unknown tools fall back to the name. */
const STEP_KEYS: Record<string, string> = {
@@ -74,12 +75,16 @@ function toneOf(block: TurnBlock): Tone {
return block.output === null ? "run" : "done";
}
+/** The step's node on the rail (components/agentchat/WorkTrace.css). */
function Mark({ tone }: { tone: Tone }) {
- if (tone === "run") return <Loader2 className="h-3 w-3 animate-spin text-muted-foreground" />;
- if (tone === "fail") return <X className="h-3 w-3 text-destructive" />;
- if (tone === "ask")
- return <span className="h-1.5 w-1.5 rounded-full bg-foreground" />;
- return <Check className="h-3 w-3 text-muted-foreground" />;
+ return (
+ <span aria-hidden className={cn("trace-node", tone === "run" && "trace-node-live")}>
+ {tone === "run" ? <span className="trace-dot" />
+ : tone === "fail" ? <X className="h-3.5 w-3.5 text-destructive" />
+ : tone === "ask" ? <span className="trace-dot text-foreground" />
+ : <Check className="h-3.5 w-3.5" />}
+ </span>
+ );
}
function StepRow({
@@ -99,21 +104,19 @@ function StepRow({
const [open, setOpen] = useState(false);
const hasDetail = Boolean(detail && detail.trim());
return (
- <li className="group/step" data-testid="assistant-step" data-tone={tone}>
- <div className="flex items-baseline gap-2">
- <span className="flex h-4 w-4 shrink-0 translate-y-[2px] items-center justify-center">
- <Mark tone={tone} />
- </span>
+ <li className="trace-step group/step pb-0.5" data-testid="assistant-step" data-tone={tone}>
+ <div className="flex items-start gap-3 py-1 text-sm leading-6">
+ <Mark tone={tone} />
<span
className={cn(
- "text-meta ",
- tone === "fail" ? "text-destructive" : "text-foreground/90",
+ "min-w-0",
+ tone === "fail" ? "text-destructive" : "text-foreground-secondary",
)}
>
- {label}
+ {tone === "run" ? <span className="trace-shimmer">{label}</span> : label}
</span>
{meta && (
- <span className="font-mono text-micro tabular-nums text-muted-foreground">
+ <span className="shrink-0 text-xs tabular-nums text-muted-foreground">
{meta}
</span>
)}
@@ -122,7 +125,7 @@ function StepRow({
type="button"
onClick={() => setOpen((v) => !v)}
className={cn(
- "ml-auto shrink-0 rounded px-1 text-micro text-muted-foreground",
+ "ml-auto shrink-0 rounded px-1 text-xs text-muted-foreground",
"transition-colors group-hover/step:text-muted-foreground hover:!text-foreground",
"focus-visible:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
open && "!text-muted-foreground",
@@ -133,7 +136,7 @@ function StepRow({
)}
</div>
{open && hasDetail && (
- <pre className="ml-6 mt-1.5 max-h-56 overflow-auto rounded-md border border-border bg-muted p-2.5 font-mono text-micro text-muted-foreground">
+ <pre className="mb-1.5 ml-7 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-muted/60 px-3 py-2 font-mono text-xs leading-5 text-foreground-secondary [overflow-wrap:anywhere]">
{detail}
</pre>
)}
@@ -174,7 +177,7 @@ function ToolStep({
return (
<StepRow tone={tone} label={label} meta={seconds(block.durationMs)} detail={detail}>
{tone === "ask" && block.approval && onDecide && (
- <div className="ml-6 mt-2 flex flex-wrap items-center gap-3 rounded-lg bg-secondary px-3 py-2">
+ <div className="mb-1.5 ml-7 mt-1 flex flex-wrap items-center gap-3">
<span className="text-meta text-foreground">{block.approval.summary}</span>
<div className="ml-auto flex gap-1.5">
<button
@@ -253,24 +256,30 @@ export function AssistantSteps({
aria-expanded={open}
disabled={pinned}
className={cn(
- "-mx-1 inline-flex items-center gap-1.5 rounded-md px-1 py-0.5",
- "text-xs text-muted-foreground",
+ "inline-flex items-center gap-2 rounded-full border border-border py-1 pl-2.5 pr-2",
+ "text-xs leading-5 text-muted-foreground transition-colors",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- !pinned && "hover:text-foreground",
+ !pinned && "hover:border-border-strong hover:bg-secondary hover:text-foreground",
)}
>
+ {live ? (
+ <Loader2 className="h-3 w-3 shrink-0 text-accent motion-safe:animate-spin" />
+ ) : (
+ <span aria-hidden className="trace-dot shrink-0" />
+ )}
+ <span className={live ? "trace-shimmer" : undefined}>
+ {live ? t("local_models.assistant.steps.working") : summary}
+ </span>
<ChevronRight
className={cn(
- "h-3.5 w-3.5 shrink-0 transition-transform",
+ "h-3 w-3 shrink-0 opacity-60 transition-transform",
open && "rotate-90",
pinned && "hidden",
)}
/>
- {live && <Loader2 className="h-3 w-3 shrink-0 animate-spin text-muted-foreground" />}
- <span>{live ? t("local_models.assistant.steps.working") : summary}</span>
</button>
{open && (
- <ul className="mt-2 flex flex-col gap-2 border-l border-border pl-3.5">
+ <ul className="trace-rail mt-1.5 pl-[5px]">
{steps.map((block) =>
block.kind === "tool" ? (
<ToolStep key={block.callId} block={block} onDecide={onDecide} />