Skip to content

Commit bb9151c

Browse files
committed
Fix message queue re-queue loop in Task.ask()
When the queue had messages during an ask operation, Task.ask() would call submitUserMessage() which posts an 'invoke: sendMessage' to the webview. However, since sendingDisabled is true during ask operations, the webview would re-queue the message, creating an infinite loop. Fixed by directly calling setMessageResponse() when processing queued messages, bypassing the webview round-trip and immediately satisfying the pending ask operation.
1 parent 88b5d66 commit bb9151c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/core/task/Task.ts

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

847847
if (message) {
848-
setTimeout(async () => {
849-
await this.submitUserMessage(message.text, message.images)
850-
}, 0)
848+
// Fulfill the ask directly to avoid re-queuing via the webview while sending is disabled
849+
this.setMessageResponse(message.text, message.images)
851850
}
852851
}
853852

0 commit comments

Comments
 (0)