From 428a18c748d9642077c658e4dae83f5d0020032f Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 14:17:07 +0900 Subject: [PATCH] test(prompt-gate): tighten dispatch route regressions --- .../non-abort-error-continuation.test.ts | 31 +++++++++---------- src/hooks/shared/prompt-async-gate.test.ts | 2 ++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/hooks/ralph-loop/non-abort-error-continuation.test.ts b/src/hooks/ralph-loop/non-abort-error-continuation.test.ts index c0b3a63db..b325d6a63 100644 --- a/src/hooks/ralph-loop/non-abort-error-continuation.test.ts +++ b/src/hooks/ralph-loop/non-abort-error-continuation.test.ts @@ -11,21 +11,29 @@ describe("ralph-loop non-abort error continuation", () => { const testDirectory = join(tmpdir(), `ralph-loop-non-abort-error-${Date.now()}`) let promptCalls: Array<{ sessionID: string; text: string }> let messagesCalls: Array<{ sessionID: string }> + let syncPromptCalls: number beforeEach(() => { promptCalls = [] messagesCalls = [] + syncPromptCalls = 0 mkdirSync(testDirectory, { recursive: true }) clearState(testDirectory) }) afterEach(() => { + expect(syncPromptCalls).toBe(0) clearState(testDirectory) if (existsSync(testDirectory)) { rmSync(testDirectory, { recursive: true, force: true }) } }) + async function failSyncPrompt(): Promise { + syncPromptCalls += 1 + throw new Error("Ralph Loop runtime-error continuation must use promptAsync") + } + test("continues immediately after non-abort session error", async () => { // given - an active Ralph Loop receives a recoverable command error const hook = createRalphLoopHook({ @@ -50,16 +58,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async (options: { - path: { id: string } - body: { parts: Array<{ type: string; text: string }> } - }) => { - promptCalls.push({ - sessionID: options.path.id, - text: options.body.parts[0]?.text ?? "", - }) - return {} - }, + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -113,7 +112,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -172,7 +171,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -248,7 +247,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -325,7 +324,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -401,7 +400,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), @@ -460,7 +459,7 @@ describe("ralph-loop non-abort error continuation", () => { }) return {} }, - prompt: async () => ({}), + prompt: failSyncPrompt, }, tui: { showToast: async () => ({}), diff --git a/src/hooks/shared/prompt-async-gate.test.ts b/src/hooks/shared/prompt-async-gate.test.ts index c45518534..05aefbbaa 100644 --- a/src/hooks/shared/prompt-async-gate.test.ts +++ b/src/hooks/shared/prompt-async-gate.test.ts @@ -10,6 +10,7 @@ import { describe("dispatchInternalPrompt", () => { afterEach(() => { // then + _setPromptGateMessagesFetchTimeoutMsForTesting(undefined) releaseAllPromptAsyncReservationsForTesting() }) @@ -126,6 +127,7 @@ describe("dispatchInternalPrompt", () => { describe("dispatchInternalPrompt shared gate behavior", () => { afterEach(() => { // then + _setPromptGateMessagesFetchTimeoutMsForTesting(undefined) releaseAllPromptAsyncReservationsForTesting() })