9bec08a952
Updated thinking visibility toggles to refresh assistant blocks in place instead of rebuilding the transcript, preserving pending user submissions and loaders before streaming starts. Added a regression test for the Ctrl+T pre-stream gap.\n\nFixes #2370
45 lines
2.0 KiB
TypeScript
45 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 invalidate = vi.spyOn(assistant, "invalidate");
|
|
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,
|
|
} as unknown as InteractiveModeContext;
|
|
|
|
new InputController(ctx).toggleThinkingBlockVisibility();
|
|
|
|
expect(ctx.hideThinkingBlock).toBe(true);
|
|
expect(set).toHaveBeenCalledWith("hideThinkingBlock", true);
|
|
expect(ctx.session.agent.hideThinkingSummary).toBe(true);
|
|
expect(chatContainer.children).toEqual([pendingUserMessage, assistant, loadingIndicator]);
|
|
expect(clear).not.toHaveBeenCalled();
|
|
expect(addChild).not.toHaveBeenCalled();
|
|
expect(rebuildChatFromMessages).not.toHaveBeenCalled();
|
|
expect(setHideThinkingBlock).toHaveBeenCalledWith(true);
|
|
expect(invalidate).toHaveBeenCalledTimes(1);
|
|
expect(showStatus).toHaveBeenCalledWith("Thinking blocks: hidden");
|
|
});
|
|
});
|