Browse Source

Set busy flag on ExecaTerminal so it reports in env details when backgrounded (#3031)

* Set busy flag on ExecaTerminal so it reports in env details when backgrounded

* Revert this
Chris Estreich 10 months ago
parent
commit
8df1ee0252

+ 5 - 5
src/core/Cline.ts

@@ -2053,15 +2053,15 @@ export class Cline extends EventEmitter<ClineEvents> {
 			...TerminalRegistry.getBackgroundTerminals(false),
 		]
 
-		if (busyTerminals.length > 0 && this.didEditFile) {
-			await delay(300) // delay after saving file to let terminals catch up
-		}
-
 		if (busyTerminals.length > 0) {
+			if (this.didEditFile) {
+				await delay(300) // Delay after saving file to let terminals catch up.
+			}
+
 			// Wait for terminals to cool down.
 			await pWaitFor(() => busyTerminals.every((t) => !TerminalRegistry.isProcessHot(t.id)), {
 				interval: 100,
-				timeout: 15_000,
+				timeout: 5_000,
 			}).catch(() => {})
 		}
 

+ 2 - 0
src/integrations/terminal/ExecaTerminal.ts

@@ -16,6 +16,8 @@ export class ExecaTerminal extends BaseTerminal {
 	}
 
 	public override runCommand(command: string, callbacks: RooTerminalCallbacks): RooTerminalProcessResultPromise {
+		this.busy = true
+
 		const process = new ExecaTerminalProcess(this)
 		process.command = command
 		this.process = process

+ 4 - 0
src/integrations/terminal/ExecaTerminalProcess.ts

@@ -11,6 +11,10 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
 		super()
 
 		this.terminalRef = new WeakRef(terminal)
+
+		this.once("completed", () => {
+			this.terminal.busy = false
+		})
 	}
 
 	public get terminal(): RooTerminal {

+ 3 - 3
src/integrations/terminal/Terminal.ts

@@ -41,9 +41,9 @@ export class Terminal extends BaseTerminal {
 	}
 
 	public override runCommand(command: string, callbacks: RooTerminalCallbacks): RooTerminalProcessResultPromise {
-		// We set busy before the command is running because the terminal may be waiting
-		// on terminal integration, and we must prevent another instance from selecting
-		// the terminal for use during that time.
+		// We set busy before the command is running because the terminal may be
+		// waiting on terminal integration, and we must prevent another instance
+		// from selecting the terminal for use during that time.
 		this.busy = true
 
 		const process = new TerminalProcess(this)