fix(delegate-task): pause timeouts for active sessions
This commit is contained in:
@@ -79,6 +79,52 @@ describe("syncPollTimeoutMs threading", () => {
|
||||
expect(abortCount).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
test("#then active OpenCode statuses do not consume the inactivity timeout", async () => {
|
||||
const { pollSyncSession } = require("./sync-session-poller")
|
||||
let abortCount = 0
|
||||
let statusCallCount = 0
|
||||
let messageCallCount = 0
|
||||
const mockClient = {
|
||||
session: {
|
||||
abort: async () => {
|
||||
abortCount++
|
||||
},
|
||||
messages: async () => {
|
||||
messageCallCount++
|
||||
return {
|
||||
data: [
|
||||
{ info: { id: "msg_001", role: "user", time: { created: 1000 } } },
|
||||
{
|
||||
info: { id: "msg_002", role: "assistant", time: { created: 2000 }, finish: "stop" },
|
||||
parts: [{ type: "text", text: "done" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
status: async () => {
|
||||
statusCallCount++
|
||||
if (statusCallCount === 1) return { data: { ses_active: { type: "busy" } } }
|
||||
if (statusCallCount === 2) return { data: { ses_active: { type: "retry" } } }
|
||||
return { data: { ses_active: { type: "idle" } } }
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
await withMockedDateNow(60_000, async () => {
|
||||
const result = await pollSyncSession(createMockCtx(), mockClient, {
|
||||
sessionID: "ses_active",
|
||||
agentToUse: "oracle",
|
||||
toastManager: null,
|
||||
taskId: undefined,
|
||||
}, 120_000)
|
||||
|
||||
expect(result).toBeNull()
|
||||
expect(abortCount).toBe(0)
|
||||
expect(statusCallCount).toBe(3)
|
||||
expect(messageCallCount).toBe(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when timeoutMs is omitted", () => {
|
||||
|
||||
Reference in New Issue
Block a user