From ff249f19e901328a0ae2425ff08d495176063d3c Mon Sep 17 00:00:00 2001 From: oldschoola Date: Tue, 23 Jun 2026 10:37:59 -0700 Subject: [PATCH] fix(tui): check thinking level directly instead of effectiveHideThinkingBlock The previous guard used effectiveHideThinkingBlock which combines hideThinkingBlock preference AND thinking-off state. When thinking was enabled but hideThinkingBlock was true (user manually hid blocks), the guard blocked the toggle, preventing users from showing blocks again via Ctrl+T. Fix: check session.thinkingLevel === Off directly, so the guard only fires when thinking is genuinely off. When thinking is on, the toggle works normally regardless of the current hideThinkingBlock preference. Updated tests to set thinkingLevel on the mock context. --- .../src/modes/controllers/input-controller.ts | 9 ++++++--- .../test/input-controller-thinking-visibility.test.ts | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) 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,