fix(interactive-subagents): harden parallel lifecycle delivery

This commit is contained in:
jb
2026-09-03 23:40:14 -04:00
parent d99dbce93d
commit 7a1043e5e0
11 changed files with 848 additions and 131 deletions
@@ -112,8 +112,27 @@ export async function readScreenAsync(surface: string, lines = 50): Promise<stri
return stdout;
}
export async function isSurfaceAlive(surface: string, signal?: AbortSignal): Promise<boolean> {
requireTmux();
try {
await execFileAsync("tmux", ["display-message", "-p", "-t", surface, "#{pane_id}"], {
encoding: "utf8",
timeout: 5_000,
killSignal: "SIGKILL",
signal,
});
return true;
} catch {
return false;
}
}
export function closeSurface(surface: string): void {
requireTmux();
execFileSync("tmux", ["kill-pane", "-t", surface], { encoding: "utf8" });
try {
execFileSync("tmux", ["kill-pane", "-t", surface], { encoding: "utf8" });
} catch {
// Replaced-shell launches may close their own pane before cleanup.
}
rebalanceSurfaces();
}