diff --git a/packages/tui/src/routes/session/rows.ts b/packages/tui/src/routes/session/rows.ts index 9bcd0cf8b3e..52e45c94a30 100644 --- a/packages/tui/src/routes/session/rows.ts +++ b/packages/tui/src/routes/session/rows.ts @@ -370,35 +370,17 @@ export function reduceSessionRows( }) usage.previousTurnCache = { read: last.tokens.cache.read, model: last.model } } - // A failure before promotion leaves its prompt queued, so keep the failure after that prompt. - const tail = messages.at(-1) - const period = messages.slice(messages.slice(0, -1).findLastIndex((message) => message.type === "idle") + 1, -1) - const deferred = - tail?.type === "idle" && - tail.outcome === "failed" && - period.some(isInput) && - !period.some((message) => message.type === "assistant") - ? tail - : undefined - // The last step or compaction may already show the failure that ended the busy period. - let failureShown = false const entries = [ - ...messages.filter((message) => !pending.has(message.id) && message !== deferred), + ...messages.filter((message) => !pending.has(message.id)), ...pendingCompactions, ...messages.filter(isInput), - ...(deferred ? [deferred] : []), ].reduce((rows, message) => { if (message.type !== "assistant") { if (message.type === "idle") { flushTurn(rows) - if (message.outcome === "failed" && message.error && !failureShown) - rows.push({ entry: { type: "message", messageID: message.id }, path: [], closesPrevious: true }) - failureShown = false return rows } if (message.type === "synthetic" && !message.description?.trim()) return rows - if (message.type === "compaction" && message.status !== "running") - failureShown = message.status === "failed" && message.error.type !== "aborted" if (message.type === "compaction" && message.status === "completed" && usage) usage.previousTurnCache = undefined rows.push({ entry: { type: "message", messageID: message.id }, @@ -408,7 +390,6 @@ export function reduceSessionRows( return rows } usage?.steps.push(message) - failureShown = !!message.error && message.error.type !== "aborted" const ordinals = { text: 0, reasoning: 0 } message.content.forEach((part) => { const partID = part.type === "tool" ? part.id : `${part.type}:${ordinals[part.type]++}` diff --git a/packages/tui/test/cli/tui/session-rows.test.ts b/packages/tui/test/cli/tui/session-rows.test.ts index 643997640b7..bc7cc3c723c 100644 --- a/packages/tui/test/cli/tui/session-rows.test.ts +++ b/packages/tui/test/cli/tui/session-rows.test.ts @@ -603,43 +603,6 @@ test("renders a footer for a pre-output retry assistant after replay", () => { expect(reduceSessionRows([message])).toEqual([{ type: "assistant-footer", messageID: "assistant-retry" }]) }) -test("shows a persisted execution failure once, after the prompt that caused it", () => { - const user: SessionMessageInfo = { type: "user", id: "user", text: "Go", time: { created: 1 } } - const failed: SessionMessageInfo = { - type: "idle", - id: "idle", - outcome: "failed", - error: { type: "provider.no-route", message: "Model unavailable: opencode/gpt-5.2" }, - time: { created: 3 }, - } - const clean: SessionMessageAssistant = { ...assistant("assistant", []), finish: "stop" } - const errored = { ...clean, error: { type: "provider.quota", message: "Insufficient account funds" } } - - expect(reduceSessionRows([user, failed])).toEqual([ - { type: "message", messageID: "user" }, - { type: "message", messageID: "idle" }, - ]) - expect(reduceSessionRows([user, clean, failed])).toEqual([ - { type: "message", messageID: "user" }, - { type: "assistant-footer", messageID: "assistant" }, - { type: "message", messageID: "idle" }, - ]) - expect(reduceSessionRows([user, errored, failed])).toEqual([ - { type: "message", messageID: "user" }, - { type: "assistant-footer", messageID: "assistant" }, - ]) - const interrupted = { ...clean, error: { type: "aborted", message: "Step interrupted" } } - const exhausted = { - ...failed, - error: { type: "aborted", message: "Execution was interrupted repeatedly and will not be resumed automatically." }, - } - expect(reduceSessionRows([user, interrupted, exhausted]).at(-1)).toEqual({ type: "message", messageID: "idle" }) - expect(reduceSessionRows([user, failed], new Set(["user"]))).toEqual([ - { type: "message", messageID: "user" }, - { type: "message", messageID: "idle" }, - ]) -}) - test("places a running compaction barrier before every queued user message", () => { const queued = (id: string, text: string, created: number): SessionMessageInfo => ({ type: "user",