Show loading spinner as soon as command starts and has output

This commit is contained in:
Saoud Rizwan
2024-09-09 12:39:16 -04:00
parent 5866adb09f
commit d634680fc3
2 changed files with 8 additions and 1 deletions

View File

@@ -1782,7 +1782,7 @@ ${
details += `\n## ${busyTerminal.lastCommand}` details += `\n## ${busyTerminal.lastCommand}`
const newOutput = this.terminalManager.getUnretrievedOutput(busyTerminal.id) const newOutput = this.terminalManager.getUnretrievedOutput(busyTerminal.id)
if (newOutput) { if (newOutput) {
details += `\n...\n${newOutput}` details += `\nNew Output:\n${newOutput}`
} else { } else {
// details += `\n(Still running, no new output)` // don't want to show this right after running the command // details += `\n(Still running, no new output)` // don't want to show this right after running the command
} }

View File

@@ -276,6 +276,7 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
// todo: need to handle errors // todo: need to handle errors
let isFirstChunk = true let isFirstChunk = true
let didOutputNonCommand = false let didOutputNonCommand = false
let didEmitEmptyLine = false
for await (let data of stream) { for await (let data of stream) {
console.log("original chunk:", data) console.log("original chunk:", data)
if (isFirstChunk) { if (isFirstChunk) {
@@ -326,6 +327,12 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
data = lines.join("\n") 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) console.log(`parsed chunk:`, data)
this.fullOutput += data this.fullOutput += data
if (this.isListening) { if (this.isListening) {