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") {