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
@@ -166,13 +166,35 @@ export async function readScreenAsync(surface: string, lines = 50): Promise<stri
return stdout;
}
export async function isSurfaceAlive(surface: string, signal?: AbortSignal): Promise<boolean> {
try {
requireHerdr();
await execFileAsync(
"herdr",
["pane", "read", surface, "--source", "recent-unwrapped", "--lines", "1"],
{ encoding: "utf8", timeout: 5_000, killSignal: "SIGKILL", signal },
);
return true;
} catch {
return false;
}
}
export function closeSurface(surface: string): void {
requireHerdr();
const tabId = tabByPane.get(surface);
if (tabId) {
execFileSync("herdr", ["tab", "close", tabId], { encoding: "utf8" });
try {
execFileSync("herdr", ["tab", "close", tabId], { encoding: "utf8" });
} catch {
// Replaced-shell launches may close their own tab before watcher cleanup.
}
tabByPane.delete(surface);
return;
}
execFileSync("herdr", ["pane", "close", surface], { encoding: "utf8" });
try {
execFileSync("herdr", ["pane", "close", surface], { encoding: "utf8" });
} catch {
// Closing an already-ended pane is idempotent cleanup.
}
}