From 8df1ee0252c2d2c50b6f90175badfb92f4f7d2da Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Tue, 29 Apr 2025 08:55:52 -0700 Subject: [PATCH] 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 --- src/core/Cline.ts | 10 +++++----- src/integrations/terminal/ExecaTerminal.ts | 2 ++ src/integrations/terminal/ExecaTerminalProcess.ts | 4 ++++ src/integrations/terminal/Terminal.ts | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index fa74e51ddf..9778baabf4 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -2053,15 +2053,15 @@ export class Cline extends EventEmitter { ...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(() => {}) } diff --git a/src/integrations/terminal/ExecaTerminal.ts b/src/integrations/terminal/ExecaTerminal.ts index fdce5d7c84..13319a58ba 100644 --- a/src/integrations/terminal/ExecaTerminal.ts +++ b/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 diff --git a/src/integrations/terminal/ExecaTerminalProcess.ts b/src/integrations/terminal/ExecaTerminalProcess.ts index 0a54ae3aca..3a703f9097 100644 --- a/src/integrations/terminal/ExecaTerminalProcess.ts +++ b/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 { diff --git a/src/integrations/terminal/Terminal.ts b/src/integrations/terminal/Terminal.ts index 6e7aeb3c27..cd361ccb37 100644 --- a/src/integrations/terminal/Terminal.ts +++ b/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)