Skip to content
Python

feat(observability): move between turns in the Trace panel: list, search, keys, strip (T3-14)

Devika Vermacfa65df26760
diff --git a/coworker/server/manager.py b/coworker/server/manager.py
index 7b7a034e..0418cd2a 100644
--- a/coworker/server/manager.py
+++ b/coworker/server/manager.py
@@ -6659,6 +6659,9 @@ class SessionManager:
for t in turns:
r = issues.get(t["turn_id"]) or {}
t["issues"] = {"warn": int(r.get("warn") or 0), "info": int(r.get("info") or 0)}
+ # T3-14: which checks warned, so the turn list can be searched by issue title
+ t["issue_checks"] = sorted({i.get("check") for i in r.get("issues") or []
+ if i.get("severity") == "warn" and i.get("check")})
if workers.get(t["turn_id"]):
t["workers"] = workers[t["turn_id"]]
return {"turns": turns}
diff --git a/surfaces/gui/src/App.tsx b/surfaces/gui/src/App.tsx
index 20506ae4..61d10836 100644
--- a/surfaces/gui/src/App.tsx
+++ b/surfaces/gui/src/App.tsx
@@ -2697,7 +2697,7 @@ export function App() {
/>
</div>
<RightRail
- teamView={stepsOpen && sessionId ? <StepsPanel sessionId={sessionId} refreshKey={stepsKey} openAt={stepsAt} onClose={() => setStepsOpen(false)} onOpenSession={(id) => { const w = sessions.find(s => s.session_id === id); if (w) void selectSession(w.session_id, w.workspace, w.agent); }} /> : 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); }} onOpenSteps={openTurnSteps} /> : undefined}
+ teamView={stepsOpen && sessionId ? <StepsPanel sessionId={sessionId} refreshKey={stepsKey} openAt={stepsAt} conversation={items} onClose={() => setStepsOpen(false)} onOpenSession={(id) => { const w = sessions.find(s => s.session_id === id); if (w) void selectSession(w.session_id, w.workspace, w.agent); }} /> : 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); }} onOpenSteps={openTurnSteps} /> : 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 68269cb6..342bea90 100644
--- a/surfaces/gui/src/api.ts
+++ b/surfaces/gui/src/api.ts
@@ -4573,6 +4573,11 @@ export interface RecordedTurn {
wake?: { reason?: string; kinds?: string[]; item_ids?: string[]; board_seq?: number | null; batched?: number | null;
deferred?: { by: string; ms: number } | null; by?: string | null } | null;
automation?: { task_id: string; run_id: string; trigger: string } | null;
+ // The turn's first and last message ids, and its warning checks (T3-14: the turn list
+ // finds a turn's part of the conversation by the answer's id, and searches issue titles).
+ first_message_id?: string | null;
+ last_message_id?: string | null;
+ issue_checks?: string[];
}
// One worker turn under a lead's turn (OB-7). `tokens` are the worker's own, never the lead's.
diff --git a/surfaces/gui/src/components/StepsPanel.tsx b/surfaces/gui/src/components/StepsPanel.tsx
index 16c0ef90..046395d7 100644
--- a/surfaces/gui/src/components/StepsPanel.tsx
+++ b/surfaces/gui/src/components/StepsPanel.tsx
@@ -22,7 +22,8 @@ import {
type TurnIssues,
} from "../api";
import { formatTokens } from "../usage";
-import { wakeKey } from "../obs3";
+import { turnTexts, wakeKey } from "../obs3";
+import { TurnList, TurnStrip } from "./TurnPicker";
type T = (k: string, o?: any) => string;
@@ -364,9 +365,13 @@ export function StepsPanel({
openAt = null,
onClose,
onOpenSession,
+ conversation = [],
}: {
sessionId: string;
refreshKey?: number;
+ /** T3-14: the session's conversation as the GUI holds it, for the turn list's first
+ * words and its search. Read here only; nothing is sent. */
+ conversation?: { kind: string; text?: string; mid?: string; name?: string; args?: any }[];
// A worker row's "Open worker session" (OB-7).
onOpenSession?: (sessionId: string) => void;
// Opened from a turn's answer: its time (unix seconds) picks the turn that produced it.
@@ -382,6 +387,7 @@ export function StepsPanel({
const [selected, setSelected] = useState<string | null>(null);
const [error, setError] = useState(false);
const [openHelpers, setOpenHelpers] = useState<Set<string>>(new Set());
+ const [listOpen, setListOpen] = useState(false);
// Another session: start again at its newest turn.
useEffect(() => {
@@ -466,14 +472,36 @@ export function StepsPanel({
const inspecting = tab === "timeline" && !!selected && !!turn;
const total = turn ? Math.max(1, turn.buckets.total || turn.duration_ms || 1) : 1;
+ // T3-14: each turn's part of the conversation, for the list's first words and its search
+ const texts = useMemo(() => turnTexts(turns || [], conversation), [turns, conversation]);
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"><Help text={H(t, "turn")}>{t("steps.turn_of", { n: turnIdx + 1, total: turns.length })}</Help></span>
+ <button className="steps-turn-open" data-testid="steps-turn" aria-haspopup="dialog" aria-expanded={listOpen}
+ title={t("steps.turns.open_list")} onClick={() => setListOpen((o) => !o)}>
+ {t("steps.turn_of", { n: turnIdx + 1, total: turns.length })} <span aria-hidden>▾</span>
+ </button>
<button aria-label={t("steps.next_turn")} disabled={turnIdx >= turns.length - 1} onClick={() => setTurnIdx(turnIdx + 1)}>›</button>
{turn && wakeLine(turn, t) && <span className="steps-turn-wake text-faint" data-testid="steps-turn-wake">· {wakeLine(turn, t)}</span>}
+ {listOpen && (
+ <TurnList turns={turns} current={turnIdx} texts={texts} wakeOf={(tn) => wakeLine(tn, t)} t={t}
+ onPick={(i) => setTurnIdx(i)} onClose={() => setListOpen(false)} />
+ )}
</span>
);
+ // T3-14 (B): ← and → move between turns while the panel has focus and no text box does.
+ const onKeyDown = (e: React.KeyboardEvent) => {
+ if (!turns || turnIdx == null || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
+ const el = e.target as HTMLElement;
+ if (el.closest("input, textarea, select, [contenteditable='true']")) return;
+ if (e.key === "ArrowLeft" && turnIdx > 0) {
+ setTurnIdx(turnIdx - 1);
+ e.preventDefault();
+ } else if (e.key === "ArrowRight" && turnIdx < turns.length - 1) {
+ setTurnIdx(turnIdx + 1);
+ e.preventDefault();
+ }
+ };
const timeline = turn && (
<div className="steps-timeline" data-testid="steps-timeline">
@@ -505,7 +533,8 @@ export function StepsPanel({
);
return (
- <div className={"team-view steps-panel" + (inspecting ? " inspecting" : "")} data-testid="steps-panel">
+ <div className={"team-view steps-panel" + (inspecting ? " inspecting" : "")} data-testid="steps-panel"
+ tabIndex={-1} onKeyDown={onKeyDown}>
<div className="steps-railhead">
<div className="steps-railhead-title">
<strong>{t("steps.title")}</strong>
@@ -513,6 +542,9 @@ export function StepsPanel({
<span className="steps-sp" />
<button className="steps-close" aria-label={t("steps.close")} onClick={onClose}>✕</button>
</div>
+ {turns && turns.length > 0 && turnIdx != null && (
+ <TurnStrip turns={turns} current={turnIdx} onPick={(i) => setTurnIdx(i)} t={t} />
+ )}
{turn && (modeLabel(turn, t) || stampLine(turn.stamp, t)) && (
<div className="steps-stamp" data-testid="steps-stamp">
{modeLabel(turn, t) && (
diff --git a/surfaces/gui/src/components/TurnPicker.test.tsx b/surfaces/gui/src/components/TurnPicker.test.tsx
new file mode 100644
index 00000000..eecf76b4
--- /dev/null
+++ b/surfaces/gui/src/components/TurnPicker.test.tsx
@@ -0,0 +1,161 @@
+// T3-14: moving between turns in the Trace panel. "Turn N of M" opens a searchable list (A),
+// ← and → move between turns while the panel has focus (B), and a thin bar per turn sits
+// under the picker (C).
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { getRecordedTurns, getTurnSteps } from "../api";
+import { StepsPanel } from "./StepsPanel";
+import { turnMatches, turnTexts } from "../obs3";
+
+vi.mock("../api", () => ({
+ getRecordedTurns: vi.fn(),
+ getTurnSteps: vi.fn(() => Promise.resolve([])),
+ getStepDetail: vi.fn(),
+ getRecordedUsage: vi.fn(() => Promise.resolve(null)),
+ getTurnIssues: vi.fn(() => Promise.resolve(null)),
+ markIssuesSeen: vi.fn(() => Promise.resolve()),
+}));
+
+const turn = (n: number, over: Record<string, any> = {}) => ({
+ turn_id: `t${n}`, seq: n, kind: "run", trigger: "user", status: "completed", started_at: 1_000 * n,
+ duration_ms: 500, stamp: {}, buckets: { total: 500 }, usage: { pill: n * 1000 }, issues: { warn: 0, info: 0 },
+ last_message_id: `a${n}`, ...over,
+});
+
+const turns = [
+ turn(1),
+ turn(2, { issues: { warn: 1, info: 0 }, issue_checks: ["tool_failed"], usage: { pill: 12_300 } }),
+ turn(3, { wake: { reason: "review" } }),
+];
+const conversation = [
+ { kind: "user", text: "Summarise the quarterly budget please" },
+ { kind: "assistant", text: "Here is the summary.", mid: "a1" },
+ { kind: "user", text: "Now read the onboarding guide" },
+ { kind: "tool", name: "read_file", args: { path: "docs/Onboarding-Guide.md" } },
+ { kind: "assistant", text: "The guide says hello.", mid: "a2" },
+ { kind: "assistant", text: "The reviewer woke me; nothing to do.", mid: "a3" },
+];
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+async function open(list = turns) {
+ vi.mocked(getRecordedTurns).mockResolvedValue(list as any);
+ render(<StepsPanel sessionId="s1" onClose={() => {}} conversation={conversation} />);
+ await waitFor(() => expect(screen.getByTestId("steps-turn").textContent).toContain(`Turn ${list.length} of ${list.length}`));
+}
+
+describe("each turn's part of the conversation", () => {
+ it("splits at each answer and finds tools and files", () => {
+ const texts = turnTexts(turns, conversation);
+ expect(texts.get("t1")!.user).toBe("Summarise the quarterly budget please");
+ expect(texts.get("t2")!.tools).toEqual(["read_file"]);
+ expect(texts.get("t2")!.files).toEqual(["docs/Onboarding-Guide.md"]);
+ expect(texts.get("t3")!.user).toBe("");
+ expect(texts.get("t3")!.answer).toContain("reviewer woke me");
+ // a running last turn with no answer yet takes what is left
+ const running = turnTexts([...turns, turn(4, { last_message_id: null })], [...conversation, { kind: "user", text: "and now?" }]);
+ expect(running.get("t4")!.user).toBe("and now?");
+ });
+
+ it("matches the number, the words, tools, files and issue titles, ignoring case", () => {
+ const text = { user: "Read the guide", answer: "Done", tools: ["run_shell"], files: ["a/Budget.xlsx"] };
+ expect(turnMatches(2, text, [], "2")).toBe(true);
+ expect(turnMatches(2, text, [], "3")).toBe(false);
+ expect(turnMatches(2, text, [], "GUIDE")).toBe(true);
+ expect(turnMatches(2, text, [], "budget.xlsx")).toBe(true);
+ expect(turnMatches(2, text, [], "run_shell")).toBe(true);
+ expect(turnMatches(2, text, ["A tool failed"], "tool failed")).toBe(true);
+ expect(turnMatches(2, text, [], "nowhere")).toBe(false);
+ });
+});
+
+describe("the turn list (A)", () => {
+ it("lists every turn with its time, first words, tokens, issue and wake reason, and jumps", async () => {
+ await open();
+ fireEvent.click(screen.getByTestId("steps-turn"));
+ const list = screen.getByTestId("turn-list");
+ expect(list).toBeTruthy();
+ const row2 = screen.getByTestId("turn-list-row-2").textContent || "";
+ expect(row2).toContain("Turn 2");
+ expect(row2).toContain("Now read the onboarding guide");
+ expect(row2).toContain("12.3k tokens");
+ expect(row2).toContain("1 issue");
+ expect(screen.getByTestId("turn-list-row-3").textContent).toContain("woke:");
+ expect(screen.getByTestId("turn-list-row-3").textContent).toContain("(no message of yours)");
+ expect(screen.getByTestId("turn-list-row-3").getAttribute("aria-current")).toBe("true");
+ fireEvent.click(screen.getByTestId("turn-list-row-1"));
+ expect(screen.queryByTestId("turn-list")).toBeNull();
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 1 of 3");
+ });
+
+ it("search keeps the turns whose text matches; a number jumps on Enter; nothing says so", async () => {
+ await open();
+ fireEvent.click(screen.getByTestId("steps-turn"));
+ const search = screen.getByTestId("turn-list-search");
+ fireEvent.change(search, { target: { value: "onboarding-GUIDE.md" } });
+ expect(screen.queryByTestId("turn-list-row-1")).toBeNull();
+ expect(screen.getByTestId("turn-list-row-2")).toBeTruthy();
+ fireEvent.change(search, { target: { value: "a tool failed" } }); // an issue title
+ expect(screen.getByTestId("turn-list-row-2")).toBeTruthy();
+ expect(screen.queryByTestId("turn-list-row-3")).toBeNull();
+ fireEvent.change(search, { target: { value: "zebra" } });
+ expect(screen.getByTestId("turn-list-empty").textContent).toBe("No turns match.");
+ fireEvent.change(search, { target: { value: "1" } });
+ expect(screen.getByTestId("turn-list-hint").textContent).toContain("Press Enter to go to turn 1");
+ fireEvent.keyDown(search, { key: "Enter" });
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 1 of 3");
+ // typing in the search box never moves the turn by itself
+ expect(getTurnSteps).toHaveBeenCalled();
+ });
+});
+
+describe("keys (B)", () => {
+ it("← and → move between turns while the panel has focus, never from a text box", async () => {
+ await open();
+ const panel = screen.getByTestId("steps-panel");
+ fireEvent.keyDown(panel, { key: "ArrowLeft" });
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 2 of 3");
+ fireEvent.keyDown(panel, { key: "ArrowLeft" });
+ fireEvent.keyDown(panel, { key: "ArrowLeft" }); // stays at the first
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 1 of 3");
+ fireEvent.keyDown(panel, { key: "ArrowRight" });
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 2 of 3");
+ fireEvent.keyDown(panel, { key: "End" }); // no Home or End
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 2 of 3");
+ fireEvent.click(screen.getByTestId("steps-turn"));
+ fireEvent.keyDown(screen.getByTestId("turn-list-search"), { key: "ArrowRight" });
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 2 of 3");
+ });
+});
+
+describe("the turns strip (C)", () => {
+ it("one bar per turn: height by tokens, amber with issues, the current one marked, click jumps", async () => {
+ await open();
+ const bars = screen.getByTestId("turn-strip").querySelectorAll(".steps-strip-bar");
+ expect(bars).toHaveLength(3);
+ const bar2 = screen.getByTestId("turn-strip-bar-2");
+ expect(bar2.className).toContain("warn");
+ expect(bar2.getAttribute("title")).toBe("Turn 2 · 12.3k tokens · 1 issue");
+ expect((bar2.querySelector("i") as HTMLElement).style.height).toBe("100%"); // the heaviest
+ expect(screen.getByTestId("turn-strip-bar-3").className).toContain("current");
+ fireEvent.click(screen.getByTestId("turn-strip-bar-1"));
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 1 of 3");
+ expect(screen.getByTestId("turn-strip-bar-1").className).toContain("current");
+ });
+
+ it("works with one turn, and stays usable with 200+", async () => {
+ await open([turn(1)]);
+ expect(screen.getByTestId("turn-strip").querySelectorAll(".steps-strip-bar")).toHaveLength(1);
+ cleanup();
+ const many = Array.from({ length: 230 }, (_, i) => turn(i + 1));
+ await open(many);
+ const strip = screen.getByTestId("turn-strip");
+ expect(strip.className).toContain("dense"); // thin bars, the strip scrolls
+ expect(strip.querySelectorAll(".steps-strip-bar")).toHaveLength(230);
+ fireEvent.click(screen.getByTestId("turn-strip-bar-117"));
+ expect(screen.getByTestId("steps-turn").textContent).toContain("Turn 117 of 230");
+ });
+});
diff --git a/surfaces/gui/src/components/TurnPicker.tsx b/surfaces/gui/src/components/TurnPicker.tsx
new file mode 100644
index 00000000..0335a653
--- /dev/null
+++ b/surfaces/gui/src/components/TurnPicker.tsx
@@ -0,0 +1,153 @@
+// T3-14: moving between turns in the Trace panel. "Turn N of M" opens a list of the session's
+// turns with a search box (A), and a thin bar per turn sits under the picker (C). The keys (B)
+// live on the panel. Everything shown or searched is what the GUI already holds: the recorded
+// turns and the conversation. Nothing is fetched or sent for it.
+
+import { useEffect, useMemo, useRef, useState } from "react";
+import type { RecordedTurn } from "../api";
+import { firstWords, turnMatches, type TurnText } from "../obs3";
+import { formatTokens } from "../usage";
+
+type T = (k: string, o?: any) => string;
+
+export const turnTokens = (tn: RecordedTurn): number => Number(tn.usage?.pill || 0);
+const warnOf = (tn: RecordedTurn): number => tn.issues?.warn || 0;
+const issueTitles = (tn: RecordedTurn, t: T): string[] =>
+ (tn.issue_checks || []).map((c) => t(`steps.issues.title.${c}`, { defaultValue: c }));
+
+function startTime(ms: number): string {
+ const d = new Date(ms);
+ const today = new Date();
+ const time = d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
+ return d.toDateString() === today.toDateString()
+ ? time
+ : `${d.toLocaleDateString([], { month: "short", day: "numeric" })} ${time}`;
+}
+
+/** The list under "Turn N of M": a search box over the session's turns, newest last. */
+export function TurnList({
+ turns,
+ current,
+ texts,
+ wakeOf,
+ onPick,
+ onClose,
+ t,
+}: {
+ turns: RecordedTurn[];
+ current: number;
+ texts: Map<string, TurnText>;
+ wakeOf: (tn: RecordedTurn) => string | null;
+ onPick: (idx: number) => void;
+ onClose: () => void;
+ t: T;
+}) {
+ const [query, setQuery] = useState("");
+ const box = useRef<HTMLDivElement | null>(null);
+ const currentRow = useRef<HTMLButtonElement | null>(null);
+ useEffect(() => {
+ currentRow.current?.scrollIntoView?.({ block: "nearest" });
+ const away = (e: MouseEvent) => {
+ if (box.current && !box.current.contains(e.target as Node)) onClose();
+ };
+ document.addEventListener("mousedown", away);
+ return () => document.removeEventListener("mousedown", away);
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
+ const shown = useMemo(
+ () => turns.map((tn, i) => ({ tn, i })).filter(({ tn, i }) => turnMatches(i + 1, texts.get(tn.turn_id), issueTitles(tn, t), query)),
+ [turns, texts, query, t],
+ );
+ const number = /^\d+$/.test(query.trim()) ? Number(query.trim()) : null;
+ const pick = (i: number) => {
+ onPick(i);
+ onClose();
+ };
+ return (
+ <div className="steps-turnlist" ref={box} data-testid="turn-list" role="dialog" aria-label={t("steps.turns.list_title")}>
+ <input
+ autoFocus
+ className="steps-turnlist-search"
+ placeholder={t("steps.turns.search")}
+ value={query}
+ data-testid="turn-list-search"
+ onChange={(e) => setQuery(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") onClose();
+ else if (e.key === "Enter" && shown.length > 0) pick(shown[0].i);
+ }}
+ />
+ {number != null && (
+ <div className="steps-turnlist-hint" data-testid="turn-list-hint">
+ {number >= 1 && number <= turns.length ? t("steps.turns.jump_hint", { n: number }) : t("steps.turns.no_such", { total: turns.length })}
+ </div>
+ )}
+ <div className="steps-turnlist-rows">
+ {shown.length === 0 ? (
+ number == null && <div className="steps-turnlist-empty" data-testid="turn-list-empty">{t("steps.turns.no_match")}</div>
+ ) : (
+ shown.map(({ tn, i }) => {
+ const text = texts.get(tn.turn_id);
+ const words = text?.user ? firstWords(text.user) : "";
+ const wake = wakeOf(tn);
+ const warn = warnOf(tn);
+ return (
+ <button
+ key={tn.turn_id}
+ ref={i === current ? currentRow : undefined}
+ className={"steps-turnlist-row" + (i === current ? " current" : "")}
+ aria-current={i === current}
+ data-testid={`turn-list-row-${i + 1}`}
+ onClick={() => pick(i)}
+ >
+ <span className="steps-turnlist-head">
+ <b>{t("steps.turns.turn_n", { n: i + 1 })}</b>
+ <span className="text-faint">{startTime(tn.started_at)}</span>
+ <span className="steps-sp" />
+ {warn > 0 && <span className="steps-badge warn">{t("steps.turns.issues", { count: warn })}</span>}
+ <span className="text-faint">{(tn.usage?.at_least ? "≥ " : "") + t("steps.turns.tokens", { tokens: formatTokens(turnTokens(tn)) })}</span>
+ </span>
+ <span className="steps-turnlist-words">{words || <span className="text-faint">{t("steps.turns.no_message")}</span>}</span>
+ {wake && <span className="steps-turnlist-wake text-faint">{wake}</span>}
+ </button>
+ );
+ })
+ )}
+ </div>
+ </div>
+ );
+}
+
+/** One thin bar per turn: its height is the turn's tokens, amber when it has issues; the
+ * current one is marked. Bars get thinner as turns add up and the strip scrolls past about
+ * 120, so 200+ turns stay readable. */
+export function TurnStrip({ turns, current, onPick, t }: { turns: RecordedTurn[]; current: number; onPick: (idx: number) => void; t: T }) {
+ const max = Math.max(1, ...turns.map(turnTokens));
+ const strip = useRef<HTMLDivElement | null>(null);
+ useEffect(() => {
+ const el = strip.current?.querySelector<HTMLElement>(".current");
+ el?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
+ }, [current, turns.length]);
+ return (
+ <div className={"steps-strip" + (turns.length > 120 ? " dense" : "")} ref={strip} data-testid="turn-strip" aria-label={t("steps.turns.strip")}>
+ {turns.map((tn, i) => {
+ const tokens = turnTokens(tn);
+ const warn = warnOf(tn);
+ const label = t("steps.turns.bar", { n: i + 1, tokens: formatTokens(tokens) }) +
+ (warn > 0 ? " · " + t("steps.turns.issues", { count: warn }) : "");
+ return (
+ <button
+ key={tn.turn_id}
+ className={"steps-strip-bar" + (warn > 0 ? " warn" : "") + (i === current ? " current" : "")}
+ title={label}
+ aria-label={label}
+ aria-current={i === current}
+ data-testid={`turn-strip-bar-${i + 1}`}
+ onClick={() => onPick(i)}
+ >
+ <i style={{ height: `${Math.max(12, (tokens / max) * 100)}%` }} />
+ </button>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index bf51e211..983b4b09 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -3375,6 +3375,21 @@
"prev_turn": "Previous turn",
"next_turn": "Next turn",
"turn_of": "Turn {{n}} of {{total}}",
+ "turns": {
+ "open_list": "All turns of this session, with search",
+ "list_title": "Turns of this session",
+ "search": "Search turns, or type a turn number",
+ "no_match": "No turns match.",
+ "jump_hint": "Press Enter to go to turn {{n}}.",
+ "no_such": "This session has {{total}} turns.",
+ "turn_n": "Turn {{n}}",
+ "tokens": "{{tokens}} tokens",
+ "issues_one": "{{count}} issue",
+ "issues_other": "{{count}} issues",
+ "no_message": "(no message of yours)",
+ "strip": "Turns, by tokens",
+ "bar": "Turn {{n}} · {{tokens}} tokens"
+ },
"reviewer_is": "reviewer {{who}}",
"finish": {
"stop": "it finished its answer",
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 3f5f0ee6..5bb23e15 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -3328,6 +3328,20 @@
"prev_turn": "上一轮",
"next_turn": "下一轮",
"turn_of": "第 {{n}} 轮,共 {{total}} 轮",
+ "turns": {
+ "open_list": "本会话的所有轮次,可搜索",
+ "list_title": "本会话的轮次",
+ "search": "搜索轮次,或输入轮次编号",
+ "no_match": "没有匹配的轮次。",
+ "jump_hint": "按 Enter 转到第 {{n}} 轮。",
+ "no_such": "本会话共有 {{total}} 轮。",
+ "turn_n": "第 {{n}} 轮",
+ "tokens": "{{tokens}} 令牌",
+ "issues_other": "{{count}} 个问题",
+ "no_message": "(没有你的消息)",
+ "strip": "各轮次的令牌",
+ "bar": "第 {{n}} 轮 · {{tokens}} 令牌"
+ },
"reviewer_is": "审查者 {{who}}",
"finish": {
"stop": "回答已完成",
diff --git a/surfaces/gui/src/obs3.ts b/surfaces/gui/src/obs3.ts
index b0619ce3..dd2ea606 100644
--- a/surfaces/gui/src/obs3.ts
+++ b/surfaces/gui/src/obs3.ts
@@ -241,3 +241,82 @@ export function hhmm(ms: number): string {
export function shortDate(ms: number): string {
return new Date(ms).toLocaleDateString(undefined, { day: "2-digit", month: "short" });
}
+
+// -- moving between turns in the Trace panel (T3-14) ------------------------------------------
+/** A turn's part of the conversation the GUI already holds: what you asked, its answer, and
+ * the tools and files its steps touched. Nothing here is fetched or sent anywhere. */
+export interface TurnText {
+ user: string;
+ answer: string;
+ tools: string[];
+ files: string[];
+}
+
+type ConvItem = { kind: string; text?: string; mid?: string; name?: string; args?: any };
+
+const FILE_KEYS = ["path", "file", "file_path", "filename", "paths", "files", "target", "dest", "source"];
+
+function filesOf(args: any): string[] {
+ if (!args || typeof args !== "object") return [];
+ const out: string[] = [];
+ for (const k of FILE_KEYS) {
+ const v = args[k];
+ if (typeof v === "string" && v) out.push(v);
+ else if (Array.isArray(v)) for (const x of v) if (typeof x === "string" && x) out.push(x);
+ }
+ return out;
+}
+
+/** Splits the conversation at each turn's answer: a turn's part runs from just after the
+ * previous turn's last message to its own (`last_message_id`, the answer's `mid`). A turn with
+ * no answer yet (running, or cut off) gets what is left at the end when it is the last one. */
+export function turnTexts(
+ turns: { turn_id: string; last_message_id?: string | null }[],
+ items: ConvItem[],
+): Map<string, TurnText> {
+ const at = new Map<string, number>();
+ items.forEach((it, i) => {
+ if (it.mid) at.set(it.mid, i);
+ });
+ const out = new Map<string, TurnText>();
+ const fill = (tid: string, from: number, to: number) => {
+ const part: TurnText = { user: "", answer: "", tools: [], files: [] };
+ for (const it of items.slice(from, to)) {
+ if (it.kind === "user" && it.text) part.user += (part.user ? "\n" : "") + it.text;
+ else if (it.kind === "assistant" && it.text) part.answer += (part.answer ? "\n" : "") + it.text;
+ else if ((it.kind === "tool" || it.kind === "approval") && it.name) {
+ part.tools.push(it.name);
+ part.files.push(...filesOf(it.args));
+ }
+ }
+ out.set(tid, part);
+ };
+ let start = 0;
+ turns.forEach((tn, k) => {
+ const end = tn.last_message_id != null ? at.get(tn.last_message_id) : undefined;
+ if (end != null && end >= start) {
+ fill(tn.turn_id, start, end + 1);
+ start = end + 1;
+ } else if (k === turns.length - 1) {
+ fill(tn.turn_id, start, items.length);
+ }
+ });
+ return out;
+}
+
+/** Whether a turn matches the list's search: its number, what you asked, the answer, tool
+ * names, file names and its issues' titles, ignoring case. */
+export function turnMatches(n: number, text: TurnText | undefined, issueTitles: string[], query: string): boolean {
+ const q = query.trim().toLowerCase();
+ if (!q) return true;
+ if (/^\d+$/.test(q)) return String(n) === q;
+ const hay = [text?.user, text?.answer, ...(text?.tools || []), ...(text?.files || []), ...issueTitles]
+ .filter(Boolean).join("\n").toLowerCase();
+ return hay.includes(q);
+}
+
+/** The first words of a message, on one line. */
+export function firstWords(text: string, max = 70): string {
+ const one = text.replace(/\s+/g, " ").trim();
+ return one.length > max ? one.slice(0, max - 1).trimEnd() + "…" : one;
+}
diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.css
index 5b597039..174fc481 100644
--- a/surfaces/gui/src/styles.css
+++ b/surfaces/gui/src/styles.css
@@ -2445,6 +2445,28 @@ html[data-theme="dark"] { --bar-model:#4c8dff; --bar-tool:#3fb8ad; --bar-wait:#3
.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; }
+/* T3-14: the turn list under "Turn N of M", and the turns strip */
+.steps-turn-picker { position:relative; }
+.steps-panel:focus { outline:none; }
+.steps-turnlist { position:absolute; top:calc(100% + 4px); left:0; z-index:30; width:min(380px, 80vw); max-height:60vh; display:flex; flex-direction:column; background:var(--panel); border:1px solid var(--line-strong); border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.18); font-weight:400; color:var(--ink); }
+.steps-turnlist-search { margin:8px; padding:6px 9px; border:1px solid var(--line-strong); border-radius:7px; background:var(--paper); color:var(--ink); font:inherit; font-size:var(--fs-ui); outline:none; }
+.steps-turnlist-search:focus { border-color:var(--accent); }
+.steps-turnlist-hint, .steps-turnlist-empty { padding:4px 12px 8px; font-size:var(--fs-meta); color:var(--muted); }
+.steps-turnlist-rows { overflow-y:auto; padding:0 4px 6px; }
+.steps-turnlist-row { display:flex; flex-direction:column; gap:2px; width:100%; text-align:left; border:0; background:none; color:var(--ink); padding:6px 8px; border-radius:7px; cursor:pointer; font:inherit; font-size:var(--fs-meta); }
+.steps-turnlist-row:hover { background:var(--paper); }
+.steps-turnlist-row.current { background:var(--paper); box-shadow:inset 2px 0 0 var(--accent); }
+.steps-turnlist-head { display:flex; align-items:center; gap:6px; min-width:0; }
+.steps-turnlist-words, .steps-turnlist-wake { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
+.steps-strip { display:flex; align-items:flex-end; gap:1px; height:22px; margin-top:6px; overflow-x:auto; overflow-y:hidden; scrollbar-width:thin; }
+.steps-strip-bar { flex:1 0 3px; max-width:14px; height:100%; display:flex; align-items:flex-end; border:0; padding:0; background:none; cursor:pointer; border-radius:2px; }
+.steps-strip.dense .steps-strip-bar { flex:0 0 3px; }
+.steps-strip-bar i { display:block; width:100%; background:var(--line-strong); border-radius:2px 2px 0 0; }
+.steps-strip-bar:hover i { background:var(--muted); }
+.steps-strip-bar.warn i { background:#f59e0b; }
+.steps-strip-bar.current { box-shadow:inset 0 -2px 0 var(--accent); }
+.steps-strip-bar.current i { background:var(--accent); }
+.steps-strip-bar.current.warn i { background:#f59e0b; outline:1px solid var(--accent); }
.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; }
diff --git a/tests/test_observability_issues.py b/tests/test_observability_issues.py
index 26e00b4a..9f491d50 100644
--- a/tests/test_observability_issues.py
+++ b/tests/test_observability_issues.py
@@ -225,6 +225,7 @@ def test_issues_are_stored_at_turn_end_and_served(tmp_path):
[turn] = client.get("/v1/sessions/i1/turns").json()["turns"]
assert turn["issues"] == {"warn": 1, "info": 0}
+ assert turn["issue_checks"] == ["tool_failed"] # T3-14: the turn list searches by issue title
got = client.get(f"/v1/sessions/i1/turns/{turn['turn_id']}/issues").json()
assert got["signals_version"] == signals.version() and got["seen"] is False
[failed] = got["issues"]