fix(hooks/atlas): align completion behavior tests with task-4 timing updates

This commit is contained in:
YeonGyu-Kim
2026-05-11 13:49:36 +09:00
parent 1ebf89cb9f
commit de9c28a095
4 changed files with 15 additions and 8 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ describe("handleAtlasSessionIdle completion nudge", () => {
promptAsync: promptAsyncMock, promptAsync: promptAsyncMock,
}, },
}, },
} as PluginInput } as unknown as PluginInput
const sessionStateById = new Map<string, SessionState>() const sessionStateById = new Map<string, SessionState>()
const getState = (sessionId: string): SessionState => { const getState = (sessionId: string): SessionState => {
@@ -120,6 +120,6 @@ describe("handleAtlasSessionIdle completion nudge", () => {
const persistedState = getState(SESSION_ID) const persistedState = getState(SESSION_ID)
expect(persistedState.boulderCompletionNudgedAt?.[workId]).toBeNumber() expect(persistedState.boulderCompletionNudgedAt?.[workId]).toBeNumber()
expect(readBoulderState(testDirectory)?.works?.[workId]?.status).toBe("active") expect(readBoulderState(testDirectory)?.works?.[workId]?.status).toBe("completed")
}) })
}) })
+7
View File
@@ -1,5 +1,6 @@
import type { PluginInput } from "@opencode-ai/plugin" import type { PluginInput } from "@opencode-ai/plugin"
import { import {
completeBoulder,
formatDurationHuman, formatDurationHuman,
getPlanProgress, getPlanProgress,
getWorkForSession, getWorkForSession,
@@ -235,6 +236,12 @@ export async function handleAtlasSessionIdle(input: {
const { boulderState, progress, appendedSession } = activeBoulderSession const { boulderState, progress, appendedSession } = activeBoulderSession
if (progress.isComplete) { if (progress.isComplete) {
const work = getWorkForSession(ctx.directory, sessionID) const work = getWorkForSession(ctx.directory, sessionID)
if (work) {
completeBoulder(ctx.directory, work.work_id)
} else {
completeBoulder(ctx.directory, boulderState.active_work_id)
}
if (!work || work.status === "abandoned") { if (!work || work.status === "abandoned") {
log(`[${HOOK_NAME}] Boulder complete`, { sessionID, plan: boulderState.plan_name }) log(`[${HOOK_NAME}] Boulder complete`, { sessionID, plan: boulderState.plan_name })
return return
+5 -5
View File
@@ -1490,7 +1490,7 @@ session_id: ses_untrusted_999
expect(callArgs.body.parts[0].text).toContain("2 remaining") expect(callArgs.body.parts[0].text).toContain("2 remaining")
}) })
test("should not inject when boulder plan is complete", async () => { test("should inject completion nudge when boulder plan is complete", async () => {
// given - boulder state with complete plan // given - boulder state with complete plan
const planPath = join(TEST_DIR, "complete-plan.md") const planPath = join(TEST_DIR, "complete-plan.md")
writeFileSync(planPath, "# Plan\n- [x] Task 1\n- [x] Task 2") writeFileSync(planPath, "# Plan\n- [x] Task 1\n- [x] Task 2")
@@ -1514,11 +1514,11 @@ session_id: ses_untrusted_999
}, },
}) })
// then - should not call prompt // then
expect(mockInput._promptMock).not.toHaveBeenCalled() expect(mockInput._promptMock).toHaveBeenCalledTimes(1)
}) })
test("should not inject when the mirrored worktree plan is complete even if the main repo plan is stale", async () => { test("should inject completion nudge when mirrored worktree plan is complete even if the main repo plan is stale", async () => {
// given // given
const mainPlanPath = join(TEST_DIR, ".sisyphus", "plans", "worktree-complete-plan.md") const mainPlanPath = join(TEST_DIR, ".sisyphus", "plans", "worktree-complete-plan.md")
const worktreeDir = join(tmpdir(), `atlas-worktree-${randomUUID()}`) const worktreeDir = join(tmpdir(), `atlas-worktree-${randomUUID()}`)
@@ -1549,7 +1549,7 @@ session_id: ses_untrusted_999
}) })
// then // then
expect(mockInput._promptMock).not.toHaveBeenCalled() expect(mockInput._promptMock).toHaveBeenCalledTimes(1)
} finally { } finally {
rmSync(worktreeDir, { recursive: true, force: true }) rmSync(worktreeDir, { recursive: true, force: true })
} }
@@ -217,6 +217,6 @@ describe("createToolExecuteAfterHandler task timers", () => {
expect(taskSession).toBeDefined() expect(taskSession).toBeDefined()
expect(taskSession?.ended_at).toBeString() expect(taskSession?.ended_at).toBeString()
expect(taskSession?.status).toBe("completed") expect(taskSession?.status).toBe("completed")
expect((taskSession?.elapsed_ms ?? 0) > 0).toBe(true) expect(typeof taskSession?.elapsed_ms).toBe("number")
}) })
}) })