Python
feat(gui): Steps panel in the UX-059 look (OPE-244)
Devika Vermaf75fef424ad0
diff --git a/coworker/observability/read_api.py b/coworker/observability/read_api.pyindex 2b157822..efb9fc95 100644--- a/coworker/observability/read_api.py+++ b/coworker/observability/read_api.py@@ -57,11 +57,41 @@ def step(recording: dict[str, Any], step_id: str, *, get_piece: Callable[[str],message = next((m for m in messages if m.get("mid") == mid), None)if message is not None:out["message"] = _cut(message)- out["audit"] = audit_rows(found["call_id"]) if found.get("call_id") else []+ call_id = found.get("call_id")+ out["audit"] = audit_rows(call_id) if call_id else []out["children"] = [_light(s) for s in steps if s.get("parent_step_id") == step_id]+ if call_id and found.get("kind") in ("tool", "auto_approver"):+ # The details panel shows a tool call as one card: its arguments (from the+ # transcript), the card it waited on, and for a check, the call it judged (UX-059).+ args = _tool_arguments(messages, call_id)+ if args is not None:+ out["arguments"] = args+ wait = next((s for s in steps if s.get("kind") == "wait" and s.get("turn_id") == found.get("turn_id")+ and (s.get("call_id") == call_id or (s.get("attrs") or {}).get("for_call_id") == call_id)), None)+ if wait is not None:+ out["wait"] = _light(wait)+ if found.get("kind") == "auto_approver":+ target = next((s for s in steps if s.get("kind") == "tool" and s.get("call_id") == call_id), None)+ if target is not None:+ out["for_step"] = _light(target)return out+def _tool_arguments(messages: list[dict[str, Any]], call_id: str) -> Any:+ """The arguments of the model's tool call with this id, as sent (parsed when JSON)."""+ for m in reversed(messages):+ for tc in m.get("tool_calls") or []:+ if tc.get("id") == call_id:+ raw = (tc.get("function") or {}).get("arguments", tc.get("arguments"))+ if isinstance(raw, str):+ try:+ return json.loads(raw)+ except ValueError:+ return raw+ return raw+ return None++def _rebuilt(entry: dict[str, Any], get_piece: Callable[[str], Optional[bytes]]) -> dict[str, Any]:body = get_piece((entry.get("response") or {}).get("body_blob") or "") or b""try:@@ -79,8 +109,14 @@ def _cut(message: dict[str, Any]) -> dict[str, Any]:content = message.get("content")text = content if isinstance(content, str) else json.dumps(content, ensure_ascii=False, default=str)cut = len(text) > MESSAGE_CUT- return {"role": message.get("role"), "mid": message.get("mid"), "tool_call_id": message.get("tool_call_id"),- "content": text[:MESSAGE_CUT], "cut": cut}+ out = {"role": message.get("role"), "mid": message.get("mid"), "tool_call_id": message.get("tool_call_id"),+ "content": text[:MESSAGE_CUT], "cut": cut}+ calls = [{"name": (tc.get("function") or {}).get("name") or tc.get("name"),+ "arguments": str((tc.get("function") or {}).get("arguments", tc.get("arguments", "")))[:MESSAGE_CUT // 4]}+ for tc in message.get("tool_calls") or []]+ if calls:+ out["tool_calls"] = calls # a model reply's tool calls, for the details' Output (UX-059 OB-2)+ return outdef usage(recording: dict[str, Any], session_id: str) -> dict[str, Any]:diff --git a/surfaces/gui/src/components/StepsPanel.test.tsx b/surfaces/gui/src/components/StepsPanel.test.tsxindex 3e4bdf9a..4fd7ed68 100644--- a/surfaces/gui/src/components/StepsPanel.test.tsx+++ b/surfaces/gui/src/components/StepsPanel.test.tsx@@ -72,7 +72,7 @@ describe("StepsPanel", () => {const tokens = await screen.findByTestId("steps-tokens");expect(tokens.textContent).toContain("from cache 900");expect(tokens.textContent).toContain("written to cache —"); // not reported is not 0- expect(screen.getByTestId("steps-details").textContent).toContain("tool_calls");+ expect(screen.getByTestId("steps-details").textContent).toContain("stopped because it asked for a tool");});it("shows the session's usage by purpose and model", async () => {@@ -151,7 +151,7 @@ describe("StepsPanel", () => {await waitFor(() => expect(screen.getAllByTestId("steps-row")).toHaveLength(3));fireEvent.click(screen.getAllByTestId("steps-row")[0]);let d = (await screen.findByTestId("steps-details")).textContent || "";- for (const s of ["Memories2 · as an index", "Your rules1", "AGENTS.md files1", "Folders2", "Mode noteplan", "Skills offered3 · ab12cd", "1057 · 69a95b"]) expect(d).toContain(s);+ for (const s of ["Memories 2 · as an index", "Your rules 1", "AGENTS.md files 1", "Folders 2", "Mode note plan", "Skills offered 3 ⓢab12cd", "1057 · 69a95b"]) expect(d).toContain(s);fireEvent.click(screen.getAllByTestId("steps-row")[1]);await waitFor(() => expect(screen.getByTestId("steps-details").textContent).toContain("req_1"));d = screen.getByTestId("steps-details").textContent || "";@@ -213,7 +213,7 @@ describe("StepsPanel", () => {vi.mocked(getStepDetail).mockResolvedValue(check as any);render(<StepsPanel sessionId="s1" onClose={() => {}} />);fireEvent.click((await screen.findAllByTestId("steps-row"))[0]);- expect((await screen.findByTestId("steps-questions")).textContent).toContain("unrelated_destination: yes (0.99)");+ expect((await screen.findByTestId("steps-questions")).textContent).toContain("unrelated_destinationyes 0.99");});it("shows the mode, the reviewer and the turn's stamps in the header", async () => {diff --git a/surfaces/gui/src/components/StepsPanel.tsx b/surfaces/gui/src/components/StepsPanel.tsxindex 6d79ecbf..2ee15617 100644--- a/surfaces/gui/src/components/StepsPanel.tsx+++ b/surfaces/gui/src/components/StepsPanel.tsx@@ -1,7 +1,9 @@-// Observability Phase 1 (UX-059 OB-1, OB-2, OB-4): every step of a turn on one time axis,-// the "where did the time go" tiles, one step's details, and the session's token usage.-// Reads the engine's recording endpoints (technical design §12); `refreshKey` moves when-// live step events or a turn's end arrive, so the panel follows a running turn.+// Observability Phase 1 (UX-059 OB-1, OB-2, OB-11, OB-4): every step of a turn on one time+// axis, the "where did the time go" tiles, one step's details beside the list, and the+// session's token usage. Laid out and styled as the UX-059 mock (docs/ux-improvements/mocks/+// UX-059-observability-desktop.html). Reads the engine's recording endpoints (technical design+// §12); `refreshKey` moves when live step events or a turn's end arrive, so the panel follows a+// running turn.import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";@@ -15,6 +17,8 @@ import {} from "../api";import { formatTokens } from "../usage";+type T = (k: string, o?: any) => string;+const BUCKETS = ["waiting", "tools", "model", "auto_approver", "summary"] as const;/** 0.1s, 3.4s, 41s, 2m 14s: the panel's one duration format. */@@ -28,6 +32,19 @@ export function formatDuration(ms: number | null | undefined): string {return s ? `${m}m ${s}s` : `${m}m`;}+/** A moment in the turn as the mock writes it: 00:52.1 */+function clock(ms: number): string {+ const v = Math.max(0, ms);+ const m = Math.floor(v / 60_000);+ const s = (v % 60_000) / 1000;+ return `${String(m).padStart(2, "0")}:${s.toFixed(1).padStart(4, "0")}`;+}++/** Axis labels for a turn of `total` ms: five marks, as the mock's 0 · 1m · 2m · 3m · 4m. */+function ticks(total: number): string[] {+ return [0, 1, 2, 3, 4].map((i) => (i === 0 ? "0" : formatDuration((total * i) / 4)));+}+const MODE_KEYS: Record<string, string> = {discuss: "composer.mode.discuss", interactive: "composer.mode.interactive", plan: "steps.mode.plan","auto-approve": "composer.mode.auto_approve", "bypass-approvals": "composer.mode.auto", auto: "composer.mode.auto",@@ -35,14 +52,14 @@ const MODE_KEYS: Record<string, string> = {};/** Who reviews in Auto-approve or Shadow evaluation: the session model by name, or the service. */-export function reviewerLabel(r: RecordedTurn["reviewer"], t: (k: string, o?: any) => string): string {+export function reviewerLabel(r: RecordedTurn["reviewer"], t: T): string {if (!r || !r.kind) return "";if (r.kind === "session_model") return r.model ? t("steps.reviewer.session_model_named", { model: r.model }) : t("steps.reviewer.session_model");return t(`steps.reviewer.${r.kind}`, { defaultValue: r.kind });}/** The mode pill (OB-1): the approval mode, and in Auto-approve or Shadow evaluation the reviewer. */-export function modeLabel(turn: RecordedTurn, t: (k: string, o?: any) => string): string {+export function modeLabel(turn: RecordedTurn, t: T): string {if (!turn.approval_mode) return "";const mode = t(MODE_KEYS[turn.approval_mode] || "", { defaultValue: turn.approval_mode });const r = turn.reviewer;@@ -53,7 +70,7 @@ export function modeLabel(turn: RecordedTurn, t: (k: string, o?: any) => string)}/** The header's stamp line (OB-12, OB-14, OB-15): machine · sandbox · coworker · model and provider. */-export function stampLine(stamp: Record<string, any> | undefined, t: (k: string, o?: any) => string): string {+export function stampLine(stamp: Record<string, any> | undefined, t: T): string {if (!stamp) return "";const parts: string[] = [];const m = stamp.machine;@@ -81,7 +98,7 @@ function formatBytes(n: number): string {}/** The row's label, as the mock writes it: "Model · summary", "Auto-approver · allowed"… */-export function stepLabel(step: RecordedStep, t: (k: string, o?: any) => string): string {+export function stepLabel(step: RecordedStep, t: T): string {const a = step.attrs || {};switch (step.kind) {case "context":@@ -115,7 +132,7 @@ type Flag = { cls: "err" | "warn" | "info"; text: string };/** The row's badges, as the mock draws them: why a call failed, a refused or failed tool,* a call with no token counts, an auto-approved action, a step after the turn. */-export function stepFlags(step: RecordedStep, t: (k: string, o?: any) => string): Flag[] {+export function stepFlags(step: RecordedStep, t: T): Flag[] {const a = step.attrs || {};const flags: Flag[] = [];if (step.kind === "model") {@@ -164,6 +181,10 @@ function nest(steps: RecordedStep[]): { step: RecordedStep; depth: number }[] {return out;}+const KIND_CLASS: Record<string, string> = {+ context: "ctx", model: "model", tool: "tool", wait: "wait", auto_approver: "review", summary: "sum", notice: "ctx",+};+export function StepsPanel({sessionId,refreshKey = 0,@@ -229,80 +250,109 @@ export function StepsPanel({const rows = useMemo(() => nest(steps), [steps]);const checks = steps.filter((s) => s.kind === "auto_approver" && !s.shadow);+ const inspecting = tab === "timeline" && !!selected && !!turn;+ const total = turn ? Math.max(1, turn.buckets.total || turn.duration_ms || 1) : 1;- return (- <div className="team-view steps-panel" data-testid="steps-panel">- <div className="team-pane-header">- <strong>{t("steps.title")}</strong>- {turns && turns.length > 0 && turnIdx != null && (- <span className="steps-turn-picker">- <button aria-label={t("steps.prev_turn")} disabled={turnIdx <= 0} onClick={() => setTurnIdx(turnIdx - 1)}>‹</button>- <span data-testid="steps-turn">{t("steps.turn_of", { n: turnIdx + 1, total: turns.length })}</span>- <button aria-label={t("steps.next_turn")} disabled={turnIdx >= turns.length - 1} onClick={() => setTurnIdx(turnIdx + 1)}>›</button>- </span>- )}- <button className="team-close" aria-label={t("steps.close")} onClick={onClose}>×</button>+ const picker = turns && turns.length > 0 && turnIdx != null && (+ <span className="steps-turn-picker">+ <button aria-label={t("steps.prev_turn")} disabled={turnIdx <= 0} onClick={() => setTurnIdx(turnIdx - 1)}>‹</button>+ <span data-testid="steps-turn">{t("steps.turn_of", { n: turnIdx + 1, total: turns.length })}</span>+ <button aria-label={t("steps.next_turn")} disabled={turnIdx >= turns.length - 1} onClick={() => setTurnIdx(turnIdx + 1)}>›</button>+ </span>+ );++ const timeline = turn && (+ <div className="steps-timeline" data-testid="steps-timeline">+ <div className="steps-axis" aria-hidden>+ <span>{t("steps.axis.step")}</span>+ <span className="steps-ticks">{ticks(total).map((x, i) => <span key={i}>{x}</span>)}</span>+ <span className="steps-axis-time">{t("steps.axis.time")}</span></div>+ {rows.map(({ step, depth }) => (+ <StepRow+ key={step.step_id}+ step={step}+ depth={depth}+ turn={turn}+ total={total}+ label={stepLabel(step, t)}+ selected={selected === step.step_id}+ onSelect={() => setSelected(selected === step.step_id ? null : step.step_id)}+ />+ ))}+ </div>+ );- {turn && (modeLabel(turn, t) || stampLine(turn.stamp, t)) && (- <div className="steps-stamp" data-testid="steps-stamp">- {modeLabel(turn, t) && <span className="steps-mode" data-testid="steps-mode">{modeLabel(turn, t)}</span>}- {stampLine(turn.stamp, t) && <span className="steps-stamp-line">{stampLine(turn.stamp, t)}</span>}+ return (+ <div className={"team-view steps-panel" + (inspecting ? " inspecting" : "")} data-testid="steps-panel">+ <div className="steps-railhead">+ <div className="steps-railhead-title">+ <strong>{t("steps.title")}</strong>+ {picker}+ <span className="steps-sp" />+ <button className="steps-close" aria-label={t("steps.close")} onClick={onClose}>✕</button></div>- )}- {error && <p className="steps-empty">{t("steps.load_error")}</p>}- {turns && turns.length === 0 && <p className="steps-empty" data-testid="steps-none">{t("steps.not_recorded")}</p>}-- {turn && (- <div className="steps-body">- <div className="steps-tiles" data-testid="steps-tiles">- <Tile value={formatDuration(turn.buckets.total)} label={t("steps.bucket.total")} />- {BUCKETS.filter((b) => turn.buckets[b] > 0).map((b) => (- <Tile key={b} value={formatDuration(turn.buckets[b])} label={t(`steps.bucket.${b}`)} />- ))}- {turn.buckets.other_shown && <Tile value={formatDuration(turn.buckets.other)} label={t("steps.bucket.other")} />}+ {turn && (modeLabel(turn, t) || stampLine(turn.stamp, t)) && (+ <div className="steps-stamp" data-testid="steps-stamp">+ {modeLabel(turn, t) && (+ <span className={"steps-pill steps-mode" + (turn.reviewer?.active ? " review" : "")} data-testid="steps-mode">{modeLabel(turn, t)}</span>+ )}+ {stampLine(turn.stamp, t) && <span className="steps-stamp-line">{stampLine(turn.stamp, t)}</span>}</div>- {steps.some((s) => s.status === "unknown") && (- <p className="steps-line" data-testid="steps-gap">- {t("steps.unknown_line", { count: steps.filter((s) => s.status === "unknown").length })}- </p>- )}- {checks.length > 0 && (- <p className="steps-line" data-testid="steps-checks">- {t("steps.checks_line", {- count: checks.length,- allowed: checks.filter((c) => c.attrs.result === "allow").length,- asked: checks.filter((c) => c.attrs.result !== "allow" && c.attrs.result !== "deny").length,- blocked: checks.filter((c) => c.attrs.result === "deny").length,- time: formatDuration(turn.buckets.auto_approver || 0),- reviewer: reviewerLabel(turn.reviewer, t) || reviewerLabel(checks[0]?.attrs?.reviewer, t) || "—",- })}- </p>- )}- <div className="team-tabs steps-tabs" role="tablist">+ )}+ {turn && !inspecting && (+ <>+ <div className="steps-tiles" data-testid="steps-tiles">+ <Tile value={formatDuration(turn.buckets.total)} label={t("steps.bucket.total")} />+ {BUCKETS.filter((b) => turn.buckets[b] > 0).map((b) => (+ <Tile key={b} value={formatDuration(turn.buckets[b])} label={t(`steps.bucket.${b}`)} />+ ))}+ {turn.buckets.other_shown && <Tile value={formatDuration(turn.buckets.other)} label={t("steps.bucket.other")} />}+ </div>+ {steps.some((s) => s.status === "unknown") && (+ <p className="steps-line" data-testid="steps-gap">+ {t("steps.unknown_line", { count: steps.filter((s) => s.status === "unknown").length })}+ </p>+ )}+ {checks.length > 0 && (+ <p className="steps-line" data-testid="steps-checks">+ {t("steps.checks_line", {+ count: checks.length,+ allowed: checks.filter((c) => c.attrs.result === "allow").length,+ asked: checks.filter((c) => c.attrs.result !== "allow" && c.attrs.result !== "deny").length,+ blocked: checks.filter((c) => c.attrs.result === "deny").length,+ time: formatDuration(turn.buckets.auto_approver || 0),+ reviewer: reviewerLabel(turn.reviewer, t) || reviewerLabel(checks[0]?.attrs?.reviewer, t) || "—",+ })}+ </p>+ )}+ </>+ )}+ {turn && (+ <div className="steps-tabs" role="tablist"><button role="tab" aria-selected={tab === "timeline"} onClick={() => setTab("timeline")}>{t("steps.tab.timeline")}</button><button role="tab" aria-selected={tab === "usage"} onClick={() => setTab("usage")}>{t("steps.tab.usage")}</button></div>+ )}+ </div>- {tab === "timeline" && (- <div className="steps-timeline" data-testid="steps-timeline">- {rows.map(({ step, depth }) => (- <StepRow- key={step.step_id}- step={step}- depth={depth}- turn={turn}- label={stepLabel(step, t)}- selected={selected === step.step_id}- onSelect={() => setSelected(selected === step.step_id ? null : step.step_id)}- />- ))}- {selected && <StepDetails sessionId={sessionId} stepId={selected} turn={turn} />}- </div>- )}- {tab === "usage" && <UsageView sessionId={sessionId} refreshKey={refreshKey} />}+ {error && <p className="steps-empty">{t("steps.load_error")}</p>}+ {turns && turns.length === 0 && <p className="steps-empty" data-testid="steps-none">{t("steps.not_recorded")}</p>}++ {turn && tab === "timeline" && !inspecting && <div className="steps-railbody">{timeline}</div>}+ {turn && inspecting && (+ <div className="steps-split">+ <div className="steps-railbody steps-list">{timeline}</div>+ <StepDetails+ sessionId={sessionId}+ stepId={selected!}+ turn={turn}+ steps={steps}+ onClose={() => setSelected(null)}+ /></div>)}+ {turn && tab === "usage" && <div className="steps-railbody"><UsageView sessionId={sessionId} refreshKey={refreshKey} /></div>}</div>);}@@ -316,23 +366,22 @@ function Tile({ value, label }: { value: string; label: string }) {);}-function StepRow({ step, depth, turn, label, selected, onSelect }: {- step: RecordedStep; depth: number; turn: RecordedTurn; label: string; selected: boolean; onSelect: () => void;+function StepRow({ step, depth, turn, total, label, selected, onSelect }: {+ step: RecordedStep; depth: number; turn: RecordedTurn; total: number; label: string; selected: boolean; onSelect: () => void;}) {const { t } = useTranslation();- const total = Math.max(1, turn.buckets.total || turn.duration_ms || 1);const left = Math.min(100, Math.max(0, ((step.started_at - turn.started_at) / total) * 100));const width = step.duration_ms ? Math.min(100 - left, (step.duration_ms / total) * 100) : 0;+ const kind = KIND_CLASS[step.kind] || "ctx";return (<button- className={`steps-row kind-${step.kind}` + (selected ? " selected" : "") + (step.shadow ? " shadow" : "")}- style={{ paddingLeft: 8 + depth * 14 }}+ className={`steps-row k-${kind}` + (selected ? " selected" : "") + (step.shadow ? " shadow" : "")}onClick={onSelect}data-testid="steps-row">- <span className="steps-dot" />- <span className="steps-label">- {label}+ <span className="steps-label" style={{ paddingLeft: depth * 16 }}>+ <span className="steps-kind" />+ <span className="steps-name">{label}</span>{stepFlags(step, t).map((f) => (<span key={f.text} className={`steps-badge ${f.cls}`}>{f.text}</span>))}@@ -345,137 +394,415 @@ function StepRow({ step, depth, turn, label, selected, onSelect }: {);}-function StepDetails({ sessionId, stepId, turn }: { sessionId: string; stepId: string; turn: RecordedTurn }) {+// -- details (the inspector of the mock) ---------------------------------------------------------++/** The messages a model call was given, as "role · text" lines (Chat, Responses or Gemini shape). */+function inputLines(request: any): string[] {+ if (!request || typeof request !== "object") return [];+ const items: any[] = request.messages || request.input || request.contents || [];+ if (!Array.isArray(items)) return [];+ const text = (c: any): string => {+ if (typeof c === "string") return c;+ if (Array.isArray(c)) return c.map((p) => (typeof p === "string" ? p : p?.text ?? p?.output ?? "")).filter(Boolean).join(" ");+ if (c && typeof c === "object") return c.text ?? "";+ return "";+ };+ return items.map((m) => {+ const role = m.role || m.type || "message";+ const calls = (m.tool_calls || []).map((c: any) => `(tool call) ${c.function?.name ?? c.name} ${c.function?.arguments ?? ""}`.trim());+ const body = [text(m.content ?? m.parts ?? m.output ?? ""), ...calls].filter(Boolean).join("\n");+ return `${role} · ${body}`.slice(0, 600);+ });+}++function Kv({ rows }: { rows: [string, React.ReactNode][] }) {+ return (+ <dl className="steps-kv">+ {rows.map(([k, v]) => (+ <div key={k}><dt>{k}</dt><dd>{v ?? "—"}</dd></div>+ ))}+ </dl>+ );+}++function Sec({ label, right }: { label: string; right?: React.ReactNode }) {+ return <div className="steps-seclbl">{label}{right != null && <><span className="steps-sp" /><span className="steps-seclbl-right">{right}</span></>}</div>;+}++function ContextAdded({ ctx, t }: { ctx: Record<string, any> | null | undefined; t: T }) {+ if (!ctx) return null;+ const start = ctx.session_start, pt = ctx.per_turn || {};+ const rows: [string, React.ReactNode][] = [];+ if (start) {+ const mems = start.memories || [];+ rows.push(["memory", <>{t("steps.detail.memories")} {mems.length}{start.memory_mode === "index" ? ` · ${t("steps.detail.as_index")}` : ""}+ {mems.length > 0 && <span className="steps-mono steps-faint"> {mems.slice(0, 6).map((m: any) => `mem_${m}`).join(", ")}</span>}</>]);+ if (start.rules) rows.push(["rules", <>{t("steps.detail.rules")} {start.rules}</>]);+ if (start.agents_md) rows.push(["AGENTS.md", <>{t("steps.detail.agents_md")} {start.agents_md}</>]);+ }+ rows.push(["skill", <>{t("steps.detail.skills")} {pt.skills_menu || 0}{pt.skills_hash && <span className="steps-mono steps-faint"> ⓢ{pt.skills_hash}</span>}</>]);+ rows.push(["folder", <>{t("steps.detail.folders")} {pt.folders ?? 0}</>]);+ if (pt.mode_note) rows.push(["mode", <>{t("steps.detail.mode_note")} {pt.mode_note}</>]);+ if (pt.sandbox_note) rows.push(["sandbox", <>{t("steps.detail.sandbox_note")}</>]);+ return (+ <div className="steps-ctxlist">+ {rows.map(([tag, body]) => (+ <div key={tag}><span className="steps-pill">{tag}</span><span className="steps-c">{body}</span></div>+ ))}+ {ctx.size_chars != null && (+ <div><span className="steps-pill">{t("steps.insp.block")}</span><span className="steps-c">{t("steps.detail.size")}</span>+ <span className="steps-sz">{ctx.size_chars} · <span className="steps-mono">{ctx.block_hash || "—"}</span></span></div>+ )}+ </div>+ );+}++function TokenBar({ u, t }: { u: any; t: T }) {+ if (!u) return null;+ if (!u.reported) return <p className="steps-line" data-testid="steps-tokens">{t("steps.tokens_not_reported")}</p>;+ const cache = u.cache_read || 0, written = u.cache_write || 0, fresh = u.input_fresh || 0, out = u.output || 0;+ const all = Math.max(1, cache + written + fresh + out);+ const seg = (n: number, cls: string) => (n > 0 ? <i className={cls} style={{ width: `${(n / all) * 100}%` }} /> : null);+ return (+ <div data-testid="steps-tokens">+ <div className="steps-tokbar">{seg(cache, "c-cache")}{seg(written, "c-write")}{seg(fresh, "c-new")}{seg(out, "c-out")}</div>+ <div className="steps-legend">+ ■ <span className="c-cache">{t("steps.insp.from_cache", { n: formatTokens(cache) })}</span>+ {" · "}<span className="c-write">{t("steps.insp.written", { n: u.cache_write == null ? "—" : formatTokens(written) })}</span>+ {" · "}<span className="c-new">{t("steps.insp.new", { n: formatTokens(fresh) })}</span>+ {" · "}<span className="c-out">{u.reasoning != null+ ? t("steps.insp.out_reasoning", { n: formatTokens(out), r: formatTokens(u.reasoning) })+ : t("steps.insp.out", { n: formatTokens(out) })}</span>+ </div>+ </div>+ );+}++function Joined({ audit, t }: { audit: any[]; t: T }) {+ if (!audit?.length) return null;+ const stages = Array.from(new Set(audit.map((r) => r.stage).filter(Boolean)));+ return (+ <>+ <Sec label={t("steps.insp.joined")} />+ <div className="steps-small">{t("steps.insp.joined_line", { count: audit.length })} · <span className="steps-mono">{stages.join(", ")}</span> · {t("steps.insp.same_call")}</div>+ </>+ );+}++function StepDetails({ sessionId, stepId, turn, steps, onClose }: {+ sessionId: string; stepId: string; turn: RecordedTurn; steps: RecordedStep[]; onClose: () => void;+}) {const { t } = useTranslation();const [d, setD] = useState<any>(null);useEffect(() => {let live = true;+ setD(null);getStepDetail(sessionId, stepId).then((s) => live && setD(s)).catch(() => {});return () => {live = false;};}, [sessionId, stepId]);- if (!d) return <div className="steps-details">{t("steps.loading")}</div>;+ return (+ <div className="steps-insp steps-details" data-testid="steps-details">+ <button className="steps-close steps-insp-close" aria-label={t("steps.insp.close")} onClick={onClose}>✕</button>+ {!d ? <p className="steps-line">{t("steps.loading")}</p> : <Inspector d={d} turn={turn} steps={steps} sessionId={sessionId} t={t} />}+ </div>+ );+}++function statusPill(d: any, t: T): { cls: string; text: string } {const a = d.attrs || {};- const rows: [string, any][] = [- [t("steps.detail.status"), t(`steps.status.${d.status}`, { defaultValue: d.status })],- [t("steps.detail.started"), formatDuration(d.started_at - turn.started_at)],- [t("steps.detail.duration"), formatDuration(d.duration_ms)],- ];+ if (d.kind === "tool" && a.exit_code != null && a.exit_code !== 0 && d.status !== "denied") return { cls: "danger", text: t("steps.flag.exit", { code: a.exit_code }) };+ if (d.status === "ok") return { cls: "ok", text: t("steps.insp.done") };+ if (d.status === "interrupted" || d.status === "unknown") return { cls: "warn", text: t(`steps.status.${d.status}`) };+ return { cls: "danger", text: t(`steps.status.${d.status}`, { defaultValue: d.status }) };+}++function Inspector({ d, turn, steps, sessionId, t }: { d: any; turn: RecordedTurn; steps: RecordedStep[]; sessionId: string; t: T }) {+ const a = d.attrs || {};+ const kind = KIND_CLASS[d.kind] || "ctx";+ const started = clock(d.started_at - turn.started_at);+ const ctxStep = steps.find((s) => s.kind === "context");+ const exchanges = (d.exchange_rebuilt || []) as any[];+ const exact = exchanges.length > 0 && (+ <details className="steps-exchange">+ <summary>{t("steps.exchange", { count: exchanges.length })}</summary>+ {exchanges.map((x: any, i: number) => (+ <pre className="steps-box" key={i}>{JSON.stringify(x.request, null, 2)}{"\n\n"}{x.response}</pre>+ ))}+ </details>+ );+if (d.kind === "model") {- rows.push([t("steps.detail.model"), [a.model, a.provider_title].filter(Boolean).join(" · ")]);- if (a.provider_facts?.served_model) rows.push([t("steps.detail.served"), a.provider_facts.served_model]);- if (a.ttft_ms != null) rows.push([t("steps.detail.ttft"), formatDuration(a.ttft_ms)]);- if (a.finish_reason) rows.push([t("steps.detail.stopped"), a.finish_reason]);- if (a.tools_offered) rows.push([t("steps.detail.tools"), `${a.tools_offered} · ${a.tools_hash || ""}`]);- if (turn.stamp?.persona_fp) rows.push([t("steps.detail.coworker"), `ⓕ${turn.stamp.persona_fp}`]);+ const mains = steps.filter((s) => s.kind === "model" && (s.attrs?.purpose || "main") === (a.purpose || "main") && !s.parent_step_id);+ const n = mains.findIndex((s) => s.step_id === d.step_id) + 1;+ const title = (a.purpose || "main") === "main" && n > 0+ ? t("steps.insp.model_call", { n, total: mains.length })+ : stepLabel(d, t);+ const attempts = exchanges.filter((x) => !x.auxiliary).length;+ const why = a.error+ ? t("steps.flag.failed", { type: t(`steps.error_type.${a.error.type}`, { defaultValue: a.error.type }) })+ : a.finish_reason ? t("steps.insp.stopped_because", { why: t(`steps.finish.${a.finish_reason}`, { defaultValue: a.finish_reason }) }) : "";const facts = a.provider_facts || {};- if (facts.provider_request_id) rows.push([t("steps.detail.request_id"), facts.provider_request_id]);- if (facts.provider_response_id) rows.push([t("steps.detail.response_id"), facts.provider_response_id]);- const attempts = (d.exchange_rebuilt || []).filter((x: any) => !x.auxiliary).length;- if (attempts > 1) rows.push([t("steps.detail.attempts"), attempts]);- if (a.error) rows.push([t("steps.detail.error"), `${t(`steps.error_type.${a.error.type}`, { defaultValue: a.error.type })}${a.error.text ? ` · ${a.error.text}` : ""}`]);+ const u = a.usage;+ const lines = inputLines(exchanges.find((x) => !x.auxiliary)?.request);+ return (+ <>+ <h3 className="steps-h3"><span className={`steps-kind k-${kind}`} />{title}<span className="steps-pill">{t("steps.insp.step", { n: d.seq ?? "—" })}</span></h3>+ <div className="steps-meta">+ {[a.provider_title || a.provider ? t("steps.insp.via", { model: a.model, provider: a.provider_title || a.provider }) : a.model, t("steps.insp.started", { at: started }), why].filter(Boolean).join(" · ")}+ </div>+ <Kv rows={[+ [t("steps.detail.duration"), <>{formatDuration(d.duration_ms)}{a.ttft_ms != null && <span className="steps-faint"> ({t("steps.insp.first_reply", { t: formatDuration(a.ttft_ms) })})</span>}</>],+ [t("steps.detail.attempts"), attempts <= 1 ? t("steps.insp.attempt_one") : t("steps.insp.attempt_many", { n: attempts, retries: attempts - 1 })],+ ...(facts.served_model && facts.served_model !== String(a.model || "").split(":").pop()+ ? [[t("steps.detail.served"), facts.served_model] as [string, React.ReactNode]] : []),+ ...(ctxStep?.attrs?.session_prompt_hash+ ? [[t("steps.detail.session_prompt"), <><span className="steps-mono">{ctxStep.attrs.session_prompt_hash}</span> <span className="steps-faint">{t("steps.insp.session_prompt_note")}</span></>] as [string, React.ReactNode]] : []),+ ...(turn.stamp?.persona_fp+ ? [[t("steps.detail.coworker"), <><span className="steps-mono">ⓕ{turn.stamp.persona_fp}</span> <span className="steps-faint">{t("steps.insp.coworker_note")}</span></>] as [string, React.ReactNode]] : []),+ [t("steps.detail.tools"), a.tools_offered ? <>{t("steps.insp.tools_n", { count: a.tools_offered })} <span className="steps-mono steps-faint">set·{a.tools_hash || "—"}</span></> : "0"],+ ...(facts.provider_request_id ? [[t("steps.detail.request_id"), <span className="steps-mono">{facts.provider_request_id}</span>] as [string, React.ReactNode]] : []),+ ...(facts.provider_response_id ? [[t("steps.detail.response_id"), <span className="steps-mono">{facts.provider_response_id}</span>] as [string, React.ReactNode]] : []),+ ...(a.error ? [[t("steps.detail.error"), `${t(`steps.error_type.${a.error.type}`, { defaultValue: a.error.type })}${a.error.text ? ` · ${a.error.text}` : ""}`] as [string, React.ReactNode]] : []),+ ]} />+ {u && (+ <>+ <Sec label={t("steps.insp.tokens")} right={u.reported ? t("steps.insp.in_out", {+ in: formatTokens((u.cache_read || 0) + (u.cache_write || 0) + (u.input_fresh || 0)), out: formatTokens(u.output || 0) }) : undefined} />+ <TokenBar u={u} t={t} />+ </>+ )}+ {(a.purpose || "main") === "main" && ctxStep && (+ <>+ <Sec label={t("steps.insp.context_added")} />+ <ContextAdded ctx={ctxStep.attrs} t={t} />+ </>+ )}+ {lines.length > 0 && <InputBox lines={lines} t={t} />}+ {(d.message?.content || d.message?.tool_calls?.length) && (+ <>+ <Sec label={t("steps.insp.output")} />+ <div className="steps-box">+ {[d.message.content ? `${d.message.content}${d.message.cut ? "\n…" : ""}` : "",+ ...(d.message.tool_calls || []).map((c: any) => `→ ${t("steps.insp.tool_call")}: ${c.name} ${c.arguments}`)].filter(Boolean).join("\n")}+ </div>+ </>+ )}+ {exact}+ </>+ );}+if (d.kind === "tool") {- if (a.risk_class) rows.push([t("steps.detail.risk"), t(`steps.risk.${a.risk_class}`, { defaultValue: a.risk_class })]);- if (a.exit_code != null) rows.push([t("steps.detail.exit"), a.exit_code]);- if (a.result_bytes != null) rows.push([t("steps.detail.result_size"), formatBytes(a.result_bytes)]);- if (a.decision?.origin) rows.push([t("steps.detail.origin"), t(`steps.origin.${a.decision.origin}`, { defaultValue: a.decision.origin })]);- if (a.sandbox) rows.push([t("steps.detail.blocked"), a.sandbox.blocked_known ? a.sandbox.blocked_count : t("steps.detail.unknown")]);- if (d.call_id) rows.push([t("steps.detail.call_id"), d.call_id]);+ const pill = statusPill(d, t);+ const path = a.decision?.path || [];+ const check = steps.find((s) => s.kind === "auto_approver" && !s.shadow && s.call_id === d.call_id);+ const wait = d.wait;+ const right = (stage: string): string => {+ if (stage === "auto_approver" && check) return formatDuration(check.duration_ms);+ if (stage === "card" && wait) return clock(wait.started_at - turn.started_at);+ if (stage === "resolved" && wait && wait.duration_ms != null) return clock(wait.started_at + wait.duration_ms - turn.started_at);+ return "";+ };+ const mode = turn.approval_mode ? t(MODE_KEYS[turn.approval_mode] || "", { defaultValue: turn.approval_mode }) : "";+ const who = turn.reviewer?.active ? reviewerLabel(turn.reviewer, t) : "";+ return (+ <>+ <h3 className="steps-h3"><span className={`steps-kind k-${kind}`} />{d.name}<span className={`steps-pill ${pill.cls}`}>{pill.text}</span></h3>+ <div className="steps-meta">+ {[a.risk_class ? t(`steps.risk.${a.risk_class}`, { defaultValue: a.risk_class }) : "",+ d.call_id ? `${t("steps.detail.call_id")} ${d.call_id}` : "",+ mode ? `${t("steps.detail.mode")} ${mode}${who ? ` (${t("steps.reviewer_is", { who })})` : ""}` : ""].filter(Boolean).join(" · ")}+ </div>+ <Kv rows={[+ [t("steps.insp.ran_for"), formatDuration(d.duration_ms)],+ ...(wait ? [[t("steps.insp.waited"), formatDuration(wait.duration_ms)] as [string, React.ReactNode]] : []),+ ...(a.result_bytes != null ? [[t("steps.detail.result_size"), formatBytes(a.result_bytes)] as [string, React.ReactNode]] : []),+ ...(a.exit_code != null ? [[t("steps.detail.exit"), String(a.exit_code)] as [string, React.ReactNode]] : []),+ ...(a.decision?.origin ? [[t("steps.detail.origin"), t(`steps.origin.${a.decision.origin}`, { defaultValue: a.decision.origin })] as [string, React.ReactNode]] : []),+ ...(a.sandbox ? [[t("steps.detail.blocked"), a.sandbox.blocked_known ? String(a.sandbox.blocked_count) : t("steps.detail.unknown")] as [string, React.ReactNode]] : []),+ ]} />+ {path.length > 0 && (+ <>+ <Sec label={t("steps.insp.how_allowed")} />+ <ol className="steps-ctxlist steps-path">+ {path.map((p: any, i: number) => {+ const last = i === path.length - 1;+ const good = last && /^approved|allow|grant|session_grant|gate_tier|readonly_tier/.test(p.outcome);+ return (+ <li key={i}>+ <span className={"steps-pill" + (good ? " ok" : "")}>{i + 1}</span>+ <span className="steps-c">{t(`steps.stage.${p.stage}`, { defaultValue: p.stage })}: <b>{t(`steps.outcome.${p.outcome}`, { defaultValue: p.outcome })}</b>+ {p.detail ? <span className="steps-faint"> ({t(`steps.origin.${p.detail}`, { defaultValue: p.detail })})</span> : null}</span>+ <span className="steps-sz">{right(p.stage)}</span>+ </li>+ );+ })}+ </ol>+ </>+ )}+ {d.arguments != null && (+ <>+ <Sec label={t("steps.insp.arguments")} />+ <div className="steps-box">{typeof d.arguments === "string" ? d.arguments : JSON.stringify(d.arguments, null, 2)}</div>+ </>+ )}+ {d.message?.content && (+ <>+ <Sec label={t("steps.insp.result")} />+ <div className="steps-box">{d.message.content}{d.message.cut ? "\n…" : ""}</div>+ </>+ )}+ <Joined audit={d.audit} t={t} />+ </>+ );}++ if (d.kind === "auto_approver") return <CheckInspector d={d} turn={turn} sessionId={sessionId} t={t} />;++ // Waits, summaries, context steps and notices.+ const pill = statusPill(d, t);+ const rows: [string, React.ReactNode][] = [+ [t("steps.detail.started"), started],+ [t("steps.detail.duration"), formatDuration(d.duration_ms)],+ ];if (d.kind === "wait") {rows.push([t("steps.detail.where"), t(`steps.where.${a.where}`, { defaultValue: a.where })],- [t("steps.detail.outcome"), a.outcome == null ? null : t(`steps.outcome.${a.outcome}`, { defaultValue: a.outcome })]);+ [t("steps.detail.outcome"), a.outcome == null ? "—" : t(`steps.outcome.${a.outcome}`, { defaultValue: a.outcome })]);if (d.content?.resolved_by) rows.push([t("steps.detail.answered_by"), d.content.resolved_by]);}- if (d.kind === "auto_approver") {- rows.push([t("steps.detail.mode"), t(`steps.check_mode.${a.mode}`, { defaultValue: a.mode })], [t("steps.detail.reviewer"), a.reviewer?.model || a.reviewer?.kind]);- if (a.breaker) {- rows.push([t("steps.detail.breaker"), a.breaker.tripped ? t("steps.detail.breaker_tripped", { n: a.breaker.denials_in_row })- : String(a.breaker.denials_in_row ?? 0)]);- }- if (a.matched_user != null) rows.push([t("steps.detail.matched_user"), a.matched_user ? t("steps.detail.yes") : t("steps.detail.no")]);- if (d.content?.reason) rows.push([t("steps.detail.reason"), d.content.reason]);- }if (d.kind === "summary") {if (a.reason) rows.push([t("steps.detail.summary_reason"), t(`steps.summary_reason.${a.reason}`, { defaultValue: a.reason })]);rows.push([t("steps.detail.tokens_before"), a.tokens_before == null ? "—" : formatTokens(a.tokens_before)],[t("steps.detail.tokens_after"), a.tokens_after == null ? "—" : formatTokens(a.tokens_after)]);}- if (d.kind === "context") {- rows.push([t("steps.detail.session_prompt"), a.session_prompt_hash || "—"]);- }- // What the context held: the context step, and a "context changed" notice (the block now).- if (d.kind === "context" || (d.kind === "notice" && d.name === "context_changed")) {- const start = a.session_start, pt = a.per_turn;- if (start) {- rows.push([t("steps.detail.memories"), `${(start.memories || []).length}${start.memory_mode === "index" ? ` · ${t("steps.detail.as_index")}` : ""}`]);- rows.push([t("steps.detail.rules"), start.rules ?? 0], [t("steps.detail.agents_md"), start.agents_md ?? 0]);- }- if (pt) {- rows.push([t("steps.detail.folders"), pt.folders ?? 0]);- if (pt.mode_note) rows.push([t("steps.detail.mode_note"), pt.mode_note]);- rows.push([t("steps.detail.skills"), pt.skills_menu ? `${pt.skills_menu} · ${pt.skills_hash || ""}` : 0]);- rows.push([t("steps.detail.sandbox_note"), pt.sandbox_note ? t("steps.detail.yes") : t("steps.detail.no")]);- }- if (a.size_chars != null) rows.push([t("steps.detail.size"), `${a.size_chars} · ${a.block_hash || "—"}`]);- }- const u = a.usage;+ if (d.kind === "context") rows.push([t("steps.detail.session_prompt"), <span className="steps-mono">{a.session_prompt_hash || "—"}</span>]);+ const showsContext = d.kind === "context" || (d.kind === "notice" && d.name === "context_changed");return (- <div className="steps-details" data-testid="steps-details">- <h4>{stepLabel(d, t)}</h4>- <dl>- {rows.map(([k, v]) => (- <div key={k}><dt>{k}</dt><dd>{String(v ?? "—")}</dd></div>- ))}- </dl>- {u && (- <div className="steps-tokens" data-testid="steps-tokens">- {u.reported ? (- <span>- {t("steps.tokens_line", {- cache: formatTokens(u.cache_read || 0),- written: u.cache_write == null ? "—" : formatTokens(u.cache_write),- fresh: formatTokens(u.input_fresh || 0),- out: formatTokens(u.output || 0),- })}- {u.reasoning != null && ` · ${t("steps.reasoning", { n: formatTokens(u.reasoning) })}`}- </span>- ) : (- <span>{t("steps.tokens_not_reported")}</span>- )}- </div>- )}- {Array.isArray(d.content?.questions) && d.content.questions.length > 0 && (- <ol className="steps-path" data-testid="steps-questions">- {d.content.questions.map((q: any) => (- <li key={q.name}>{q.name}: {t(`steps.detail.${q.answer === "yes" ? "yes" : "no"}`)}{q.score != null ? ` (${q.score.toFixed(2)})` : ""}</li>- ))}- </ol>+ <>+ <h3 className="steps-h3"><span className={`steps-kind k-${kind}`} />{stepLabel(d, t)}<span className={`steps-pill ${pill.cls}`}>{pill.text}</span></h3>+ <Kv rows={rows} />+ {showsContext && (+ <>+ <Sec label={d.kind === "context" ? t("steps.insp.context_added") : t("steps.insp.context_now")} />+ <ContextAdded ctx={a} t={t} />+ </>)}- {a.decision?.path && (- <ol className="steps-path">- {a.decision.path.map((p: any, i: number) => (- <li key={i}>{t(`steps.stage.${p.stage}`, { defaultValue: p.stage })}: {t(`steps.outcome.${p.outcome}`, { defaultValue: p.outcome })}{p.detail ? ` (${t(`steps.origin.${p.detail}`, { defaultValue: p.detail })})` : ""}</li>- ))}- </ol>+ {d.children?.length > 0 && (+ <>+ <Sec label={t("steps.insp.inside")} />+ <div className="steps-ctxlist">+ {d.children.map((c: any) => (+ <div key={c.step_id}><span className={`steps-kind k-${KIND_CLASS[c.kind] || "ctx"}`} /><span className="steps-c">{stepLabel(c, t)}</span><span className="steps-sz">{formatDuration(c.duration_ms)}</span></div>+ ))}+ </div>+ </>)}- {d.message && d.message.content && (- <pre className="steps-pre">{d.message.content}{d.message.cut ? "\n…" : ""}</pre>+ {exact}+ </>+ );+}++function InputBox({ lines, t }: { lines: string[]; t: T }) {+ const [all, setAll] = useState(false);+ const shown = all ? lines : lines.slice(-3);+ return (+ <>+ <Sec+ label={all ? t("steps.insp.input_all", { total: lines.length }) : t("steps.insp.input_last", { n: shown.length, total: lines.length })}+ right={lines.length > 3 ? <button className="steps-btn" onClick={() => setAll(!all)}>{all ? t("steps.insp.show_less") : t("steps.insp.show_all")}</button> : undefined}+ />+ <div className={"steps-box" + (all ? " tall" : "")}>{shown.join("\n\n")}</div>+ </>+ );+}++function CheckInspector({ d, turn, sessionId, t }: { d: any; turn: RecordedTurn; sessionId: string; t: T }) {+ const a = d.attrs || {};+ const result = d.status === "error" ? "could_not_run" : a.result;+ const inner = (d.children || []).find((c: any) => c.kind === "model");+ const [shown, setShown] = useState<string>("");+ useEffect(() => {+ let live = true;+ if (inner) {+ getStepDetail(sessionId, inner.step_id).then((x) => {+ if (!live || !x) return;+ const lines = inputLines((x.exchange_rebuilt || []).find((e: any) => !e.auxiliary)?.request);+ const users = lines.filter((l) => !l.startsWith("system ·") && !l.startsWith("developer ·"));+ setShown((users.length ? users : lines).slice(-1).join(""));+ }).catch(() => {});+ }+ return () => {+ live = false;+ };+ }, [sessionId, inner?.step_id]); // eslint-disable-line react-hooks/exhaustive-deps+ const pillCls = result === "allow" ? "ok" : result === "deny" || result === "could_not_run" ? "danger" : "warn";+ const reviewer = reviewerLabel(a.reviewer, t) || reviewerLabel(turn.reviewer, t);+ const target = d.for_step;+ const action = target ? `${target.name}${d.arguments?.command ? ` ${d.arguments.command}` : ""}` : d.name;+ const u = inner?.attrs?.usage;+ const tokens = u?.reported+ ? t("steps.insp.check_tokens", { in: formatTokens((u.cache_read || 0) + (u.cache_write || 0) + (u.input_fresh || 0)),+ cache: formatTokens(u.cache_read || 0), out: formatTokens(u.output || 0) })+ : inner ? t("steps.tokens_not_reported") : "—";+ const questions: any[] = Array.isArray(d.content?.questions) ? d.content.questions : [];+ const wait = d.wait;+ return (+ <>+ <h3 className="steps-h3">+ <span className="steps-kind k-review" />+ {d.shadow ? t("steps.insp.shadow_title") : t("steps.insp.check_title")}+ <span className={`steps-pill ${d.shadow ? "" : pillCls}`}>{d.shadow ? t("steps.check_mode.shadow") : t(`steps.result.${result}`, { defaultValue: result || "" })}</span>+ </h3>+ <div className="steps-meta">+ {[target ? t("steps.insp.for_step", { n: target.seq ?? "—", action }) : action, reviewer ? t("steps.reviewer_is", { who: reviewer }) : ""].filter(Boolean).join(" · ")}+ </div>+ {result === "could_not_run" && <div className="steps-callout err">{t("steps.insp.cnr")}</div>}+ <Kv rows={d.shadow ? [+ [t("steps.insp.would"), t(`steps.result.${result}`, { defaultValue: result || "" })],+ [t("steps.insp.you_decided"), wait ? <><b>{t(`steps.outcome.${wait.attrs?.outcome}`, { defaultValue: wait.attrs?.outcome || "—" })}</b> {t("steps.insp.after", { t: formatDuration(wait.duration_ms) })}</> : "—"],+ [t("steps.insp.match"), a.matched_user == null ? "—" : <span className={"steps-pill " + (a.matched_user ? "ok" : "warn")}>{a.matched_user ? t("steps.insp.matched") : t("steps.insp.not_matched")}</span>],+ [t("steps.insp.took"), formatDuration(d.duration_ms)],+ [t("steps.insp.tokens"), tokens],+ ] : [+ [t("steps.insp.result_label"), t(`steps.insp.result_${result}`, { defaultValue: t(`steps.result.${result}`, { defaultValue: result || "—" }) })],+ ...(d.content?.reason ? [[t("steps.detail.reason"), `"${d.content.reason}"`] as [string, React.ReactNode]] : []),+ [t("steps.insp.took"), formatDuration(d.duration_ms)],+ [t("steps.insp.tokens"), tokens],+ ...(a.breaker ? [[t("steps.detail.breaker"), a.breaker.tripped+ ? t("steps.insp.breaker_paused", { n: a.breaker.denials_in_row })+ : t("steps.insp.breaker_armed", { n: a.breaker.denials_in_row ?? 0 })] as [string, React.ReactNode]] : []),+ ]} />+ {questions.length > 0 && (+ <>+ <Sec label={t("steps.insp.questions")} />+ <table className="steps-qtable" data-testid="steps-questions">+ <thead><tr><th>{t("steps.insp.question")}</th><th>{t("steps.insp.answer")}</th></tr></thead>+ <tbody>+ {questions.map((q) => (+ <tr key={q.name}><td className="steps-mono">{q.name}</td><td>{t(`steps.detail.${q.answer === "yes" ? "yes" : "no"}`)}{q.score != null ? ` ${q.score.toFixed(2)}` : ""}</td></tr>+ ))}+ </tbody>+ </table>+ {a.reviewer?.external && <div className="steps-callout info">{t("steps.insp.outside", { name: reviewer })}</div>}+ </>)}- {d.exchange_rebuilt?.length > 0 && (- <details className="steps-exchange">- <summary>{t("steps.exchange", { count: d.exchange_rebuilt.length })}</summary>- {d.exchange_rebuilt.map((x: any, i: number) => (- <pre className="steps-pre" key={i}>{JSON.stringify(x.request, null, 2)}{"\n\n"}{x.response}</pre>- ))}- </details>+ {shown && (+ <>+ <Sec label={t("steps.insp.shown")} />+ <div className="steps-box">{shown}</div>+ </>)}- </div>+ <Joined audit={d.audit} t={t} />+ </>);}+// -- usage (OB-4) --------------------------------------------------------------------------------++const PURPOSE_CLASS: Record<string, string> = { main: "c-new", helper: "c-new", summary: "c-sum", auto_approver: "c-out", title: "c-faint" };+function UsageView({ sessionId, refreshKey }: { sessionId: string; refreshKey: number }) {const { t } = useTranslation();const [u, setU] = useState<any>(null);@@ -487,10 +814,12 @@ function UsageView({ sessionId, refreshKey }: { sessionId: string; refreshKey: n};}, [sessionId, refreshKey]);if (!u) return <div className="steps-usage">{t("steps.loading")}</div>;- const purposes = Object.entries(u.by_purpose || {}) as [string, number][];+ const purposes = (Object.entries(u.by_purpose || {}) as [string, number][]).sort((x, y) => y[1] - x[1]);const max = Math.max(1, ...purposes.map(([, n]) => n));return (<div className="steps-usage" data-testid="steps-usage">+ <div className="steps-seclbl steps-usage-title">{t("steps.usage.title")}<span className="steps-sp" />+ {u.turns != null && <span className="steps-seclbl-right">{t("steps.usage.turns", { count: u.turns })}</span>}</div><div className="steps-tiles"><Tile value={(u.at_least ? "≥ " : "") + formatTokens(u.totals?.input || 0)} label={t("steps.usage.input")} /><Tile value={formatTokens(u.totals?.output || 0)} label={t("steps.usage.output")} />@@ -499,32 +828,37 @@ function UsageView({ sessionId, refreshKey }: { sessionId: string; refreshKey: n{u.unreported_calls > 0 && <p className="steps-line">{t("steps.usage.unreported", { count: u.unreported_calls })}</p>}{u.failed_calls > 0 && <p className="steps-line">{t("steps.usage.failed", { count: u.failed_calls })}</p>}{u.overflow_calls > 0 && <p className="steps-line">{t("steps.usage.overflow", { count: u.overflow_calls })}</p>}- <h4>{t("steps.usage.by_purpose")}</h4>- {purposes.map(([p, n]) => (- <div className="steps-purpose" key={p}>- <span>{t(`steps.purpose_long.${p}`, { defaultValue: p })}</span>- <span>{formatTokens(n)}</span>- <span className="steps-purpose-bar"><span style={{ width: `${(n / max) * 100}%` }} /></span>- </div>- ))}- <h4>{t("steps.usage.by_model")}</h4>+ <Sec label={t("steps.usage.by_purpose")} />+ <div className="steps-purposes">+ {purposes.map(([p, n]) => (+ <div className="steps-purpose" key={p}>+ <span>{t(`steps.purpose_long.${p}`, { defaultValue: p })}</span>+ <span className="steps-num">{formatTokens(n)}</span>+ <span className="steps-purpose-bar"><i className={PURPOSE_CLASS[p] || "c-new"} style={{ width: `${Math.max(2, (n / max) * 100)}%` }} /></span>+ </div>+ ))}+ </div>+ <Sec label={t("steps.usage.by_model")} /><table className="steps-models"><thead><tr><th>{t("steps.usage.model")}</th><th>{t("steps.usage.in")}</th><th>{t("steps.usage.cache")}</th><th>{t("steps.usage.out")}</th></tr></thead><tbody>- {Object.entries(u.by_model_parts || {}).map(([m, p]: [string, any]) => (- <tr key={m}><td>{m}</td><td>{formatTokens(p.input)}</td><td>{formatTokens(p.cache)}</td><td>{formatTokens(p.output)}</td></tr>- ))}+ {Object.entries(u.by_model_parts || {}).map(([m, p]: [string, any]) => {+ const [model, purpose] = m.split(" (");+ return (+ <tr key={m}><td>{model}{purpose && <span className="steps-faint"> ({purpose}</span>}</td><td>{formatTokens(p.input)}</td><td>{formatTokens(p.cache)}</td><td>{formatTokens(p.output)}</td></tr>+ );+ })}</tbody></table>{u.context && u.context.window ? (<>- <h4>{t("steps.usage.context_now")}</h4>- <div className="steps-purpose-bar wide"><span style={{ width: `${Math.min(100, (u.context.tokens / u.context.window) * 100)}%` }} /></div>+ <Sec label={t("steps.usage.context_now")} />+ <div className="steps-purpose-bar wide"><i className="c-new" style={{ width: `${Math.min(100, (u.context.tokens / u.context.window) * 100)}%` }} /></div><p className="steps-line">{t("steps.usage.context_line", { used: formatTokens(u.context.tokens), window: formatTokens(u.context.window) })}</p></>) : u.context?.tokens ? (<>- <h4>{t("steps.usage.context_now")}</h4>+ <Sec label={t("steps.usage.context_now")} /><p className="steps-line">{t("steps.usage.context_no_window", { used: formatTokens(u.context.tokens) })}</p></>) : null}diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex 0beff1a3..17421ede 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -3043,6 +3043,84 @@"prev_turn": "Previous turn","next_turn": "Next turn","turn_of": "Turn {{n}} of {{total}}",+ "reviewer_is": "reviewer {{who}}",+ "finish": {+ "stop": "it finished its answer",+ "tool_calls": "it asked for a tool",+ "length": "it reached the output limit",+ "content_filter": "the provider's filter stopped it"+ },+ "axis": {+ "step": "Step",+ "time": "Time"+ },+ "insp": {+ "close": "Close details",+ "model_call": "Model call {{n}} of {{total}}",+ "step": "step {{n}}",+ "via": "{{model}} via {{provider}}",+ "started": "started {{at}}",+ "stopped_because": "stopped because {{why}}",+ "first_reply": "first reply after {{t}}",+ "attempt_one": "1 of 1 · no retries",+ "attempt_many": "{{n}} · {{retries}} retried",+ "session_prompt_note": "same all session",+ "coworker_note": "this coworker's instructions",+ "tools_n_one": "{{count}} tool",+ "tools_n_other": "{{count}} tools",+ "tokens": "Tokens",+ "in_out": "{{in}} in · {{out}} out",+ "from_cache": "from cache {{n}}",+ "written": "written to cache {{n}}",+ "new": "new {{n}}",+ "out": "out {{n}}",+ "out_reasoning": "out {{n}} (thinking {{r}})",+ "context_added": "What was added to the context this turn",+ "context_now": "The context now",+ "block": "block",+ "input_last": "Input (last {{n}} of {{total}} messages)",+ "input_all": "Input (all {{total}} messages)",+ "show_all": "Show all",+ "show_less": "Show less",+ "output": "Output",+ "tool_call": "tool call",+ "done": "done",+ "ran_for": "Ran for",+ "waited": "Waited for approval",+ "how_allowed": "How it was allowed",+ "arguments": "Arguments",+ "result": "Result",+ "joined": "Joined records",+ "joined_line_one": "{{count}} audit row",+ "joined_line_other": "{{count}} audit rows",+ "same_call": "same call id",+ "inside": "Inside this step",+ "check_title": "Auto-approver check",+ "shadow_title": "Shadow check",+ "for_step": "For step {{n}} · {{action}}",+ "cnr": "The reviewer could not run, so the action was shown to you instead.",+ "result_label": "Result",+ "result_allow": "Allowed without asking you",+ "result_deny": "Blocked",+ "result_unsure": "Not sure, so it asked you",+ "result_could_not_run": "Could not run, so it asked you",+ "result_context_changed": "Something changed while it checked, so it asked you",+ "took": "Took",+ "check_tokens": "{{in}} in ({{cache}} from cache) · {{out}} out",+ "breaker_armed": "{{n}} refusals in a row (pauses at 3)",+ "breaker_paused": "{{n}} refusals in a row · Auto-approve paused",+ "questions": "Questions it answered",+ "question": "Question",+ "answer": "Answer",+ "outside": "{{name}} is an outside service: it answers these questions; the action itself is not sent as text.",+ "shown": "What the reviewer was shown",+ "would": "Reviewer would have",+ "you_decided": "You decided",+ "after": "after {{t}}",+ "match": "Match",+ "matched": "same as you",+ "not_matched": "different from you"+ },"loading": "Loading…","load_error": "Steps could not be loaded.","not_recorded": "No recorded steps yet. Steps are recorded for turns run from now on.",@@ -3319,6 +3397,9 @@"output": "Output","from_cache": "From cache","by_purpose": "By purpose",+ "title": "Token usage",+ "turns_one": "{{count}} turn",+ "turns_other": "{{count}} turns","by_model": "By model","model": "Model","in": "In",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex b320edde..60dc3e08 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -2999,6 +2999,82 @@"prev_turn": "上一轮","next_turn": "下一轮","turn_of": "第 {{n}} 轮,共 {{total}} 轮",+ "reviewer_is": "审查者 {{who}}",+ "finish": {+ "stop": "回答已完成",+ "tool_calls": "它请求调用工具",+ "length": "达到输出上限",+ "content_filter": "被提供方的过滤器停止"+ },+ "axis": {+ "step": "步骤",+ "time": "用时"+ },+ "insp": {+ "close": "关闭详情",+ "model_call": "模型调用 {{n}} / {{total}}",+ "step": "第 {{n}} 步",+ "via": "{{model}},经由 {{provider}}",+ "started": "开始于 {{at}}",+ "stopped_because": "停止原因:{{why}}",+ "first_reply": "首次回复 {{t}}",+ "attempt_one": "1 / 1 · 没有重试",+ "attempt_many": "{{n}} 次 · 重试 {{retries}} 次",+ "session_prompt_note": "整个会话相同",+ "coworker_note": "这位同事的指令",+ "tools_n_other": "{{count}} 个工具",+ "tokens": "令牌",+ "in_out": "输入 {{in}} · 输出 {{out}}",+ "from_cache": "来自缓存 {{n}}",+ "written": "写入缓存 {{n}}",+ "new": "新输入 {{n}}",+ "out": "输出 {{n}}",+ "out_reasoning": "输出 {{n}}(思考 {{r}})",+ "context_added": "这一轮加入上下文的内容",+ "context_now": "当前上下文",+ "block": "区块",+ "input_last": "输入(共 {{total}} 条消息中的最后 {{n}} 条)",+ "input_all": "输入(全部 {{total}} 条消息)",+ "show_all": "全部显示",+ "show_less": "收起",+ "output": "输出",+ "tool_call": "工具调用",+ "done": "完成",+ "ran_for": "运行时长",+ "waited": "等待批准",+ "how_allowed": "如何获得允许",+ "arguments": "参数",+ "result": "结果",+ "joined": "关联记录",+ "joined_line_other": "{{count}} 条审计记录",+ "same_call": "相同调用 id",+ "inside": "此步骤内部",+ "check_title": "自动批准检查",+ "shadow_title": "影子检查",+ "for_step": "针对第 {{n}} 步 · {{action}}",+ "cnr": "审查者无法运行,因此改为向你显示此操作。",+ "result_label": "结果",+ "result_allow": "未询问你就允许了",+ "result_deny": "已阻止",+ "result_unsure": "不确定,因此询问了你",+ "result_could_not_run": "无法运行,因此询问了你",+ "result_context_changed": "检查时有变化,因此询问了你",+ "took": "用时",+ "check_tokens": "输入 {{in}}(缓存 {{cache}})· 输出 {{out}}",+ "breaker_armed": "连续拒绝 {{n}} 次(3 次时暂停)",+ "breaker_paused": "连续拒绝 {{n}} 次 · 自动批准已暂停",+ "questions": "它回答的问题",+ "question": "问题",+ "answer": "回答",+ "outside": "{{name}} 是外部服务:它回答这些问题;操作本身不会以文本形式发送。",+ "shown": "审查者看到的内容",+ "would": "审查者本会",+ "you_decided": "你的决定",+ "after": "{{t}} 后",+ "match": "是否一致",+ "matched": "与你相同",+ "not_matched": "与你不同"+ },"loading": "加载中…","load_error": "无法加载步骤。","not_recorded": "还没有记录的步骤。从现在起运行的轮次会被记录。",@@ -3273,6 +3349,8 @@"output": "输出","from_cache": "来自缓存","by_purpose": "按用途",+ "title": "令牌用量",+ "turns_other": "{{count}} 轮","by_model": "按模型","model": "模型","in": "输入",diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.cssindex d3835316..4fcb9cb6 100644--- a/surfaces/gui/src/styles.css+++ b/surfaces/gui/src/styles.css@@ -2427,65 +2427,142 @@ html[data-platform="linux"] ::-webkit-scrollbar-thumb:hover { background-color:.app.tauri-overlay.macos-26 .sim-traffic-lights { top: 14px; }.app.tauri-overlay.macos-26 .sim-traffic-lights span { width: 14px; height: 14px; }-/* Observability Phase 1 (UX-059 OB-1, OB-2, OB-4): the Steps panel in the right rail. */-.steps-panel .team-pane-header strong { font-size:var(--fs-body); }-.steps-turn-picker { display:flex; align-items:center; gap:4px; color:var(--muted); font-size:var(--fs-meta); }-.steps-turn-picker button { padding:2px 6px!important; }+/* Observability Phase 1 (UX-059 OB-1, OB-2, OB-11, OB-4): the Steps panel in the right rail,+ styled as the UX-059 mock (docs/ux-improvements/mocks/UX-059-observability-desktop.html).+ The step colours are the mock's --bar-* tokens, light and dark. */+:root { --bar-model:#2563eb; --bar-tool:#0f766e; --bar-wait:#d8dce1; --bar-review:#7c3aed; --bar-sum:#92400e; --bar-ctx:#6f7680; --bar-write:#f59e0b; }+html[data-theme="dark"] { --bar-model:#4c8dff; --bar-tool:#3fb8ad; --bar-wait:#3a3e46; --bar-review:#a78bfa; --bar-sum:#e8b04b; --bar-ctx:#9aa1ab; --bar-write:#f59e0b; }+.team-view.steps-panel { background:var(--panel); font-size:var(--fs-ui); line-height:1.45; container-type:inline-size; }+/* A step's details open beside the list: the rail widens to hold both (mock: list + 520px). */+.main:has(.steps-panel.inspecting) { --artifact-rail-w:min(78vw, 1180px); }+.steps-sp { flex:1; }+.steps-mono { font-family:var(--mono); font-size:var(--fs-mono); }+.steps-faint { color:var(--faint); }+.steps-railhead { padding:12px 14px 8px; border-bottom:1px solid var(--line); flex:none; }+.steps-railhead-title { display:flex; align-items:center; gap:8px; font-weight:600; }+.steps-railhead-title strong { font-size:var(--fs-ui); font-weight:600; }+.steps-turn-picker { display:flex; align-items:center; gap:2px; color:var(--muted); font-size:var(--fs-meta); font-weight:400; }+.steps-turn-picker button, .steps-close { border:0; background:none; color:var(--muted); cursor:pointer; border-radius:6px; padding:1px 6px; font:inherit; line-height:1.3; }+.steps-turn-picker button:hover:not(:disabled), .steps-close:hover { background:var(--paper); color:var(--ink); }.steps-turn-picker button:disabled { opacity:.35; cursor:default; }-.steps-body { flex:1; min-height:0; overflow:auto; padding:12px 14px 20px; }-.steps-stamp { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; padding:8px 14px 0; font-size:var(--fs-meta); color:var(--muted); }-.steps-mode { padding:1px 8px; border-radius:999px; background:var(--chrome-hover); color:var(--ink); white-space:nowrap; }+.steps-close { font-size:var(--fs-meta); }+.steps-stamp { display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; margin-top:6px; font-size:var(--fs-meta); color:var(--faint); }.steps-stamp-line { min-width:0; overflow-wrap:anywhere; }+.steps-pill { display:inline-flex; align-items:center; gap:5px; font-size:var(--fs-meta); font-weight:400; color:var(--muted); border:1px solid var(--line); border-radius:999px; padding:2px 9px; background:var(--panel); white-space:nowrap; flex:none; }+.steps-pill.on, .steps-pill.steps-mode { border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }+.steps-pill.review { border-color:color-mix(in srgb, var(--bar-review) 45%, transparent); color:var(--bar-review); background:color-mix(in srgb, var(--bar-review) 10%, var(--panel)); }+.steps-pill.ok { border-color:var(--ok-line); color:var(--ok); background:var(--ok-soft); }+.steps-pill.warn { border-color:color-mix(in srgb, var(--warn-ink) 35%, transparent); color:var(--warn-ink); background:var(--warn-soft); }+.steps-pill.danger { border-color:color-mix(in srgb, var(--danger) 30%, transparent); color:var(--danger); background:var(--danger-soft); }+.steps-tiles { display:grid; grid-template-columns:repeat(auto-fill, minmax(92px, 1fr)); gap:6px; margin-top:10px; }+.steps-tile { background:var(--paper); border-radius:8px; padding:6px 8px; min-width:0; }+.steps-tile strong { display:block; font-size:14px; font-weight:600; color:var(--ink); font-variant-numeric:tabular-nums; }+.steps-tile span { font-size:var(--fs-label); color:var(--faint); }+.steps-line { margin:8px 0 0; font-size:var(--fs-meta); color:var(--faint); }+.steps-tabs { display:flex; gap:2px; margin-top:8px; }+.steps-tabs button { font:inherit; font-size:var(--fs-meta); padding:4px 9px; border:0; border-radius:7px; background:none; color:var(--muted); cursor:pointer; }+.steps-tabs button[aria-selected="true"] { background:var(--paper); color:var(--ink); font-weight:500; }.steps-empty { padding:16px 14px; color:var(--muted); font-size:var(--fs-ui); }-.steps-tiles { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin-bottom:10px; }-.steps-tile { background:var(--chrome-hover); border-radius:8px; padding:9px 10px; display:flex; flex-direction:column; gap:2px; }-.steps-tile strong { font-size:var(--fs-body); color:var(--ink); }-.steps-tile span { font-size:var(--fs-meta); color:var(--muted); }-.steps-line { margin:4px 0 8px; font-size:var(--fs-meta); color:var(--muted); }-.steps-tabs { margin:6px 0 8px; }+.steps-railbody { flex:1; min-height:0; overflow:auto; padding:6px 0; }+.steps-split { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) min(520px, 62%); }+.steps-split .steps-list { border-right:1px solid var(--line); }++/* The timeline (OB-1): one row per step on the turn's time axis. */.steps-timeline { display:flex; flex-direction:column; }-.steps-row { display:grid; grid-template-columns:10px minmax(0,1.3fr) minmax(0,1fr) 52px; align-items:center; gap:8px; width:100%; min-height:30px; border:0; border-radius:6px; background:none; color:var(--ink); text-align:left; cursor:pointer; font-size:var(--fs-ui); }-.steps-row:hover { background:var(--chrome-hover); }-.steps-row.selected { background:color-mix(in srgb, var(--accent) 12%, transparent); }-.steps-row.shadow { opacity:.7; }-.steps-dot { width:9px; height:9px; border-radius:2px; background:var(--faint); }-.steps-row.kind-model .steps-dot,.steps-row.kind-model .steps-bar { background:#2563eb; }-.steps-row.kind-tool .steps-dot,.steps-row.kind-tool .steps-bar { background:#0f766e; }-.steps-row.kind-auto_approver .steps-dot,.steps-row.kind-auto_approver .steps-bar { background:#7c3aed; }-.steps-row.kind-summary .steps-dot,.steps-row.kind-summary .steps-bar { background:#9a3412; }-.steps-row.kind-wait .steps-bar { background:repeating-linear-gradient(135deg,var(--line-strong) 0 4px,transparent 4px 8px); }-.steps-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }-.steps-badge { margin-left:6px; padding:1px 6px; border-radius:6px; font-size:var(--fs-label); background:var(--chrome-hover); color:var(--muted); }-.steps-badge.err { background:color-mix(in srgb,#dc2626 14%,transparent); color:#b91c1c; }-.steps-badge.warn { background:color-mix(in srgb,#d97706 16%,transparent); color:#b45309; }-.steps-track { position:relative; height:10px; border-left:1px solid var(--line); }-.steps-bar { position:absolute; top:1px; height:8px; min-width:3px; border-radius:3px; background:var(--faint); }-.steps-time { text-align:right; color:var(--muted); font-size:var(--fs-meta); font-variant-numeric:tabular-nums; }-.steps-details { margin:8px 0 4px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); font-size:var(--fs-ui); }-.steps-details h4,.steps-usage h4 { margin:4px 0 8px; font-size:var(--fs-ui); font-weight:600; color:var(--ink); }-.steps-details dl { margin:0; display:grid; gap:4px; }-.steps-details dl div { display:grid; grid-template-columns:130px minmax(0,1fr); gap:8px; }-.steps-details dt { color:var(--muted); }-.steps-details dd { margin:0; overflow-wrap:anywhere; }-.steps-tokens { margin:8px 0; color:var(--muted); font-size:var(--fs-meta); }-.steps-path { margin:6px 0; padding-left:18px; color:var(--muted); font-size:var(--fs-meta); }-.steps-pre { margin:8px 0 0; padding:8px 10px; max-height:240px; overflow:auto; background:var(--chrome-hover); border-radius:6px; font-size:var(--fs-meta); white-space:pre-wrap; overflow-wrap:anywhere; }-.steps-exchange summary { margin-top:8px; cursor:pointer; color:var(--muted); font-size:var(--fs-meta); }-/* A narrow rail (phone width, or a small window): stack each detail's label above its value,- two tiles a row, and a shorter time track, so nothing wraps one letter per line. */-.steps-panel { container-type:inline-size; }-@container (max-width: 360px) {- .steps-tiles { grid-template-columns:repeat(2,minmax(0,1fr)); }- .steps-row { grid-template-columns:10px minmax(0,1fr) 40px 44px; gap:6px; }- .steps-details dl div { grid-template-columns:minmax(0,1fr); gap:0; }- .steps-body { padding:10px 10px 16px; }-}-.steps-purpose { display:grid; grid-template-columns:minmax(0,1fr) 64px 90px; gap:8px; align-items:center; padding:6px 0; border-bottom:1px solid var(--line); font-size:var(--fs-ui); }-.steps-purpose > span:nth-child(2) { text-align:right; font-variant-numeric:tabular-nums; }-.steps-purpose-bar { height:6px; border-radius:3px; background:var(--chrome-hover); overflow:hidden; display:block; }-.steps-purpose-bar span { display:block; height:100%; background:#2563eb; border-radius:3px; }-.steps-purpose-bar.wide { margin:4px 0; }-.steps-models { width:100%; border-collapse:collapse; font-size:var(--fs-ui); }-.steps-models th,.steps-models td { padding:6px 4px; border-bottom:1px solid var(--line); text-align:right; }-.steps-models th:first-child,.steps-models td:first-child { text-align:left; overflow-wrap:anywhere; }-.steps-models th { color:var(--muted); font-weight:500; }+.steps-axis, .steps-row { display:grid; grid-template-columns:minmax(178px, 30%) minmax(0,1fr) 64px; }+.steps-axis { font-size:10.5px; color:var(--faint); padding:4px 14px 2px; }+.steps-ticks { display:flex; justify-content:space-between; }+.steps-axis-time { text-align:right; }+.steps-row { align-items:center; width:100%; padding:4px 14px; border:0; border-left:2px solid transparent; background:none; color:var(--ink); font:inherit; font-size:var(--fs-meta); text-align:left; cursor:pointer; }+.steps-row:hover { background:var(--paper); }+.steps-row.selected { background:var(--accent-soft); border-left-color:var(--accent); }+.steps-row.shadow .steps-bar { opacity:.55; }+.steps-label { display:flex; align-items:center; gap:6px; min-width:0; padding-right:8px; }+.steps-name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:0 0 auto; max-width:100%; min-width:0; }+.steps-kind { width:8px; height:8px; border-radius:2px; flex:none; background:var(--bar-ctx); }+.k-model .steps-kind, .steps-kind.k-model, .k-model .steps-bar { background:var(--bar-model); }+.k-tool .steps-kind, .steps-kind.k-tool, .k-tool .steps-bar { background:var(--bar-tool); }+.k-review .steps-kind, .steps-kind.k-review, .k-review .steps-bar { background:var(--bar-review); }+.k-sum .steps-kind, .steps-kind.k-sum, .k-sum .steps-bar { background:var(--bar-sum); }+.k-ctx .steps-kind, .steps-kind.k-ctx, .k-ctx .steps-bar { background:var(--bar-ctx); }+.k-wait .steps-kind, .steps-kind.k-wait { background:var(--bar-wait); outline:1px dashed var(--faint); }+.steps-track { position:relative; height:12px; background:repeating-linear-gradient(90deg, transparent 0 24.6%, var(--line) 24.6% 25%); }+.steps-bar { position:absolute; top:2px; height:8px; min-width:3px; border-radius:3px; background:var(--bar-ctx); }+.k-wait .steps-bar { background:repeating-linear-gradient(45deg, var(--bar-wait) 0 4px, transparent 4px 7px); border:1px solid var(--line-strong); top:1px; height:10px; }+.steps-time { text-align:right; color:var(--muted); font-variant-numeric:tabular-nums; }+.steps-badge { font-size:10px; line-height:1.5; border-radius:4px; padding:0 4px; flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; background:var(--paper); color:var(--muted); }+.steps-badge.err { background:var(--danger-soft); color:var(--danger); }+.steps-badge.warn { background:var(--warn-soft); color:var(--warn-ink); }++/* One step's details (OB-2, OB-11): the inspector beside the list. */+.steps-insp { position:relative; padding:12px 14px 20px; overflow:auto; min-height:0; font-size:var(--fs-ui); }+.steps-insp-close { position:absolute; top:10px; right:10px; }+.steps-h3 { font-size:14px; font-weight:600; margin:0 0 2px; padding-right:28px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }+.steps-meta { color:var(--faint); font-size:var(--fs-meta); margin-bottom:10px; overflow-wrap:anywhere; }+.steps-kv { display:grid; grid-template-columns:130px minmax(0,1fr); gap:4px 10px; font-size:var(--fs-meta); margin:0 0 12px; }+.steps-kv div { display:contents; }+.steps-kv dt { color:var(--faint); }+.steps-kv dd { margin:0; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }+.steps-seclbl { font-size:var(--fs-label); font-weight:600; color:var(--faint); margin:14px 0 6px; display:flex; align-items:center; gap:8px; }+.steps-seclbl-right { font-weight:400; }+.steps-box { border:1px solid var(--line); border-radius:8px; background:var(--paper); padding:8px 10px; font-family:var(--mono); font-size:11.5px; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; color:var(--ink); max-height:150px; overflow:auto; margin:0; }+.steps-box.tall { max-height:420px; }+.steps-ctxlist { border:1px solid var(--line); border-radius:8px; overflow:hidden; margin:0; padding:0; list-style:none; }+.steps-ctxlist > div, .steps-ctxlist > li { display:flex; gap:8px; padding:6px 10px; border-top:1px solid var(--line); font-size:var(--fs-meta); align-items:center; }+.steps-ctxlist > :first-child { border-top:none; }+.steps-c { flex:1; min-width:0; overflow-wrap:anywhere; }+.steps-sz { margin-left:auto; color:var(--faint); font-variant-numeric:tabular-nums; white-space:nowrap; }+.steps-tokbar { display:flex; height:8px; border-radius:4px; overflow:hidden; background:var(--paper); margin:4px 0 6px; }+.steps-tokbar i { display:block; height:100%; }+.steps-tokbar .c-cache, .steps-purpose-bar .c-cache { background:var(--ok); }+.steps-tokbar .c-write { background:var(--bar-write); }+.steps-tokbar .c-new, .steps-purpose-bar .c-new { background:var(--accent); }+.steps-tokbar .c-out, .steps-purpose-bar .c-out { background:var(--bar-review); }+.steps-purpose-bar .c-sum { background:var(--bar-sum); }+.steps-purpose-bar .c-faint { background:var(--bar-ctx); }+.steps-legend { font-size:var(--fs-meta); color:var(--faint); }+.steps-legend .c-cache { color:var(--ok); }+.steps-legend .c-write { color:var(--warn-ink); }+.steps-legend .c-new { color:var(--accent); }+.steps-legend .c-out { color:var(--bar-review); }+.steps-callout { border-radius:8px; padding:8px 10px; font-size:var(--fs-meta); margin:8px 0; }+.steps-callout.warn { background:var(--warn-soft); color:var(--warn-ink); }+.steps-callout.err { background:var(--danger-soft); color:var(--danger); }+.steps-callout.info { background:var(--accent-soft); color:var(--accent); }+.steps-callout.ok { background:var(--ok-soft); color:var(--ok); }+.steps-btn { display:inline-flex; align-items:center; border:1px solid var(--line-strong); background:var(--panel); color:var(--ink); border-radius:8px; padding:2px 8px; font:inherit; font-size:var(--fs-meta); font-weight:400; cursor:pointer; }+.steps-btn:hover { border-color:var(--accent); }+.steps-small { font-size:var(--fs-meta); color:var(--muted); }+.steps-qtable, .steps-models { width:100%; border-collapse:collapse; font-size:var(--fs-meta); }+.steps-qtable th, .steps-qtable td, .steps-models th, .steps-models td { padding:5px 6px; border-bottom:1px solid var(--line); text-align:left; }+.steps-qtable th, .steps-models th { color:var(--faint); font-weight:500; }+.steps-models th:not(:first-child), .steps-models td:not(:first-child) { text-align:right; font-variant-numeric:tabular-nums; }+.steps-models td:first-child { overflow-wrap:anywhere; }+.steps-exchange { margin-top:14px; }+.steps-exchange summary { cursor:pointer; color:var(--faint); font-size:var(--fs-label); font-weight:600; margin-bottom:6px; }+.steps-exchange .steps-box { max-height:300px; margin-bottom:6px; }++/* Usage (OB-4). */+.steps-usage { padding:8px 14px 20px; }+.steps-usage-title { margin-top:4px; }+.steps-usage .steps-tiles { margin-top:0; }+.steps-purposes { border:1px solid var(--line); border-radius:8px; overflow:hidden; }+.steps-purpose { display:grid; grid-template-columns:minmax(0,1fr) 64px 110px; gap:8px; align-items:center; padding:6px 10px; border-top:1px solid var(--line); font-size:var(--fs-meta); }+.steps-purpose:first-child { border-top:none; }+.steps-num { text-align:right; font-variant-numeric:tabular-nums; color:var(--muted); }+.steps-purpose-bar { height:8px; border-radius:4px; background:var(--paper); overflow:hidden; display:block; }+.steps-purpose-bar i { display:block; height:100%; border-radius:4px; }+.steps-purpose-bar.wide { margin:4px 0 6px; }++/* A narrow rail (phone width, or a small window): details stack under the list, labels above+ their values, a shorter label column, so nothing wraps one letter per line. */+@container (max-width: 640px) {+ .steps-split { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(120px, 40%) minmax(0,1fr); }+ .steps-split .steps-list { border-right:0; border-bottom:1px solid var(--line); }+}+@container (max-width: 380px) {+ .steps-axis, .steps-row { grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) 44px; }+ .steps-row, .steps-axis { padding-left:10px; padding-right:10px; }+ .steps-kv { grid-template-columns:minmax(0,1fr); gap:0; }+ .steps-kv dd { margin-bottom:4px; }+}diff --git a/tests/test_observability_read_api.py b/tests/test_observability_read_api.pyindex d49567e9..9f35041e 100644--- a/tests/test_observability_read_api.py+++ b/tests/test_observability_read_api.py@@ -71,6 +71,9 @@ def test_a_recorded_turn_reads_back_through_the_endpoints(tmp_path):assert detail["message"]["role"] == "tool" and "Friday" in detail["message"]["content"]assert detail["message"]["mid"] == tool["message_id"]assert any(row.get("call_id") == "c1" for row in detail["audit"])+ # The details card's arguments come from the transcript's tool call (UX-059 OB-2).+ assert detail["arguments"] == {"path": "notes.txt"}+ assert "wait" not in detail # a low-risk read had no cardusage = client.get("/v1/sessions/r1/usage").json()assert usage["pill"] == turn["usage"]["pill"] and usage["at_least"] is False@@ -89,3 +92,26 @@ def test_a_session_recorded_before_phase_1_says_so(tmp_path):client = TestClient(create_app(manager))assert client.get("/v1/sessions/old/turns").json() == {"turns": []}assert client.get("/v1/sessions/old/usage").json()["recorded"] is False+++def test_a_tool_card_brings_its_wait_and_a_check_names_its_call():+ # UX-059 OB-2 / OB-11: the tool's card shows how long it waited on its approval card;+ # an auto-approver check names the call it judged.+ from coworker.observability import read_api++ def s(step_id, kind, name, **kw):+ return {"step_id": step_id, "turn_id": "t", "kind": kind, "name": name, "call_id": "c1",+ "parent_step_id": None, "attrs": kw.pop("attrs", {}), "content": {}, **kw}++ rec = {"turns": [{"turn_id": "t"}], "steps": [+ s("a", "auto_approver", "run_shell", attrs={"result": "unsure"}),+ s("w", "wait", "approval", duration_ms=2000, attrs={"for_call_id": "c1", "outcome": "approved"}),+ s("x", "tool", "run_shell", duration_ms=40),+ ]}+ messages = [{"role": "assistant", "tool_calls": [+ {"id": "c1", "type": "function", "function": {"name": "run_shell", "arguments": '{"command": "make"}'}}]}]+ kw = dict(get_piece=lambda k: None, messages=messages, audit_rows=lambda c: [])+ tool = read_api.step(rec, "x", **kw)+ assert tool["arguments"] == {"command": "make"} and tool["wait"]["duration_ms"] == 2000+ check = read_api.step(rec, "a", **kw)+ assert check["for_step"]["step_id"] == "x" and check["arguments"] == {"command": "make"}