Skip to content

Commit 400f26e

Browse files
committed
Fix approval flow for queued messages in Task.ts
When messages are queued while a tool is waiting for approval, they now properly handle the approval before sending. This prevents tools from being rejected when processing queued messages. - Modified Task.ts to check if the ask type requires approval (tool, command, browser_action_launch, use_mcp_server) - For approval-required asks, use handleWebviewAskResponse('yesButtonClicked') instead of setMessageResponse() - For other ask types like followup, continue using setMessageResponse() as before This ensures the correct order: approve tools first, then send messages.
1 parent 652b77e commit 400f26e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/core/task/Task.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,19 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
845845
const message = this.messageQueueService.dequeueMessage()
846846

847847
if (message) {
848-
// Fulfill the ask directly to avoid re-queuing via the webview while sending is disabled
849-
this.setMessageResponse(message.text, message.images)
848+
// Check if this is a tool approval ask that needs to be handled
849+
if (
850+
type === "tool" ||
851+
type === "command" ||
852+
type === "browser_action_launch" ||
853+
type === "use_mcp_server"
854+
) {
855+
// For tool approvals, we need to approve first, then send the message if there's text/images
856+
this.handleWebviewAskResponse("yesButtonClicked", message.text, message.images)
857+
} else {
858+
// For other ask types (like followup), fulfill the ask directly
859+
this.setMessageResponse(message.text, message.images)
860+
}
850861
}
851862
}
852863

0 commit comments

Comments
 (0)