fix(interactive-subagents): harden parallel lifecycle delivery
This commit is contained in:
@@ -281,11 +281,13 @@ async function readScreenWithCli(
|
||||
surface: string,
|
||||
lines: number,
|
||||
timeout = ASYNC_READ_SCREEN_TIMEOUT_MS,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string> {
|
||||
const { stdout } = await execFileAsync(cli, readScreenArgs(surface, lines), {
|
||||
encoding: "utf8",
|
||||
timeout,
|
||||
killSignal: "SIGKILL",
|
||||
signal,
|
||||
});
|
||||
return parseReadTail(stdout);
|
||||
}
|
||||
@@ -294,6 +296,15 @@ export async function readScreenAsync(surface: string, lines = 50): Promise<stri
|
||||
return readScreenWithCli(requireOrca(), surface, lines);
|
||||
}
|
||||
|
||||
export async function isSurfaceAlive(surface: string, signal?: AbortSignal): Promise<boolean> {
|
||||
try {
|
||||
await readScreenWithCli(requireOrca(), surface, 1, ASYNC_READ_SCREEN_TIMEOUT_MS, signal);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const __orcaTest__ = { readScreenWithCli };
|
||||
|
||||
export function closeSurface(surface: string): void {
|
||||
@@ -301,7 +312,11 @@ export function closeSurface(surface: string): void {
|
||||
const args = ["terminal", "close", "--terminal", surface];
|
||||
if (tabByHandle.has(surface)) args.push("--tab");
|
||||
args.push("--json");
|
||||
const output = execFileSync(cli, args, { encoding: "utf8" });
|
||||
parseResponse("terminal close", output);
|
||||
try {
|
||||
const output = execFileSync(cli, args, { encoding: "utf8" });
|
||||
parseResponse("terminal close", output);
|
||||
} catch {
|
||||
// Replaced-shell launches may close their own terminal before cleanup.
|
||||
}
|
||||
tabByHandle.delete(surface);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user