From 1e857e0a6a8736234908b8aacef0fee881c33b26 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 11 Nov 2025 23:39:00 +0100 Subject: [PATCH] Fix aborted tool display when continuing sessions Two fixes for rendering aborted tools in --continue mode: 1. In renderInitialMessages: Check if assistant message was aborted/errored and immediately mark tool execution components as failed instead of leaving them in pending state. 2. In AssistantMessageComponent: Don't show "Aborted" text when there are tool calls in the message, since the tool execution components will show the error state themselves. This prevents duplicate error messages. Now aborted tools show properly as red with "Operation aborted" message, without the duplicate "Aborted" text above them. --- .../coding-agent/src/tui/assistant-message.ts | 14 +++++++++----- packages/coding-agent/src/tui/tui-renderer.ts | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/coding-agent/src/tui/assistant-message.ts b/packages/coding-agent/src/tui/assistant-message.ts index 0f87fe50..90fd7c32 100644 --- a/packages/coding-agent/src/tui/assistant-message.ts +++ b/packages/coding-agent/src/tui/assistant-message.ts @@ -49,11 +49,15 @@ export class AssistantMessageComponent extends Container { } // Check if aborted - show after partial content - if (message.stopReason === "aborted") { - this.contentContainer.addChild(new Text(chalk.red("Aborted"))); - } else if (message.stopReason === "error") { - const errorMsg = message.errorMessage || "Unknown error"; - this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`))); + // But only if there are no tool calls (tool execution components will show the error) + const hasToolCalls = message.content.some((c) => c.type === "toolCall"); + if (!hasToolCalls) { + if (message.stopReason === "aborted") { + this.contentContainer.addChild(new Text(chalk.red("Aborted"))); + } else if (message.stopReason === "error") { + const errorMsg = message.errorMessage || "Unknown error"; + this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`))); + } } } } diff --git a/packages/coding-agent/src/tui/tui-renderer.ts b/packages/coding-agent/src/tui/tui-renderer.ts index f8d43c4e..99d2427f 100644 --- a/packages/coding-agent/src/tui/tui-renderer.ts +++ b/packages/coding-agent/src/tui/tui-renderer.ts @@ -327,8 +327,21 @@ export class TuiRenderer { if (content.type === "toolCall") { const component = new ToolExecutionComponent(content.name, content.arguments); this.chatContainer.addChild(component); - // Store in map so we can update with results later - this.pendingTools.set(content.id, component); + + // If message was aborted/errored, immediately mark tool as failed + if (assistantMsg.stopReason === "aborted" || assistantMsg.stopReason === "error") { + const errorMessage = + assistantMsg.stopReason === "aborted" + ? "Operation aborted" + : assistantMsg.errorMessage || "Error"; + component.updateResult({ + output: errorMessage, + isError: true, + }); + } else { + // Store in map so we can update with results later + this.pendingTools.set(content.id, component); + } } } } else if (message.role === "toolResult") {