fix(cli): treat missing session status as idle in run completion

This commit is contained in:
YeonGyu-Kim
2026-04-13 22:57:12 +09:00
parent 4ce1dde32d
commit 1b36194b51
2 changed files with 24 additions and 0 deletions
+21
View File
@@ -235,6 +235,27 @@ describe("pollForCompletion", () => {
expect(result).toBe(0)
})
it("treats missing main session status as idle when status API omits idle sessions", async () => {
//#given - latest opencode omits idle sessions from the status map
const ctx = createMockContext({
statuses: {},
})
const eventState = createEventState()
eventState.mainSessionIdle = false
eventState.hasReceivedMeaningfulWork = true
const abortController = new AbortController()
//#when
const result = await pollForCompletion(ctx, eventState, abortController, {
pollIntervalMs: 10,
requiredConsecutive: 2,
minStabilizationMs: 10,
})
//#then - missing entry is treated as idle instead of hanging forever
expect(result).toBe(0)
})
it("allows silent completion after stabilization when no meaningful work is received", async () => {
//#given - session is idle and stable but no assistant message/tool event arrived
const ctx = createMockContext()
+3
View File
@@ -193,6 +193,9 @@ async function getMainSessionStatus(
statusesRes,
{} as Record<string, { type?: string }>
)
if (!(ctx.sessionID in statuses)) {
return "idle"
}
const status = statuses[ctx.sessionID]?.type
if (status === "idle" || status === "busy" || status === "retry") {
return status