From 2fdd304fbf4b44abfa4f82b6b20d9d8a8f6d5414 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 11 Nov 2025 23:37:05 +0100 Subject: [PATCH] Mark pending tool components as aborted when streaming is interrupted When user presses Esc during tool argument streaming, the assistant message ends with stopReason="aborted" but tool execution never starts. Now we check for aborted/error stopReasons in message_end and update all pending tool execution components to show red error state with "Operation aborted" message. This fixes the issue where tool components stayed stuck in blue/pending state after aborting during JSON streaming. --- packages/coding-agent/src/tui/tui-renderer.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/coding-agent/src/tui/tui-renderer.ts b/packages/coding-agent/src/tui/tui-renderer.ts index 8e9d9564..f8d43c4e 100644 --- a/packages/coding-agent/src/tui/tui-renderer.ts +++ b/packages/coding-agent/src/tui/tui-renderer.ts @@ -213,6 +213,21 @@ export class TuiRenderer { break; } if (this.streamingComponent && event.message.role === "assistant") { + const assistantMsg = event.message as AssistantMessage; + + // If message was aborted or errored, mark all pending tool components as failed + if (assistantMsg.stopReason === "aborted" || assistantMsg.stopReason === "error") { + const errorMessage = + assistantMsg.stopReason === "aborted" ? "Operation aborted" : assistantMsg.errorMessage || "Error"; + for (const [toolCallId, component] of this.pendingTools.entries()) { + component.updateResult({ + output: errorMessage, + isError: true, + }); + } + this.pendingTools.clear(); + } + // Keep the streaming component - it's now the final assistant message this.streamingComponent = null; }