From 0d888df879114a4e0739024f2b09688ac8872630 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 17 Feb 2026 16:15:25 +0900 Subject: [PATCH] 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. --- src/cli/run/completion.test.ts | 24 +++++++++++++++++++++++- src/cli/run/completion.ts | 9 +-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/cli/run/completion.test.ts b/src/cli/run/completion.test.ts index d54ae9ea..1537d318 100644 --- a/src/cli/run/completion.test.ts +++ b/src/cli/run/completion.test.ts @@ -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) }) diff --git a/src/cli/run/completion.ts b/src/cli/run/completion.ts index 69c3c19d..f9edec9f 100644 --- a/src/cli/run/completion.ts +++ b/src/cli/run/completion.ts @@ -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}`) )