fix(core): prevent race condition crash during shell auto-promotion

This commit is contained in:
Gaurav Ghosh
2026-04-08 11:51:54 -07:00
parent 4599c8e984
commit 78c25f30c5
2 changed files with 12 additions and 1 deletions
@@ -1341,6 +1341,11 @@ export class ShellExecutionService {
const activePty = this.activePtys.get(pid);
const activeChild = this.activeChildProcesses.get(pid);
// If the process has already exited, there is no need to background it.
if (!activePty && !activeChild) {
return;
}
const resolvedSessionId =
sessionId ?? activePty?.sessionId ?? activeChild?.sessionId;
const resolvedCommand =
+7 -1
View File
@@ -515,7 +515,13 @@ export class ShellToolInvocation extends BaseToolInvocation<
if (shouldAutoPromote && currentPid) {
if (this._autoPromoteTimer) clearTimeout(this._autoPromoteTimer);
this._autoPromoteTimer = setTimeout(() => {
ShellExecutionService.background(currentPid!);
const sessionId =
this.context.config?.getSessionId?.() ?? 'default';
ShellExecutionService.background(
currentPid!,
sessionId,
strippedCommand,
);
}, waitMs);
}
};