From 39883fd8bf38c8782343829f97e7d4a38fb7c8ef Mon Sep 17 00:00:00 2001 From: metaphorics <152830360+metaphorics@users.noreply.github.com> Date: Sun, 14 Jun 2026 08:54:29 +0900 Subject: [PATCH] test(coding-agent): type clearQueue stub to drop unsafe cast in restore test Address PR review: the makeCtx session stub typed clearQueue() as returning string[], forcing an `as unknown as` cast when the ordering test overrode it with message objects. Type the stub to the real RestoredQueuedMessage[] shape so the override needs no cast and shape drift is caught at compile time. --- .../test/input-controller-compaction-image.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/coding-agent/test/input-controller-compaction-image.test.ts b/packages/coding-agent/test/input-controller-compaction-image.test.ts index 64466253c..7079e54dd 100644 --- a/packages/coding-agent/test/input-controller-compaction-image.test.ts +++ b/packages/coding-agent/test/input-controller-compaction-image.test.ts @@ -21,6 +21,7 @@ import { InputController } from "@oh-my-pi/pi-coding-agent/modes/controllers/inp import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { CompactionQueuedMessage, InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; import { UiHelpers } from "@oh-my-pi/pi-coding-agent/modes/utils/ui-helpers"; +import type { RestoredQueuedMessage } from "@oh-my-pi/pi-coding-agent/session/agent-session"; beforeAll(() => { initTheme(); @@ -39,7 +40,7 @@ function makeCtx(initialQueue: CompactionQueuedMessage[] = []) { extensionRunner: undefined, customCommands: [] as Array<{ command: { name: string } }>, getQueuedMessages: () => ({ steering: [] as string[], followUp: [] as string[] }), - clearQueue: () => ({ steering: [] as string[], followUp: [] as string[] }), + clearQueue: () => ({ steering: [] as RestoredQueuedMessage[], followUp: [] as RestoredQueuedMessage[] }), prompt: mock(async (text: string, opts?: PromptOpts): Promise => { promptCalls.push({ text, opts }); }), @@ -155,7 +156,7 @@ describe("compaction queue Alt+Up restore", () => { { text: "compaction steer", mode: "steer", images: undefined }, { text: "compaction followup", mode: "followUp", images: undefined }, ]); - (session as unknown as { clearQueue: () => unknown }).clearQueue = () => ({ + session.clearQueue = () => ({ steering: [{ text: "session steer" }], followUp: [{ text: "session followup" }], });