952bd5338d
Previously, pollRunningTasks() and checkAndInterruptStaleTasks() treated
any non-"idle" session status as "still running", which caused tasks with
terminal statuses like "interrupted" to be skipped indefinitely — both
for completion detection AND stale timeout. This made the parent session
hang forever waiting for an ALL COMPLETE notification that never came.
Extract isActiveSessionStatus() and isTerminalSessionStatus() that
classify session statuses explicitly. Only known active statuses
("busy", "retry", "running") protect tasks from completion/stale checks.
Known terminal statuses ("interrupted") trigger immediate completion.
Unknown statuses fall through to the standard idle/gone path with output
validation as a conservative default.
Introduced by: a0c93816 (2026-02-14), dc370f7f (2026-03-08)
21 lines
572 B
TypeScript
21 lines
572 B
TypeScript
import { log } from "../../shared"
|
|
|
|
const ACTIVE_SESSION_STATUSES = new Set(["busy", "retry", "running"])
|
|
const KNOWN_TERMINAL_STATUSES = new Set(["idle", "interrupted"])
|
|
|
|
export function isActiveSessionStatus(type: string): boolean {
|
|
if (ACTIVE_SESSION_STATUSES.has(type)) {
|
|
return true
|
|
}
|
|
|
|
if (!KNOWN_TERMINAL_STATUSES.has(type)) {
|
|
log("[background-agent] Unknown session status type encountered:", type)
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
export function isTerminalSessionStatus(type: string): boolean {
|
|
return KNOWN_TERMINAL_STATUSES.has(type) && type !== "idle"
|
|
}
|