From d634680fc37b097f144f67d9b8efe8011bd5d564 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:39:16 -0400 Subject: [PATCH] Show loading spinner as soon as command starts and has output --- src/ClaudeDev.ts | 2 +- src/integrations/TerminalManager.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index bbe72e2..751ba59 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -1782,7 +1782,7 @@ ${ details += `\n## ${busyTerminal.lastCommand}` const newOutput = this.terminalManager.getUnretrievedOutput(busyTerminal.id) if (newOutput) { - details += `\n...\n${newOutput}` + details += `\nNew Output:\n${newOutput}` } else { // details += `\n(Still running, no new output)` // don't want to show this right after running the command } diff --git a/src/integrations/TerminalManager.ts b/src/integrations/TerminalManager.ts index da7dd4e..d3445fc 100644 --- a/src/integrations/TerminalManager.ts +++ b/src/integrations/TerminalManager.ts @@ -276,6 +276,7 @@ export class TerminalProcess extends EventEmitter { // todo: need to handle errors let isFirstChunk = true let didOutputNonCommand = false + let didEmitEmptyLine = false for await (let data of stream) { console.log("original chunk:", data) if (isFirstChunk) { @@ -326,6 +327,12 @@ export class TerminalProcess extends EventEmitter { data = lines.join("\n") } + // For non-immediately returning commands we want to show loading spinner right away but this wouldnt happen until it emits a line break, so as soon as we get any output we emit "" to let webview know to show spinner + if (!didEmitEmptyLine && !this.fullOutput && data) { + this.emit("line", "") // empty line to indicate start of command output stream + didEmitEmptyLine = true + } + console.log(`parsed chunk:`, data) this.fullOutput += data if (this.isListening) {