From 60ebcbac1bd1f916d8b891eadb78a94094352d4b Mon Sep 17 00:00:00 2001 From: LordMelkor Date: Sun, 22 Nov 2026 00:36:05 -0500 Subject: [PATCH 1/4] Honor explicit turn outcomes while an agent is working Signed-off-by: LordMelkor Co-authored-by: Jello --- docs/plugin-authoring-guide.md | 5 ++++- .../agents/ActivityTranscript.test.tsx | 20 ++++++++++++------- src/features/agents/ActivityTranscript.tsx | 4 +++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/plugin-authoring-guide.md b/docs/plugin-authoring-guide.md index 29c771c34c..778bdccdb5 100644 --- a/docs/plugin-authoring-guide.md +++ b/docs/plugin-authoring-guide.md @@ -387,7 +387,10 @@ Activity tab. Feature-detect `ctx.agents.ui?.Transcript` and keep a fallback on older hosts where `ui` is absent. It renders the same transcript view bundled harnesses use: the Refresh header, live refreshes while `working` is true (including on `Delivery.step` calls), **View activity** turn focus, Markdown, -file diffs, prompt sections and context use. The plugin still owns its +file diffs, prompt sections and context use. A turn that is over carries +`endedAt`, or `outcome` (`ended`, `stopped`, `error` or `unknown`) when its end +time is not known. While `working` is true the view draws a turn that has +neither as working. The plugin still owns its conversation list and marks its own sent-message items with `posted: true` and `messageId`. Derive its props from `@buzz/author` with `ComponentProps["Transcript"]>`. diff --git a/src/features/agents/ActivityTranscript.test.tsx b/src/features/agents/ActivityTranscript.test.tsx index 99ced4a9b1..45e223fbd6 100644 --- a/src/features/agents/ActivityTranscript.test.tsx +++ b/src/features/agents/ActivityTranscript.test.tsx @@ -418,17 +418,22 @@ it("shows no time for an entry with a zero, non-finite or invalid time", () => { }); it.each([ - ["ended", 2000, undefined, "Completed"], - ["working", undefined, undefined, "Working"], - ["ended", 2000, "Command failed", "Failed"], - ["unknown", undefined, undefined, "Status unknown"], + ["ended", 2000, undefined, undefined, "Completed"], + ["working", undefined, undefined, undefined, "Working"], + ["working", undefined, "ended", undefined, "Completed"], + ["working", undefined, "error", undefined, "Failed"], + ["working", undefined, "stopped", undefined, "Stopped"], + ["working", undefined, "unknown", undefined, "Status unknown"], + ["ended", 2000, undefined, "Command failed", "Failed"], + ["unknown", undefined, undefined, undefined, "Status unknown"], ] as const)( - "shows only the turn status for %s/%s/%s", - (state, endedAt, error, label) => { + "shows only the turn status for %s/%s/%s/%s", + (state, endedAt, outcome, error, label) => { const turn = { turnId: "status", startedAt: 1000, endedAt, + outcome, error, channelId: "channel", threadRootId: "a".repeat(64), @@ -444,10 +449,11 @@ it.each([ state={() => state} />, ); - if (state === "working") { + if (label === "Working") { expect(container.querySelector("header")).toBeNull(); expect(screen.getAllByText("Working")).toHaveLength(1); } else { + expect(screen.queryByText("Working")).not.toBeInTheDocument(); expect(container.querySelector("header")).toHaveTextContent(label); expect(container.querySelector("header time") !== null).toBe(!!endedAt); } diff --git a/src/features/agents/ActivityTranscript.tsx b/src/features/agents/ActivityTranscript.tsx index 83dffc2f26..360176028c 100644 --- a/src/features/agents/ActivityTranscript.tsx +++ b/src/features/agents/ActivityTranscript.tsx @@ -349,7 +349,9 @@ export function ActivityTranscript({ Date: Sun, 22 Nov 2026 00:22:18 -0500 Subject: [PATCH 2/4] Keep transcript turn labels with the snapshot on screen Keep Working visible while the stop read is pending. Publish the captured working state on success or failure so a failed stop read releases the label as well. Co-authored-by: Jello Signed-off-by: LordMelkor --- src/features/agents/TranscriptPanel.test.tsx | 71 ++++++++++++++++++-- src/features/agents/TranscriptPanel.tsx | 7 +- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/features/agents/TranscriptPanel.test.tsx b/src/features/agents/TranscriptPanel.test.tsx index fdedcbf4dd..1cbdbbe852 100644 --- a/src/features/agents/TranscriptPanel.test.tsx +++ b/src/features/agents/TranscriptPanel.test.tsx @@ -33,15 +33,15 @@ afterEach(() => { }); /** A read whose calls each settle when the test says. */ -function reads() { +function reads() { const calls: { key: string; signal: AbortSignal; - resolve(value: string | undefined): void; + resolve(value: T | undefined): void; reject(error: Error): void; }[] = []; const read = (key: string) => (signal: AbortSignal) => - new Promise((resolve, reject) => + new Promise((resolve, reject) => calls.push({ key, signal, resolve, reject }), ); return { calls, read }; @@ -312,7 +312,11 @@ it("keeps the transcript while new read inputs are read, and ignores the read th }); view.rerender({ key: "a", again: "s3", working: false }); await settle(nth(calls, 3), "second"); - expect(view.result.current.shown).toEqual({ key: "a", transcript: "second" }); + expect(view.result.current.shown).toEqual({ + key: "a", + transcript: "second", + working: false, + }); }); it("shows a missing transcript as null", async () => { @@ -321,6 +325,62 @@ it("shows a missing transcript as null", async () => { expect(view.result.current.shown.transcript).toBeNull(); }); +const agent = { key: "agent", name: "Agent" } as Parameters< + typeof TranscriptPanel +>[0]["agent"]; + +it.each(["succeeds", "fails"])( + "keeps Working until the stop read %s", + async (result) => { + const { read, calls } = reads(); + const panel = (working: boolean) => ( + + ); + const live: TranscriptTurn = { + turnId: "latest", + startedAt: 1000, + channelId: null, + threadRootId: null, + triggeringEventIds: [], + config: [], + newSession: false, + partial: false, + items: [], + }; + const view = render(panel(true)); + await act(async () => nth(calls, 0).resolve({ turns: [live] })); + expect(screen.getByText("Working")).toBeVisible(); + + view.rerender(panel(false)); + const stop = nth(calls, 1); + expect(screen.getByText("Working")).toBeVisible(); + expect(screen.queryByText("Status unknown")).toBeNull(); + if (result === "succeeds") { + await act(async () => + stop.resolve({ turns: [{ ...live, endedAt: 2000 }] }), + ); + expect(screen.getByText("Completed")).toBeVisible(); + } else { + await act(async () => stop.reject(new Error("unavailable"))); + expect(screen.getByRole("alert")).toHaveTextContent( + "Could not read: unavailable", + ); + expect(screen.getByText("Status unknown")).toBeVisible(); + } + expect(screen.queryByText("Working")).toBeNull(); + act(() => vi.advanceTimersByTime(LIVE_READ_MS * 3)); + expect(calls).toHaveLength(2); + }, +); + it("keeps the shown transcript mounted while its sessions change", async () => { const pending: { resolve(value: Transcript): void; @@ -330,9 +390,6 @@ it("keeps the shown transcript mounted while its sessions change", async () => { new Promise((resolve, reject) => pending.push({ resolve, reject }), ); - const agent = { key: "agent", name: "Agent" } as Parameters< - typeof TranscriptPanel - >[0]["agent"]; const panel = (readAgain: string) => (
= Readonly<{ key: string; /** null: the agent type has no transcript for it. */ transcript?: T | null; + working?: boolean; error?: string; }>; /** A full read, or one of only the latest turns. */ @@ -214,8 +215,8 @@ export function useLiveTranscript({ const before = held.current; held.current = next.error !== undefined && before.key === key - ? { ...before, error: next.error } - : { key, ...next }; + ? { ...before, working, error: next.error } + : { key, ...next, working }; setShown(held.current); if (queued.current && request(true, queued.current)) return; setLoading(false); @@ -379,7 +380,7 @@ export function TranscriptPanel({ agentKey={agent.key} agentPicture={agent.picture} community={agent.relay} - state={() => (working ? "working" : undefined)} + state={() => (shown.working ? "working" : undefined)} before={notes?.(transcript)} /> ) : ( From 690aa828778f14868ec49e0215dfbc484471f78a Mon Sep 17 00:00:00 2001 From: LordMelkor Date: Sun, 22 Nov 2026 00:41:22 -0500 Subject: [PATCH 3/4] Document unknown transcript item timestamps Co-authored-by: Jello Signed-off-by: LordMelkor --- docs/plugin-authoring-guide.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/plugin-authoring-guide.md b/docs/plugin-authoring-guide.md index 778bdccdb5..4ed31123bb 100644 --- a/docs/plugin-authoring-guide.md +++ b/docs/plugin-authoring-guide.md @@ -390,7 +390,8 @@ harnesses use: the Refresh header, live refreshes while `working` is true file diffs, prompt sections and context use. A turn that is over carries `endedAt`, or `outcome` (`ended`, `stopped`, `error` or `unknown`) when its end time is not known. While `working` is true the view draws a turn that has -neither as working. The plugin still owns its +neither as working. Use `at: 0` when an item's timestamp is unknown. For a +tool with an unknown start time, omit `completedAt`. The plugin still owns its conversation list and marks its own sent-message items with `posted: true` and `messageId`. Derive its props from `@buzz/author` with `ComponentProps["Transcript"]>`. From c86b43291922088256a71cae68aa6e3c13165b39 Mon Sep 17 00:00:00 2001 From: LordMelkor Date: Sun, 22 Nov 2026 06:31:10 -0500 Subject: [PATCH 4/4] Bound the Working label while a stopped transcript read is pending Co-authored-by: Jello Signed-off-by: LordMelkor --- src/features/agents/TranscriptPanel.test.tsx | 27 +++++++++++++++++--- src/features/agents/TranscriptPanel.tsx | 12 ++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/features/agents/TranscriptPanel.test.tsx b/src/features/agents/TranscriptPanel.test.tsx index 1cbdbbe852..c32dacf645 100644 --- a/src/features/agents/TranscriptPanel.test.tsx +++ b/src/features/agents/TranscriptPanel.test.tsx @@ -329,9 +329,14 @@ const agent = { key: "agent", name: "Agent" } as Parameters< typeof TranscriptPanel >[0]["agent"]; -it.each(["succeeds", "fails"])( - "keeps Working until the stop read %s", - async (result) => { +it.each([ + { result: "succeeds", late: false }, + { result: "fails", late: false }, + { result: "succeeds", late: true }, + { result: "fails", late: true }, +])( + "shows the stop outcome when the read $result (past the hold: $late)", + async ({ result, late }) => { const { read, calls } = reads(); const panel = (working: boolean) => ( vi.advanceTimersByTime(9_999)); + expect(screen.getByText("Working")).toBeVisible(); + act(() => vi.advanceTimersByTime(1)); + expect(screen.getByText("Status unknown")).toBeVisible(); + expect(screen.queryByText("Working")).toBeNull(); + } if (result === "succeeds") { await act(async () => stop.resolve({ turns: [{ ...live, endedAt: 2000 }] }), @@ -378,6 +390,15 @@ it.each(["succeeds", "fails"])( expect(screen.queryByText("Working")).toBeNull(); act(() => vi.advanceTimersByTime(LIVE_READ_MS * 3)); expect(calls).toHaveLength(2); + if (late && result === "succeeds") { + view.rerender(panel(true)); + await act(async () => nth(calls, 2).resolve({ turns: [live] })); + view.rerender(panel(false)); + act(() => vi.advanceTimersByTime(9_999)); + expect(screen.getByText("Working")).toBeVisible(); + act(() => vi.advanceTimersByTime(1)); + expect(screen.getByText("Status unknown")).toBeVisible(); + } }, ); diff --git a/src/features/agents/TranscriptPanel.tsx b/src/features/agents/TranscriptPanel.tsx index 1d89d569e0..72220183a5 100644 --- a/src/features/agents/TranscriptPanel.tsx +++ b/src/features/agents/TranscriptPanel.tsx @@ -21,6 +21,7 @@ import type { AgentViewProps } from "./service"; export const LIVE_READ_MS = 2500; /** How long after a read a step the agent reports reads again. */ export const STEP_READ_MS = 1000; +const STOP_STATUS_HOLD_MS = 10_000; /** Turns a merged transcript holds at most. */ export const TURN_LIMIT = 50; @@ -342,6 +343,15 @@ export function TranscriptPanel({ refreshWhileWorking, agentKey: agent.key, }); + const holding = !working && Boolean(shown.working); + const [holdExpired, setHoldExpired] = useState(false); + useEffect(() => { + setHoldExpired(false); + if (!holding) return; + const timer = setTimeout(() => setHoldExpired(true), STOP_STATUS_HOLD_MS); + return () => clearTimeout(timer); + }, [holding]); + const isWorking = shown.working && (working || !holdExpired); const { transcript, error } = shown; return (
@@ -380,7 +390,7 @@ export function TranscriptPanel({ agentKey={agent.key} agentPicture={agent.picture} community={agent.relay} - state={() => (shown.working ? "working" : undefined)} + state={() => (isWorking ? "working" : undefined)} before={notes?.(transcript)} /> ) : (