Skip to content
Python

feat(gui): Steps panel with the timeline, step details and session usage (OPE-244)

Devika Vermaa6d7ebdaec9b
diff --git a/coworker/observability/read_api.py b/coworker/observability/read_api.py
index 9d4486ba..2b157822 100644
--- a/coworker/observability/read_api.py
+++ b/coworker/observability/read_api.py
@@ -86,6 +86,24 @@ def _cut(message: dict[str, Any]) -> dict[str, Any]:
def usage(recording: dict[str, Any], session_id: str) -> dict[str, Any]:
out = calculator.usage(recording, session_id)
out["recorded"] = bool(recording.get("turns"))
+ out["turns"] = len(recording.get("turns") or [])
+ # The popover's parts: input, from cache, output, per model row and in all (OB-4).
+ parts: dict[str, dict[str, int]] = {}
+ totals = {"input": 0, "cache": 0, "output": 0}
+ for s in recording.get("steps") or []:
+ a = s.get("attrs") or {}
+ u = a.get("usage") or {}
+ if s.get("kind") != "model" or not u.get("reported") or a.get("error") or a.get("purpose") == "proxy":
+ continue
+ p = a.get("purpose", "main")
+ key = a.get("model", "?") + ("" if p == "main" else f" ({p})")
+ row = parts.setdefault(key, {"input": 0, "cache": 0, "output": 0})
+ for target in (row, totals):
+ target["input"] += calculator.input_total(u)
+ target["cache"] += u.get("cache_read") or 0
+ target["output"] += u.get("output") or 0
+ out["by_model_parts"] = parts
+ out["totals"] = totals
# Context fill: the last main call's total input against its model's context window (M-R18).
last = next((s for s in reversed(recording.get("steps") or [])
if s.get("kind") == "model" and (s.get("attrs") or {}).get("purpose") == "main"
diff --git a/surfaces/gui/src/App.tsx b/surfaces/gui/src/App.tsx
index 6f65ed01..a5f03f87 100644
--- a/surfaces/gui/src/App.tsx
+++ b/surfaces/gui/src/App.tsx
@@ -111,6 +111,7 @@ import { ConnectorRequestCard } from "./components/ConnectorRequestCard";
import { DirectoryRequestCard } from "./components/DirectoryRequestCard";
import { PlanCard } from "./components/PlanCard";
import { TeamView, TeamQuickLook } from "./components/TeamView";
+import { StepsPanel } from "./components/StepsPanel";
import type { WorkerFilter } from "./teamRoster";
import type { TeamSummary } from "./teamView";
import { getTeamSummary } from "./api";
@@ -414,6 +415,10 @@ export function App() {
boardSessionRef.current = sessionId;
const [boardOwner, setBoardOwner] = useState("");
const [teamViewOpen, setTeamViewOpen] = useState(false);
+ // Observability (UX-059 OB-1): the Steps panel takes the rail's full-view slot, like the
+ // team view; `stepsKey` moves on live step events and at a turn's end so it follows along.
+ const [stepsOpen, setStepsOpen] = useState(false);
+ const [stepsKey, setStepsKey] = useState(0);
const [teamWorkerId, setTeamWorkerId] = useState<string | null>(null);
const [teamWorkerFilter, setTeamWorkerFilter] = useState<WorkerFilter | null>(null);
const [teamSummary, setTeamSummary] = useState<TeamSummary | null>(null);
@@ -1154,8 +1159,13 @@ export function App() {
{ kind: "notice", tone: "warn", text: d.error || t("app.notice.input_rejected") },
]);
break;
+ case "step":
+ // Recording events for the Steps panel (batched by the server every 100 ms).
+ setStepsKey((k) => k + 1);
+ break;
case "turn_done":
setRunning(false);
+ setStepsKey((k) => k + 1);
setReviewerPaused(false); // the pause is scoped to the turn
refreshSessions();
// Catch-all artifact refresh: files created via shell or on a brand-new session (whose
@@ -2233,6 +2243,23 @@ export function App() {
{surface === "session" && (
<SandboxChip info={sandboxInfo} onOpenSettings={() => openSettings("sandbox")} />
)}
+ {/* UX-059 OB-1: every step of each turn, and where the time and tokens went. */}
+ {surface === "session" && agent !== "chat" && (
+ <button
+ className={"topbar-artifacts-btn" + (stepsOpen ? " active" : "")}
+ onMouseDown={(e) => e.stopPropagation()}
+ onClick={() => {
+ setStepsOpen(!stepsOpen);
+ setTeamViewOpen(false);
+ setRailHidden(false);
+ }}
+ title={t("steps.open_title")}
+ aria-pressed={stepsOpen}
+ data-testid="steps-open"
+ >
+ <span>{t("steps.open")}</span>
+ </button>
+ )}
{/* §32: the panel toggle is the ONE session-panel entry, for every non-chat persona
(the rail now carries Access, so code-family gets it too). */}
{agent !== "chat" && (
@@ -2604,7 +2631,7 @@ export function App() {
/>
</div>
<RightRail
- teamView={teamViewOpen ? <TeamView openKey={boardRailKey} board={boardOwner === sessionId ? board : null} summary={teamSummary?.lead_session === sessionId ? teamSummary : null} initialItem={boardDetailId} initialWorkerId={teamWorkerId} initialWorkerFilter={teamWorkerFilter} onOpenFullSession={(id) => { const w = sessions.find(s => s.session_id === id); if (w) void selectSession(w.session_id, w.workspace, w.agent); }} sessionId={sessionId} sessions={sessions} machine={machine} machineName={curSession?.machine_name} onClose={() => { setTeamViewOpen(false); setBoardDetailId(null); setTeamWorkerId(null); setTeamWorkerFilter(null); }} onRefresh={() => { void refreshBoard(); setBrowserRefreshKey(k => k + 1); }} /> : undefined}
+ teamView={stepsOpen && sessionId ? <StepsPanel sessionId={sessionId} refreshKey={stepsKey} onClose={() => setStepsOpen(false)} /> : teamViewOpen ? <TeamView openKey={boardRailKey} board={boardOwner === sessionId ? board : null} summary={teamSummary?.lead_session === sessionId ? teamSummary : null} initialItem={boardDetailId} initialWorkerId={teamWorkerId} initialWorkerFilter={teamWorkerFilter} onOpenFullSession={(id) => { const w = sessions.find(s => s.session_id === id); if (w) void selectSession(w.session_id, w.workspace, w.agent); }} sessionId={sessionId} sessions={sessions} machine={machine} machineName={curSession?.machine_name} onClose={() => { setTeamViewOpen(false); setBoardDetailId(null); setTeamWorkerId(null); setTeamWorkerFilter(null); }} onRefresh={() => { void refreshBoard(); setBrowserRefreshKey(k => k + 1); }} /> : undefined}
active={surface === "session" && agent !== "chat" && !railHidden}
sessionId={sessionId}
refreshKey={browserRefreshKey}
diff --git a/surfaces/gui/src/api.ts b/surfaces/gui/src/api.ts
index a0af6c6f..e4488d5f 100644
--- a/surfaces/gui/src/api.ts
+++ b/surfaces/gui/src/api.ts
@@ -4385,3 +4385,60 @@ export async function forgetConnectorOnMachine(sourceMachineId: string, name: st
);
return res.json();
}
+
+// -- Observability (Phase 1): recorded turns and steps of a session ----------------------------
+// Served by the engine (technical design §12); `sessionApiBase` reaches a remote machine's
+// session through the machine proxy, like the transcript.
+
+export interface RecordedTurn {
+ turn_id: string;
+ seq: number;
+ kind: string;
+ trigger: string;
+ status: string;
+ started_at: number;
+ duration_ms: number | null;
+ stamp: Record<string, any>;
+ buckets: Record<string, any>;
+ usage: Record<string, any>;
+}
+
+export interface RecordedStep {
+ step_id: string;
+ turn_id: string | null;
+ parent_step_id: string | null;
+ seq: number | null;
+ kind: string;
+ name: string;
+ started_at: number;
+ duration_ms: number | null;
+ status: string;
+ call_id: string | null;
+ message_id: string | null;
+ shadow: boolean;
+ after_turn: boolean;
+ attrs: Record<string, any>;
+ content?: Record<string, any>;
+}
+
+async function recordingGet(sessionId: string, path: string): Promise<any> {
+ const res = await fetch(`${sessionApiBase(sessionId)}/v1/sessions/${encodeURIComponent(sessionId)}${path}`);
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ return res.json();
+}
+
+export async function getRecordedTurns(sessionId: string): Promise<RecordedTurn[]> {
+ return (await recordingGet(sessionId, "/turns")).turns ?? [];
+}
+
+export async function getTurnSteps(sessionId: string, turnId: string): Promise<RecordedStep[]> {
+ return (await recordingGet(sessionId, `/turns/${encodeURIComponent(turnId)}/steps`)).steps ?? [];
+}
+
+export async function getStepDetail(sessionId: string, stepId: string): Promise<any> {
+ return (await recordingGet(sessionId, `/steps/${encodeURIComponent(stepId)}`)).step ?? null;
+}
+
+export async function getRecordedUsage(sessionId: string): Promise<any> {
+ return recordingGet(sessionId, "/usage");
+}
diff --git a/surfaces/gui/src/components/StepsPanel.test.tsx b/surfaces/gui/src/components/StepsPanel.test.tsx
new file mode 100644
index 00000000..29822f33
--- /dev/null
+++ b/surfaces/gui/src/components/StepsPanel.test.tsx
@@ -0,0 +1,112 @@
+// Observability Phase 1 (UX-059 OB-1, OB-2, OB-4): the Steps panel reads the recording.
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { getRecordedTurns, getRecordedUsage, getStepDetail, getTurnSteps } from "../api";
+import { StepsPanel, formatDuration } from "./StepsPanel";
+
+vi.mock("../api", () => ({
+ getRecordedTurns: vi.fn(),
+ getTurnSteps: vi.fn(),
+ getStepDetail: vi.fn(),
+ getRecordedUsage: vi.fn(),
+}));
+
+const turn = {
+ turn_id: "t1", seq: 1, kind: "run", trigger: "user", status: "completed", started_at: 1000,
+ duration_ms: 10_000, stamp: {},
+ buckets: { total: 10_000, waiting: 4000, tools: 2000, model: 3000, auto_approver: 0, summary: 0, other: 1000, other_shown: true },
+ usage: { pill: 2077 },
+};
+
+const step = (over: Record<string, any>) => ({
+ step_id: "s", turn_id: "t1", parent_step_id: null, seq: 1, kind: "tool", name: "read_file",
+ started_at: 1000, duration_ms: 100, status: "ok", call_id: null, message_id: null, shadow: false,
+ after_turn: false, attrs: {}, ...over,
+});
+
+const steps = [
+ step({ step_id: "c", kind: "context", name: "context", duration_ms: 0 }),
+ step({ step_id: "m1", kind: "model", name: "model", duration_ms: 3000,
+ attrs: { purpose: "main", usage: { reported: true, input_fresh: 100, cache_read: 900, cache_write: null, output: 10, reasoning: null } } }),
+ step({ step_id: "a1", kind: "auto_approver", name: "run_shell", started_at: 4000, attrs: { result: "allow", mode: "live" } }),
+ step({ step_id: "w1", kind: "wait", name: "approval", started_at: 4100, duration_ms: 4000, attrs: { kind: "approval", where: "session", outcome: "approved" } }),
+ step({ step_id: "x1", kind: "tool", name: "run_shell", started_at: 8100, duration_ms: 2000, status: "error" }),
+ step({ step_id: "h1", kind: "model", name: "model", parent_step_id: "x1", started_at: 8200, attrs: { purpose: "helper" } }),
+];
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("StepsPanel", () => {
+ it("shows where the time went, every step on one axis, and nested helper steps", async () => {
+ vi.mocked(getRecordedTurns).mockResolvedValue([turn] as any);
+ vi.mocked(getTurnSteps).mockResolvedValue(steps as any);
+ render(<StepsPanel sessionId="s1" onClose={() => {}} />);
+
+ await screen.findByText("Turn 1 of 1");
+ const tiles = screen.getByTestId("steps-tiles").textContent || "";
+ // Total, every bucket that is not zero, and Other (it is 10% here).
+ expect(tiles).toContain("10s");
+ expect(tiles).toContain("Waiting for you");
+ expect(tiles).toContain("Other");
+ expect(tiles).not.toContain("Auto-approver");
+ await waitFor(() => expect(screen.getAllByTestId("steps-row")).toHaveLength(6));
+ const labels = screen.getAllByTestId("steps-row").map((r) => r.textContent);
+ expect(labels[0]).toContain("Context built");
+ expect(labels[2]).toContain("Auto-approver · allowed");
+ expect(labels[3]).toContain("Waiting for you · approval");
+ expect(labels[4]).toContain("error");
+ expect(labels[5]).toContain("Model · helper"); // right under its explore tool step
+ expect(screen.getByTestId("steps-checks").textContent).toContain("1 check · 1 allowed");
+ });
+
+ it("opens a step's details with its tokens", async () => {
+ vi.mocked(getRecordedTurns).mockResolvedValue([turn] as any);
+ vi.mocked(getTurnSteps).mockResolvedValue(steps as any);
+ vi.mocked(getStepDetail).mockResolvedValue({ ...steps[1], attrs: { ...steps[1].attrs, model: "openai:model-a", finish_reason: "tool_calls" } });
+ render(<StepsPanel sessionId="s1" onClose={() => {}} />);
+ await waitFor(() => expect(screen.getAllByTestId("steps-row")).toHaveLength(6));
+ fireEvent.click(screen.getAllByTestId("steps-row")[1]);
+ 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");
+ });
+
+ it("shows the session's usage by purpose and model", async () => {
+ vi.mocked(getRecordedTurns).mockResolvedValue([turn] as any);
+ vi.mocked(getTurnSteps).mockResolvedValue(steps as any);
+ vi.mocked(getRecordedUsage).mockResolvedValue({
+ pill: 2077, at_least: true, unreported_calls: 1, failed_calls: 0, overflow_calls: 0, cache_share: 0.94,
+ by_purpose: { main: 2035, title: 42 }, totals: { input: 2060, cache: 1900, output: 17 },
+ by_model_parts: { "openai:model-a": { input: 2020, cache: 1900, output: 15 } },
+ context: { tokens: 1020, window: 200000 },
+ });
+ render(<StepsPanel sessionId="s1" onClose={() => {}} />);
+ fireEvent.click(await screen.findByRole("tab", { name: "Usage" }));
+ const usage = await screen.findByTestId("steps-usage");
+ expect(usage.textContent).toContain("≥ 2.1k");
+ expect(usage.textContent).toContain("94%");
+ expect(usage.textContent).toContain("Main work");
+ expect(usage.textContent).toContain("Session title");
+ expect(usage.textContent).toContain("1 call did not report usage");
+ });
+
+ it("says when a session has no recorded steps", async () => {
+ vi.mocked(getRecordedTurns).mockResolvedValue([]);
+ render(<StepsPanel sessionId="old" onClose={() => {}} />);
+ expect((await screen.findByTestId("steps-none")).textContent).toContain("No recorded steps yet");
+ });
+});
+
+describe("formatDuration", () => {
+ it("reads like the mock", () => {
+ expect(formatDuration(100)).toBe("0.1s");
+ expect(formatDuration(3400)).toBe("3.4s");
+ expect(formatDuration(41_000)).toBe("41s");
+ expect(formatDuration(134_000)).toBe("2m 14s");
+ expect(formatDuration(null)).toBe("—");
+ });
+});
diff --git a/surfaces/gui/src/components/StepsPanel.tsx b/surfaces/gui/src/components/StepsPanel.tsx
new file mode 100644
index 00000000..756be783
--- /dev/null
+++ b/surfaces/gui/src/components/StepsPanel.tsx
@@ -0,0 +1,361 @@
+// 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.
+
+import { useEffect, useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+import {
+ getRecordedTurns,
+ getRecordedUsage,
+ getStepDetail,
+ getTurnSteps,
+ type RecordedStep,
+ type RecordedTurn,
+} from "../api";
+import { formatTokens } from "../usage";
+
+const BUCKETS = ["waiting", "tools", "model", "auto_approver", "summary"] as const;
+
+/** 0.1s, 3.4s, 41s, 2m 14s: the panel's one duration format. */
+export function formatDuration(ms: number | null | undefined): string {
+ if (ms == null || !Number.isFinite(ms)) return "—";
+ if (ms < 10_000) return `${(ms / 1000).toFixed(1)}s`;
+ if (ms < 60_000) return `${Math.round(ms / 1000)}s`;
+ const m = Math.floor(ms / 60_000);
+ const s = Math.round((ms % 60_000) / 1000);
+ return s ? `${m}m ${s}s` : `${m}m`;
+}
+
+/** 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 {
+ const a = step.attrs || {};
+ switch (step.kind) {
+ case "context":
+ return t("steps.row.context");
+ case "model": {
+ const purpose = a.purpose && a.purpose !== "main" ? ` · ${t(`steps.purpose.${a.purpose}`, { defaultValue: a.purpose })}` : "";
+ return t("steps.row.model") + purpose;
+ }
+ case "wait":
+ return `${t("steps.row.wait")} · ${t(`steps.wait.${a.kind}`, { defaultValue: a.kind || "" })}`;
+ case "auto_approver":
+ return `${t("steps.row.auto_approver")} · ${t(`steps.result.${a.result}`, { defaultValue: a.result || "" })}`;
+ case "summary": {
+ const before = a.tokens_before, after = a.tokens_after;
+ const arrow = before != null && after != null ? ` · ${formatTokens(before)}→${formatTokens(after)}` : "";
+ return (step.name === "trim" ? t("steps.row.trim") : t("steps.row.summary")) + arrow;
+ }
+ case "notice":
+ return t(`steps.notice.${step.name}`, { defaultValue: step.name });
+ default:
+ return step.name;
+ }
+}
+
+/** Steps in canonical order, each nested child right under its parent. */
+function nest(steps: RecordedStep[]): { step: RecordedStep; depth: number }[] {
+ const ids = new Set(steps.map((s) => s.step_id));
+ const children = new Map<string, RecordedStep[]>();
+ for (const s of steps) {
+ if (s.parent_step_id && ids.has(s.parent_step_id)) {
+ children.set(s.parent_step_id, [...(children.get(s.parent_step_id) || []), s]);
+ }
+ }
+ const out: { step: RecordedStep; depth: number }[] = [];
+ const walk = (s: RecordedStep, depth: number) => {
+ out.push({ step: s, depth });
+ for (const c of children.get(s.step_id) || []) walk(c, depth + 1);
+ };
+ for (const s of steps) if (!s.parent_step_id || !ids.has(s.parent_step_id)) walk(s, 0);
+ return out;
+}
+
+export function StepsPanel({
+ sessionId,
+ refreshKey = 0,
+ onClose,
+}: {
+ sessionId: string;
+ refreshKey?: number;
+ onClose: () => void;
+}) {
+ const { t } = useTranslation();
+ const [turns, setTurns] = useState<RecordedTurn[] | null>(null);
+ const [turnIdx, setTurnIdx] = useState<number | null>(null);
+ const [steps, setSteps] = useState<RecordedStep[]>([]);
+ const [tab, setTab] = useState<"timeline" | "usage">("timeline");
+ const [selected, setSelected] = useState<string | null>(null);
+ const [error, setError] = useState(false);
+
+ useEffect(() => {
+ let live = true;
+ getRecordedTurns(sessionId)
+ .then((ts) => {
+ if (!live) return;
+ setTurns(ts);
+ setError(false);
+ // Follow the newest turn unless one was picked.
+ setTurnIdx((i) => (i == null || i >= ts.length - 1 ? ts.length - 1 : i));
+ })
+ .catch(() => live && setError(true));
+ return () => {
+ live = false;
+ };
+ }, [sessionId, refreshKey]);
+
+ const turn = turns && turnIdx != null && turnIdx >= 0 ? turns[turnIdx] : null;
+ useEffect(() => {
+ if (!turn) return;
+ let live = true;
+ getTurnSteps(sessionId, turn.turn_id).then((s) => live && setSteps(s)).catch(() => {});
+ return () => {
+ live = false;
+ };
+ }, [sessionId, turn?.turn_id, refreshKey]);
+
+ const rows = useMemo(() => nest(steps), [steps]);
+ const checks = steps.filter((s) => s.kind === "auto_approver" && !s.shadow);
+
+ 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>
+ </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")} />}
+ </div>
+ {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,
+ })}
+ </p>
+ )}
+ <div className="team-tabs 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>
+
+ {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} />}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function Tile({ value, label }: { value: string; label: string }) {
+ return (
+ <div className="steps-tile">
+ <strong>{value}</strong>
+ <span>{label}</span>
+ </div>
+ );
+}
+
+function StepRow({ step, depth, turn, label, selected, onSelect }: {
+ step: RecordedStep; depth: number; turn: RecordedTurn; 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 bad = ["error", "denied", "interrupted", "skipped"].includes(step.status);
+ return (
+ <button
+ className={`steps-row kind-${step.kind}` + (selected ? " selected" : "") + (step.shadow ? " shadow" : "")}
+ style={{ paddingLeft: 8 + depth * 14 }}
+ onClick={onSelect}
+ data-testid="steps-row"
+ >
+ <span className="steps-dot" />
+ <span className="steps-label">
+ {label}
+ {bad && <span className={`steps-badge ${step.status}`}>{t(`steps.status.${step.status}`)}</span>}
+ {step.after_turn && <span className="steps-badge">{t("steps.after_turn")}</span>}
+ </span>
+ <span className="steps-track">
+ <span className="steps-bar" style={{ left: `${left}%`, width: width ? `${width}%` : undefined }} />
+ </span>
+ <span className="steps-time">{formatDuration(step.duration_ms)}</span>
+ </button>
+ );
+}
+
+function StepDetails({ sessionId, stepId, turn }: { sessionId: string; stepId: string; turn: RecordedTurn }) {
+ const { t } = useTranslation();
+ const [d, setD] = useState<any>(null);
+ useEffect(() => {
+ let live = true;
+ 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>;
+ 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 === "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 (a.error) rows.push([t("steps.detail.error"), `${a.error.type}${a.error.text ? ` · ${a.error.text}` : ""}`]);
+ }
+ if (d.kind === "tool") {
+ if (a.risk_class) rows.push([t("steps.detail.risk"), a.risk_class]);
+ if (a.exit_code != null) rows.push([t("steps.detail.exit"), a.exit_code]);
+ 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.kind === "wait") {
+ rows.push([t("steps.detail.where"), a.where], [t("steps.detail.outcome"), 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"), a.mode], [t("steps.detail.reviewer"), a.reviewer?.model || a.reviewer?.kind]);
+ if (d.content?.reason) rows.push([t("steps.detail.reason"), d.content.reason]);
+ }
+ if (d.kind === "context") {
+ rows.push([t("steps.detail.session_prompt"), a.session_prompt_hash || "—"], [t("steps.detail.size"), a.size_chars]);
+ }
+ const u = a.usage;
+ 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>
+ )}
+ {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 })}: {p.outcome}{p.detail ? ` (${p.detail})` : ""}</li>
+ ))}
+ </ol>
+ )}
+ {d.message && (
+ <pre className="steps-pre">{d.message.content}{d.message.cut ? "\n…" : ""}</pre>
+ )}
+ {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>
+ )}
+ </div>
+ );
+}
+
+function UsageView({ sessionId, refreshKey }: { sessionId: string; refreshKey: number }) {
+ const { t } = useTranslation();
+ const [u, setU] = useState<any>(null);
+ useEffect(() => {
+ let live = true;
+ getRecordedUsage(sessionId).then((x) => live && setU(x)).catch(() => {});
+ return () => {
+ live = false;
+ };
+ }, [sessionId, refreshKey]);
+ if (!u) return <div className="steps-usage">{t("steps.loading")}</div>;
+ const purposes = Object.entries(u.by_purpose || {}) as [string, number][];
+ const max = Math.max(1, ...purposes.map(([, n]) => n));
+ return (
+ <div className="steps-usage" data-testid="steps-usage">
+ <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")} />
+ <Tile value={u.cache_share == null ? "—" : `${Math.round(u.cache_share * 100)}%`} label={t("steps.usage.from_cache")} />
+ </div>
+ {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>
+ <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>
+ ))}
+ </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>
+ <p className="steps-line">{t("steps.usage.context_line", { used: formatTokens(u.context.tokens), window: formatTokens(u.context.window) })}</p>
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index 595455f0..4f2730db 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -3034,5 +3034,169 @@
"row": "Also fetch pages through {{name}}",
"caution": "{{name}} then sees the address of every page the agent opens."
}
+ },
+ "steps": {
+ "title": "Steps",
+ "open": "Steps",
+ "open_title": "Every step of each turn, and where the time and tokens went",
+ "close": "Close steps",
+ "prev_turn": "Previous turn",
+ "next_turn": "Next turn",
+ "turn_of": "Turn {{n}} of {{total}}",
+ "loading": "Loading…",
+ "load_error": "Steps could not be loaded.",
+ "not_recorded": "No recorded steps yet. Steps are recorded for turns run from now on.",
+ "tab": {
+ "timeline": "Timeline",
+ "usage": "Usage"
+ },
+ "bucket": {
+ "total": "Total",
+ "waiting": "Waiting for you",
+ "tools": "Tools",
+ "model": "Model",
+ "auto_approver": "Auto-approver",
+ "summary": "Summary",
+ "other": "Other"
+ },
+ "checks_line_one": "Auto-approve: {{count}} check · {{allowed}} allowed · {{asked}} asked you · {{blocked}} blocked",
+ "checks_line_other": "Auto-approve: {{count}} checks · {{allowed}} allowed · {{asked}} asked you · {{blocked}} blocked",
+ "row": {
+ "context": "Context built",
+ "model": "Model",
+ "wait": "Waiting for you",
+ "auto_approver": "Auto-approver",
+ "summary": "Summary",
+ "trim": "Trim"
+ },
+ "purpose": {
+ "main": "main",
+ "helper": "helper",
+ "summary": "summary",
+ "auto_approver": "auto-approver",
+ "title": "title",
+ "proxy": "proxy",
+ "unattributed": "unattributed"
+ },
+ "purpose_long": {
+ "main": "Main work",
+ "helper": "Helper agent (explore)",
+ "summary": "Summaries (compaction)",
+ "auto_approver": "Auto-approver",
+ "title": "Session title",
+ "unattributed": "Not attributed"
+ },
+ "wait": {
+ "approval": "approval",
+ "question": "question",
+ "plan": "plan",
+ "team": "team",
+ "items": "work items",
+ "connector": "connector",
+ "tool_install": "tool install",
+ "directory": "folder"
+ },
+ "result": {
+ "allow": "allowed",
+ "deny": "blocked",
+ "unsure": "asked you",
+ "could_not_run": "could not run",
+ "context_changed": "asked you (changed while checking)"
+ },
+ "notice": {
+ "error": "Error",
+ "interrupted": "Stopped",
+ "reviewer_paused": "Auto-approve paused",
+ "step_limit": "Step limit reached",
+ "truncated": "Reply cut off",
+ "context_changed": "Context changed",
+ "stamp_changed": "Settings changed",
+ "summary_failed": "Summary failed",
+ "recording_gap": "Recording gap"
+ },
+ "status": {
+ "ok": "ok",
+ "error": "error",
+ "denied": "refused",
+ "interrupted": "stopped",
+ "skipped": "skipped",
+ "running": "running",
+ "unknown": "unknown"
+ },
+ "after_turn": "after the turn",
+ "detail": {
+ "status": "Status",
+ "started": "Started at",
+ "duration": "Duration",
+ "model": "Model",
+ "served": "Answered by",
+ "ttft": "First reply after",
+ "stopped": "Stopped because",
+ "tools": "Tools offered",
+ "error": "Error",
+ "risk": "Risk",
+ "exit": "Exit code",
+ "origin": "Decided by",
+ "blocked": "Sites blocked",
+ "unknown": "unknown",
+ "where": "Shown in",
+ "outcome": "Outcome",
+ "answered_by": "Answered by",
+ "mode": "Mode",
+ "reviewer": "Reviewer",
+ "reason": "Reason",
+ "session_prompt": "Session prompt",
+ "size": "Context block size"
+ },
+ "origin": {
+ "low_risk": "low risk",
+ "bypass": "full access",
+ "config_allowlist": "your allowlist",
+ "session_grant": "allowed for this session",
+ "standing_rule": "a standing rule",
+ "trusted_rule": "your trust rule",
+ "trusted_server": "server trust",
+ "run_grant": "allowed for this request",
+ "allow_anyway": "you (allow anyway)",
+ "lead_denial": "the lead's denial",
+ "reviewer": "the auto-approver",
+ "user": "you",
+ "denied_by_rule": "a rule",
+ "reviewer_denied": "the auto-approver",
+ "unattended_auto": "attendance auto",
+ "readonly_tier": "read-only command",
+ "gate_tier": "safe change"
+ },
+ "stage": {
+ "permission": "Permission",
+ "grant": "Grant",
+ "auto_approver": "Auto-approver",
+ "card": "Card",
+ "resolved": "Answer"
+ },
+ "tokens_line": "from cache {{cache}} · written to cache {{written}} · new {{fresh}} · out {{out}}",
+ "reasoning": "of which reasoning {{n}}",
+ "tokens_not_reported": "The provider did not report tokens for this call.",
+ "exchange_one": "Exact request and response ({{count}} attempt)",
+ "exchange_other": "Exact request and response ({{count}} attempts)",
+ "usage": {
+ "input": "Input",
+ "output": "Output",
+ "from_cache": "From cache",
+ "by_purpose": "By purpose",
+ "by_model": "By model",
+ "model": "Model",
+ "in": "In",
+ "cache": "Cache",
+ "out": "Out",
+ "context_now": "Context now",
+ "context_line": "{{used}} of {{window}}",
+ "unreported_one": "{{count}} call did not report usage",
+ "unreported_other": "{{count}} calls did not report usage",
+ "failed_one": "{{count}} failed call (usage unknown)",
+ "failed_other": "{{count}} failed calls (usage unknown)",
+ "overflow_one": "{{count}} call was over the context limit and the conversation was summarised",
+ "overflow_other": "{{count}} calls were over the context limit and the conversation was summarised"
+ }
}
}
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 143d652f..b9fad4a1 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -2990,5 +2990,164 @@
"row": "也通过 {{name}} 抓取网页",
"caution": "{{name}} 届时会看到智能体打开的每个网页的地址。"
}
+ },
+ "steps": {
+ "title": "步骤",
+ "open": "步骤",
+ "open_title": "每一轮的每个步骤,以及时间和令牌用在了哪里",
+ "close": "关闭步骤",
+ "prev_turn": "上一轮",
+ "next_turn": "下一轮",
+ "turn_of": "第 {{n}} 轮,共 {{total}} 轮",
+ "loading": "加载中…",
+ "load_error": "无法加载步骤。",
+ "not_recorded": "还没有记录的步骤。从现在起运行的轮次会被记录。",
+ "tab": {
+ "timeline": "时间线",
+ "usage": "用量"
+ },
+ "bucket": {
+ "total": "总计",
+ "waiting": "等待你",
+ "tools": "工具",
+ "model": "模型",
+ "auto_approver": "自动审批",
+ "summary": "摘要",
+ "other": "其他"
+ },
+ "checks_line_other": "自动审批:{{count}} 次检查 · {{allowed}} 次允许 · {{asked}} 次询问你 · {{blocked}} 次阻止",
+ "row": {
+ "context": "构建上下文",
+ "model": "模型",
+ "wait": "等待你",
+ "auto_approver": "自动审批",
+ "summary": "摘要",
+ "trim": "裁剪"
+ },
+ "purpose": {
+ "main": "主要",
+ "helper": "助手",
+ "summary": "摘要",
+ "auto_approver": "自动审批",
+ "title": "标题",
+ "proxy": "代理",
+ "unattributed": "未归属"
+ },
+ "purpose_long": {
+ "main": "主要工作",
+ "helper": "助手代理(探索)",
+ "summary": "摘要(压缩)",
+ "auto_approver": "自动审批",
+ "title": "会话标题",
+ "unattributed": "未归属"
+ },
+ "wait": {
+ "approval": "审批",
+ "question": "问题",
+ "plan": "计划",
+ "team": "团队",
+ "items": "工作项",
+ "connector": "连接器",
+ "tool_install": "安装工具",
+ "directory": "文件夹"
+ },
+ "result": {
+ "allow": "已允许",
+ "deny": "已阻止",
+ "unsure": "询问你",
+ "could_not_run": "无法运行",
+ "context_changed": "询问你(检查时有变化)"
+ },
+ "notice": {
+ "error": "错误",
+ "interrupted": "已停止",
+ "reviewer_paused": "自动审批已暂停",
+ "step_limit": "达到步骤上限",
+ "truncated": "回复被截断",
+ "context_changed": "上下文已变化",
+ "stamp_changed": "设置已变化",
+ "summary_failed": "摘要失败",
+ "recording_gap": "记录缺口"
+ },
+ "status": {
+ "ok": "正常",
+ "error": "错误",
+ "denied": "已拒绝",
+ "interrupted": "已停止",
+ "skipped": "已跳过",
+ "running": "运行中",
+ "unknown": "未知"
+ },
+ "after_turn": "轮次结束后",
+ "detail": {
+ "status": "状态",
+ "started": "开始于",
+ "duration": "时长",
+ "model": "模型",
+ "served": "实际回答",
+ "ttft": "首次回复用时",
+ "stopped": "停止原因",
+ "tools": "提供的工具",
+ "error": "错误",
+ "risk": "风险",
+ "exit": "退出码",
+ "origin": "决定者",
+ "blocked": "被阻止的站点",
+ "unknown": "未知",
+ "where": "显示于",
+ "outcome": "结果",
+ "answered_by": "回答者",
+ "mode": "模式",
+ "reviewer": "审批者",
+ "reason": "原因",
+ "session_prompt": "会话提示词",
+ "size": "上下文块大小"
+ },
+ "origin": {
+ "low_risk": "低风险",
+ "bypass": "完全访问",
+ "config_allowlist": "你的允许列表",
+ "session_grant": "本会话已允许",
+ "standing_rule": "常设规则",
+ "trusted_rule": "你的信任规则",
+ "trusted_server": "服务器信任",
+ "run_grant": "本次请求已允许",
+ "allow_anyway": "你(仍然允许)",
+ "lead_denial": "负责人的拒绝",
+ "reviewer": "自动审批",
+ "user": "你",
+ "denied_by_rule": "规则",
+ "reviewer_denied": "自动审批",
+ "unattended_auto": "自动值守",
+ "readonly_tier": "只读命令",
+ "gate_tier": "安全更改"
+ },
+ "stage": {
+ "permission": "权限",
+ "grant": "授权",
+ "auto_approver": "自动审批",
+ "card": "卡片",
+ "resolved": "回答"
+ },
+ "tokens_line": "来自缓存 {{cache}} · 写入缓存 {{written}} · 新增 {{fresh}} · 输出 {{out}}",
+ "reasoning": "其中推理 {{n}}",
+ "tokens_not_reported": "提供方没有报告这次调用的令牌数。",
+ "exchange_other": "确切的请求和响应({{count}} 次尝试)",
+ "usage": {
+ "input": "输入",
+ "output": "输出",
+ "from_cache": "来自缓存",
+ "by_purpose": "按用途",
+ "by_model": "按模型",
+ "model": "模型",
+ "in": "输入",
+ "cache": "缓存",
+ "out": "输出",
+ "context_now": "当前上下文",
+ "context_line": "{{used}} / {{window}}",
+ "unreported_other": "{{count}} 次调用没有报告用量",
+ "failed_other": "{{count}} 次调用失败(用量未知)",
+ "overflow_other": "{{count}} 次调用超出上下文上限,对话已被摘要"
+ }
}
}
diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.css
index e89ed5d5..734c9916 100644
--- a/surfaces/gui/src/styles.css
+++ b/surfaces/gui/src/styles.css
@@ -2425,3 +2425,54 @@ html[data-platform="linux"] ::-webkit-scrollbar-thumb:hover { background-color:
.app.tauri-overlay.macos-26 .titlebar-drag { height: 42px; padding-top: 2px; }
.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; }
+.steps-turn-picker button:disabled { opacity:.35; cursor:default; }
+.steps-body { flex:1; min-height:0; overflow:auto; padding:12px 14px 20px; }
+.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-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.error,.steps-badge.denied { background:color-mix(in srgb,#dc2626 14%,transparent); color:#b91c1c; }
+.steps-badge.interrupted,.steps-badge.skipped { 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); }
+.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; }
diff --git a/surfaces/gui/src/types.ts b/surfaces/gui/src/types.ts
index 1c257b2e..f44c9c03 100644
--- a/surfaces/gui/src/types.ts
+++ b/surfaces/gui/src/types.ts
@@ -1,5 +1,7 @@
export type EventType =
| "ready"
+ // Observability: batched recording events for the Steps panel ({events: [...]}).
+ | "step"
| "inbound"
| "turn_start"
| "assistant_delta"
diff --git a/tests/test_observability_read_api.py b/tests/test_observability_read_api.py
index 4b41d4e3..d49567e9 100644
--- a/tests/test_observability_read_api.py
+++ b/tests/test_observability_read_api.py
@@ -77,6 +77,8 @@ def test_a_recorded_turn_reads_back_through_the_endpoints(tmp_path):
assert usage["recorded"] is True
assert usage["cache_share"] == round(1900 / (100 + 900 + 20 + 1000 + 40), 3)
assert usage["context"]["tokens"] == 1020
+ assert usage["totals"] == {"input": 100 + 900 + 20 + 1000 + 40, "cache": 1900, "output": 17}
+ assert usage["turns"] == 1
types = [e["type"] for e in live]
assert types[0] == "turn_started" and "turn_ended" in types and "step_ended" in types