diff --git a/packages/coding-agent/src/modes/controllers/input-controller.ts b/packages/coding-agent/src/modes/controllers/input-controller.ts index 723ef0116..4df00bdd6 100644 --- a/packages/coding-agent/src/modes/controllers/input-controller.ts +++ b/packages/coding-agent/src/modes/controllers/input-controller.ts @@ -1,5 +1,6 @@ import * as fs from "node:fs/promises"; import * as path from "node:path"; +import { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent } from "@oh-my-pi/pi-ai"; import { type AutocompleteProvider, matchesKey, type SlashCommand } from "@oh-my-pi/pi-tui"; import { $env, isEnoent, logger, sanitizeText } from "@oh-my-pi/pi-utils"; @@ -1525,9 +1526,11 @@ export class InputController { toggleThinkingBlockVisibility(): void { // When thinking is "off", thinking blocks are always hidden (some // providers return them regardless). The toggle is meaningless in - // that state regardless of the persisted preference — inform the - // user instead of silently flipping the persisted value. - if (this.ctx.effectiveHideThinkingBlock) { + // that state — inform the user instead of silently flipping the + // persisted value. When thinking is on, the toggle works normally + // even if blocks are already hidden (user may want to show them). + const thinkingOff = (this.ctx.session?.thinkingLevel ?? ThinkingLevel.Off) === ThinkingLevel.Off; + if (thinkingOff) { this.ctx.showStatus("Thinking is off — enable thinking to show blocks"); return; } diff --git a/packages/coding-agent/test/input-controller-thinking-visibility.test.ts b/packages/coding-agent/test/input-controller-thinking-visibility.test.ts index 42e559f13..d4d4219d4 100644 --- a/packages/coding-agent/test/input-controller-thinking-visibility.test.ts +++ b/packages/coding-agent/test/input-controller-thinking-visibility.test.ts @@ -21,7 +21,7 @@ describe("InputController thinking visibility", () => { hideThinkingBlock: false, effectiveHideThinkingBlock: false, settings: { set }, - session: { agent: { hideThinkingSummary: false } }, + session: { agent: { hideThinkingSummary: false }, thinkingLevel: "high" }, chatContainer, streamingComponent: undefined, streamingMessage: undefined, @@ -57,7 +57,7 @@ describe("InputController thinking visibility", () => { hideThinkingBlock: false, effectiveHideThinkingBlock: true, // thinking is off → effective is true settings: { set }, - session: { agent: { hideThinkingSummary: false } }, + session: { agent: { hideThinkingSummary: false }, thinkingLevel: "off" }, chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() }, streamingComponent: undefined, streamingMessage: undefined, @@ -88,7 +88,7 @@ describe("InputController thinking visibility", () => { hideThinkingBlock: true, effectiveHideThinkingBlock: true, // thinking is off → effective is true settings: { set }, - session: { agent: { hideThinkingSummary: false } }, + session: { agent: { hideThinkingSummary: false }, thinkingLevel: "off" }, chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() }, streamingComponent: undefined, streamingMessage: undefined,