fix(cli-run): avoid infinite wait on missing child status

Treat child sessions missing from session.status as transient so completion polling can proceed while still blocking on explicit non-idle descendants.
This commit is contained in:
YeonGyu-Kim 2026-02-17 16:15:25 +09:00
parent 5f9cfcbcf3
commit 0d888df879
2 changed files with 24 additions and 9 deletions

View File

@ -143,7 +143,7 @@ describe("checkCompletionConditions", () => {
expect(result).toBe(false)
})
it("returns false when child status is missing", async () => {
it("returns true when child status is missing but descendants are idle", async () => {
// given
spyOn(console, "log").mockImplementation(() => {})
const ctx = createMockContext({
@ -158,6 +158,28 @@ describe("checkCompletionConditions", () => {
// when
const result = await checkCompletionConditions(ctx)
// then
expect(result).toBe(true)
})
it("returns false when descendant is busy even if parent status is missing", async () => {
// given
spyOn(console, "log").mockImplementation(() => {})
const ctx = createMockContext({
childrenBySession: {
"test-session": [{ id: "child-1" }],
"child-1": [{ id: "grandchild-1" }],
"grandchild-1": [],
},
statuses: {
"grandchild-1": { type: "busy" },
},
})
const { checkCompletionConditions } = await import("./completion")
// when
const result = await checkCompletionConditions(ctx)
// then
expect(result).toBe(false)
})

View File

@ -86,14 +86,7 @@ async function areAllDescendantsIdle(
for (const child of children) {
const status = allStatuses[child.id]
if (!status) {
console.log(
pc.dim(` Waiting: session ${child.id.slice(0, 8)}... status unknown`)
)
return false
}
if (status.type !== "idle") {
if (status && status.type !== "idle") {
console.log(
pc.dim(` Waiting: session ${child.id.slice(0, 8)}... is ${status.type}`)
)