fix(hooks): settle idle prompt continuations

This commit is contained in:
YeonGyu-Kim
2026-05-10 12:55:36 +09:00
parent 806842981f
commit 1ea4dfe215
8 changed files with 118 additions and 1 deletions
+35
View File
@@ -68,6 +68,7 @@ describe("atlas hook", () => {
): ReturnType<typeof createAtlasHook> {
const resolvedOptions: AtlasHookOptions = {
directory: TEST_DIR,
idleSettleMs: 0,
isCallerOrchestrator: async (sessionID) => callerAgentBySession.get(sessionID ?? "") === "atlas",
...options,
}
@@ -1346,6 +1347,40 @@ session_id: ses_untrusted_999
expect(callArgs.body.parts[0].text).toContain("2 remaining")
})
test("should settle idle before injecting boulder continuation", async () => {
// given
const planPath = join(TEST_DIR, "test-plan.md")
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [x] Task 2")
const state: BoulderState = {
active_plan: planPath,
started_at: "2026-01-02T10:00:00Z",
session_ids: [MAIN_SESSION_ID],
plan_name: "test-plan",
}
writeBoulderState(TEST_DIR, state)
const mockInput = createMockPluginInput()
const hook = createTestAtlasHook(mockInput, { idleSettleMs: 50 })
// when
const startedAt = Date.now()
const eventPromise = hook.handler({
event: {
type: "session.idle",
properties: { sessionID: MAIN_SESSION_ID },
},
})
await Promise.resolve()
// then
expect(mockInput._promptMock).not.toHaveBeenCalled()
await eventPromise
expect(Date.now() - startedAt).toBeGreaterThanOrEqual(45)
expect(mockInput._promptMock).toHaveBeenCalledTimes(1)
})
test("should not inject when no boulder state exists", async () => {
// given - no boulder state
const mockInput = createMockPluginInput()