From 2712853f4e2f9224c4305eea717725481fb1e780 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 9 Jan 2026 01:27:00 +0000 Subject: [PATCH] fix: prevent hang when sending message during command_output When a user sends a message while a command is running (command_output state), the UI would hang because handleChatReset() disabled all inputs but no new command_output ask was sent to re-enable them (since runInBackground became true). This fix changes the behavior so that: 1. For command_output, send terminalOperation with the user message instead of askResponse 2. Clear the input fields but skip handleChatReset() to keep UI responsive 3. In backend, if terminalOperation includes text/images, resolve the pending ask so the loop can continue Fixes #10329 --- src/core/task/Task.ts | 18 +++++++++++++++++- src/core/webview/webviewMessageHandler.ts | 6 +++++- webview-ui/src/components/chat/ChatView.tsx | 17 ++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 5fcfde37ef5..8c2fa95f4ea 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1588,8 +1588,24 @@ export class Task extends EventEmitter implements TaskLike { } } - async handleTerminalOperation(terminalOperation: "continue" | "abort") { + /** + * Handle terminal operations (continue/abort) with optional user message. + * + * When the user sends a message while a command is running (command_output ask), + * we need to both continue the terminal AND resolve the pending ask with the + * user's message. This prevents the UI from hanging. + * + * @param terminalOperation - "continue" to proceed or "abort" to kill the command + * @param text - Optional user message text + * @param images - Optional user message images + */ + async handleTerminalOperation(terminalOperation: "continue" | "abort", text?: string, images?: string[]) { if (terminalOperation === "continue") { + // If user provided a message, resolve the pending ask with their message + // This allows the user to provide feedback while the command runs + if (text || (images && images.length > 0)) { + this.handleWebviewAskResponse("messageResponse", text, images) + } this.terminalProcess?.continue() } else if (terminalOperation === "abort") { this.terminalProcess?.abort() diff --git a/src/core/webview/webviewMessageHandler.ts b/src/core/webview/webviewMessageHandler.ts index 0df014b49ab..5d4ac0bebc0 100644 --- a/src/core/webview/webviewMessageHandler.ts +++ b/src/core/webview/webviewMessageHandler.ts @@ -655,7 +655,11 @@ export const webviewMessageHandler = async ( case "terminalOperation": if (message.terminalOperation) { - provider.getCurrentTask()?.handleTerminalOperation(message.terminalOperation) + // Pass text/images if user sent a message with the terminal operation + // This allows the user to provide additional context when continuing + // a long-running command + const resolved = await resolveIncomingImages({ text: message.text, images: message.images }) + provider.getCurrentTask()?.handleTerminalOperation(message.terminalOperation, resolved.text, resolved.images) } break case "clearTask": diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 6f3ee16ec12..055c9396298 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -616,11 +616,26 @@ const ChatViewComponent: React.ForwardRefRenderFunction