Ensure all command_outputs are sent to the webview before making next API request

This commit is contained in:
Saoud Rizwan
2024-08-05 01:00:19 -04:00
parent 84f89c569a
commit c0ef27033b

View File

@@ -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 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 // Wait for a short delay to ensure all messages are sent to the webview
// This is necessary because the non-awaited promises in the loop might not be // This delay allows time for non-awaited promises to be created and
// created until the next Node.js event loop cycle. We want to make sure all // for their associated messages to be sent to the webview, maintaining
// promises are at least created before proceeding, to maintain the correct // the correct order of messages (although the webview is smart about
// order of messages and avoid potential race conditions. // grouping command_output messages despite any gaps anyways)
await delay(0) await delay(100)
// for attemptCompletion, we don't want to return the command output // for attemptCompletion, we don't want to return the command output
if (returnEmptyStringOnSuccess) { if (returnEmptyStringOnSuccess) {
return "" return ""