Files
orca/tests/e2e/helpers/streaming-terminal-cleanup.ts
T
Neil 339045b150 fix(runtime): coalesce concurrent host terminal focus (#11841)
Bound exclusive host navigation to a generation-aware latest-wins
single-flight so bulk open and switch fan-out stay responsive on large
remote fleets. Add freeze repro harnesses and navigated settlement.
2026-08-03 02:18:05 -07:00

28 lines
876 B
TypeScript

export async function closeStreamingTerminals(
terminals: string[],
call: (method: 'terminal.closeTab' | 'terminal.close', terminal: string) => Promise<unknown>
): Promise<void> {
const results = await Promise.allSettled(
terminals.map(async (terminal) => {
try {
await call('terminal.closeTab', terminal)
} catch (closeTabError) {
try {
await call('terminal.close', terminal)
} catch (closeError) {
throw new AggregateError(
[closeTabError, closeError],
`Failed to close streaming terminal ${terminal}`
)
}
}
})
)
const failures = results.flatMap((result) =>
result.status === 'rejected' ? [result.reason] : []
)
if (failures.length > 0) {
throw new AggregateError(failures, `Failed to close ${failures.length} streaming terminal(s)`)
}
}