fix(interactive-subagents): harden parallel lifecycle delivery
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user