Files
oh-my-pi/packages/coding-agent/test/input-controller-thinking-visibility.test.ts
T
can1357 282963ee2f feat(coding-agent): supported omitting thinking summaries
- Added `omitThinking` setting to allow instruction of upstream providers to omit thinking summaries.
- Decoupled UI-level thinking block visibility from backend data retrieval.
- Updated session creation to use `omitThinking` for configuring provider-side summaries.
2026-06-20 08:14:54 +02:00

46 lines
2.0 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import { AssistantMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/assistant-message";
import { InputController } from "@oh-my-pi/pi-coding-agent/modes/controllers/input-controller";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
describe("InputController thinking visibility", () => {
it("keeps pre-stream pending transcript content mounted when Ctrl+T toggles thinking blocks", () => {
const pendingUserMessage = { kind: "pending-user" };
const loadingIndicator = { kind: "loading" };
const assistant = new AssistantMessageComponent();
const setHideThinkingBlock = vi.spyOn(assistant, "setHideThinkingBlock");
const resetDisplay = vi.fn();
const clear = vi.fn();
const addChild = vi.fn();
const rebuildChatFromMessages = vi.fn();
const set = vi.fn();
const showStatus = vi.fn();
const children = [pendingUserMessage, assistant, loadingIndicator];
const chatContainer = { children, clear, addChild };
const ctx = {
hideThinkingBlock: false,
settings: { set },
session: { agent: { hideThinkingSummary: false } },
chatContainer,
streamingComponent: undefined,
streamingMessage: undefined,
rebuildChatFromMessages,
showStatus,
ui: { resetDisplay },
} as unknown as InteractiveModeContext;
new InputController(ctx).toggleThinkingBlockVisibility();
expect(ctx.hideThinkingBlock).toBe(true);
expect(set).toHaveBeenCalledWith("hideThinkingBlock", true);
expect(ctx.session.agent.hideThinkingSummary).toBe(false);
expect(chatContainer.children).toEqual([pendingUserMessage, assistant, loadingIndicator]);
expect(clear).not.toHaveBeenCalled();
expect(addChild).not.toHaveBeenCalled();
expect(rebuildChatFromMessages).not.toHaveBeenCalled();
expect(setHideThinkingBlock).toHaveBeenCalledWith(true);
expect(resetDisplay).toHaveBeenCalledTimes(1);
expect(showStatus).toHaveBeenCalledWith("Thinking blocks: hidden");
});
});