diff --git a/src/core/tools/ExecuteCommandTool.ts b/src/core/tools/ExecuteCommandTool.ts index 58b0055b4c..5066ee166a 100644 --- a/src/core/tools/ExecuteCommandTool.ts +++ b/src/core/tools/ExecuteCommandTool.ts @@ -571,6 +571,10 @@ function formatExitStatus(exitDetails: ExitCodeDetails | undefined): string { return "Exit code: " } + if (exitDetails.aborted) { + return "Command was aborted by the user." + } + if (exitDetails.signalName) { let status = `Process terminated by signal ${exitDetails.signalName}` if (exitDetails.coreDumpPossible) { diff --git a/src/integrations/terminal/ExecaTerminalProcess.ts b/src/integrations/terminal/ExecaTerminalProcess.ts index cde5a1251f..bec0b01082 100644 --- a/src/integrations/terminal/ExecaTerminalProcess.ts +++ b/src/integrations/terminal/ExecaTerminalProcess.ts @@ -130,7 +130,7 @@ export class ExecaTerminalProcess extends BaseTerminalProcess { } } - this.emit("shell_execution_complete", { exitCode: 0 }) + this.emit("shell_execution_complete", { exitCode: 0, aborted: this.aborted }) } catch (error) { if (error instanceof ExecaError) { console.error(`[ExecaTerminalProcess#run] shell execution error: ${error.message}`) diff --git a/src/integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts b/src/integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts index c7f3ee2145..331d9864e0 100644 --- a/src/integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts +++ b/src/integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts @@ -129,7 +129,7 @@ describe("ExecaTerminalProcess", () => { const spy = vitest.fn() terminalProcess.on("shell_execution_complete", spy) await terminalProcess.run("echo test") - expect(spy).toHaveBeenCalledWith({ exitCode: 0 }) + expect(spy).toHaveBeenCalledWith({ exitCode: 0, aborted: false }) }) it("should emit completed event with full output", async () => { diff --git a/src/integrations/terminal/types.ts b/src/integrations/terminal/types.ts index 8224875b60..be494a1e2f 100644 --- a/src/integrations/terminal/types.ts +++ b/src/integrations/terminal/types.ts @@ -72,4 +72,10 @@ export interface ExitCodeDetails { signal?: number | undefined signalName?: string coreDumpPossible?: boolean + /** + * Set to true when the user explicitly pressed the Abort button + * to terminate the command, as opposed to the process exiting on its own + * or being killed by the OS (e.g., OOM-killer). + */ + aborted?: boolean }