fix(todo-continuation-enforcer): defer prune interval to first idle event
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -8,6 +8,7 @@ declare module "bun:test" {
|
||||
|
||||
import { afterAll, afterEach, describe, expect, it, mock } from "bun:test"
|
||||
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import * as actualSessionStateModule from "./session-state"
|
||||
import type { SessionStateStore } from "./session-state"
|
||||
|
||||
@@ -37,6 +38,12 @@ function createMockPluginInput(): PluginInput {
|
||||
} as PluginInput
|
||||
}
|
||||
|
||||
function createMockBackgroundManager(): BackgroundManager {
|
||||
return {
|
||||
getTasksByParentSession: () => [{ status: "running" }],
|
||||
} as BackgroundManager
|
||||
}
|
||||
|
||||
function getCreatedSessionStateStore(): SessionStateStore {
|
||||
if (!createdSessionStateStore) {
|
||||
throw new Error("expected session state store to be created")
|
||||
@@ -68,7 +75,7 @@ describe("todo-continuation-enforcer dispose", () => {
|
||||
enforcer.dispose()
|
||||
})
|
||||
|
||||
it("#given enforcer with active session states #when dispose is called #then internal session state store is shut down", () => {
|
||||
it("#given enforcer with active session states #when dispose is called #then internal session state store is shut down", async () => {
|
||||
// given
|
||||
const originalClearInterval = globalThis.clearInterval
|
||||
const clearIntervalCalls: Array<Parameters<typeof clearInterval>[0]> = []
|
||||
@@ -78,9 +85,13 @@ describe("todo-continuation-enforcer dispose", () => {
|
||||
}) as typeof clearInterval
|
||||
|
||||
try {
|
||||
const enforcer = createTodoContinuationEnforcer(createMockPluginInput())
|
||||
const enforcer = createTodoContinuationEnforcer(createMockPluginInput(), {
|
||||
backgroundManager: createMockBackgroundManager(),
|
||||
})
|
||||
const sessionStateStore = getCreatedSessionStateStore()
|
||||
|
||||
await enforcer.handler({ event: { type: "session.idle", properties: { sessionID: "session-1" } } })
|
||||
|
||||
enforcer.markRecovering("session-1")
|
||||
enforcer.markRecovering("session-2")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user