diff --git a/hooks/hooks.json b/hooks/hooks.json index 3c6562c..20021cc 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -24,7 +24,8 @@ "hooks": [ { "type": "command", - "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-end-cleanup.mjs\"" + "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-end-cleanup.mjs\"", + "timeout": 15 } ] } diff --git a/tests/session-end-cleanup.test.ts b/tests/session-end-cleanup.test.ts index 1375046..fda9a88 100644 --- a/tests/session-end-cleanup.test.ts +++ b/tests/session-end-cleanup.test.ts @@ -77,6 +77,22 @@ describe("session-end-cleanup", () => { }); describe("hooks.json wiring", () => { + test("gives session cleanup enough time during contended teardown", () => { + const config = JSON.parse(readFileSync(HOOKS_CONFIG_PATH, "utf-8")) as { + hooks?: { + SessionEnd?: Array<{ + hooks?: Array<{ type?: string; command?: string; timeout?: number }>; + }>; + }; + }; + + const cleanupHook = config.hooks?.SessionEnd + ?.flatMap((entry) => entry.hooks ?? []) + .find((hook) => hook.command?.includes("session-end-cleanup.mjs")); + + expect(cleanupHook?.timeout).toBe(15); + }); + test("does not register the Agent pretooluse observer hook", () => { const config = JSON.parse(readFileSync(HOOKS_CONFIG_PATH, "utf-8")) as { hooks?: {