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:
parent
5f9cfcbcf3
commit
0d888df879
@ -143,7 +143,7 @@ describe("checkCompletionConditions", () => {
|
|||||||
expect(result).toBe(false)
|
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
|
// given
|
||||||
spyOn(console, "log").mockImplementation(() => {})
|
spyOn(console, "log").mockImplementation(() => {})
|
||||||
const ctx = createMockContext({
|
const ctx = createMockContext({
|
||||||
@ -158,6 +158,28 @@ describe("checkCompletionConditions", () => {
|
|||||||
// when
|
// when
|
||||||
const result = await checkCompletionConditions(ctx)
|
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
|
// then
|
||||||
expect(result).toBe(false)
|
expect(result).toBe(false)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -86,14 +86,7 @@ async function areAllDescendantsIdle(
|
|||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
const status = allStatuses[child.id]
|
const status = allStatuses[child.id]
|
||||||
if (!status) {
|
if (status && status.type !== "idle") {
|
||||||
console.log(
|
|
||||||
pc.dim(` Waiting: session ${child.id.slice(0, 8)}... status unknown`)
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.type !== "idle") {
|
|
||||||
console.log(
|
console.log(
|
||||||
pc.dim(` Waiting: session ${child.id.slice(0, 8)}... is ${status.type}`)
|
pc.dim(` Waiting: session ${child.id.slice(0, 8)}... is ${status.type}`)
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user