diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 5fcfde37ef..8c2fa95f4e 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 0df014b49a..5d4ac0bebc 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 6f3ee16ec1..055c939629 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