From c0ef27033b3b2f0783aa769a58be396cc1c4598e Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Mon, 5 Aug 2024 01:00:19 -0400 Subject: [PATCH] Ensure all command_outputs are sent to the webview before making next API request --- src/ClaudeDev.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index ebc1f26..d6b4faf 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -684,12 +684,12 @@ export class ClaudeDev { throw e // if the command was not terminated by user, let outer catch handle it as a real error } } - // Wait for the next event loop tick to ensure all promises from the loop are created - // This is necessary because the non-awaited promises in the loop might not be - // created until the next Node.js event loop cycle. We want to make sure all - // promises are at least created before proceeding, to maintain the correct - // order of messages and avoid potential race conditions. - await delay(0) + // Wait for a short delay to ensure all messages are sent to the webview + // This delay allows time for non-awaited promises to be created and + // for their associated messages to be sent to the webview, maintaining + // the correct order of messages (although the webview is smart about + // grouping command_output messages despite any gaps anyways) + await delay(100) // for attemptCompletion, we don't want to return the command output if (returnEmptyStringOnSuccess) { return ""