Skip to content

Commit ff249f1

Browse files
committed
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.
1 parent c77fdff commit ff249f1

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/coding-agent/src/modes/controllers/input-controller.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "node:fs/promises";
22
import * as path from "node:path";
3+
import { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
34
import type { ImageContent } from "@oh-my-pi/pi-ai";
45
import { type AutocompleteProvider, matchesKey, type SlashCommand } from "@oh-my-pi/pi-tui";
56
import { $env, isEnoent, logger, sanitizeText } from "@oh-my-pi/pi-utils";
@@ -1525,9 +1526,11 @@ export class InputController {
15251526
toggleThinkingBlockVisibility(): void {
15261527
// When thinking is "off", thinking blocks are always hidden (some
15271528
// providers return them regardless). The toggle is meaningless in
1528-
// that state regardless of the persisted preference — inform the
1529-
// user instead of silently flipping the persisted value.
1530-
if (this.ctx.effectiveHideThinkingBlock) {
1529+
// that state — inform the user instead of silently flipping the
1530+
// persisted value. When thinking is on, the toggle works normally
1531+
// even if blocks are already hidden (user may want to show them).
1532+
const thinkingOff = (this.ctx.session?.thinkingLevel ?? ThinkingLevel.Off) === ThinkingLevel.Off;
1533+
if (thinkingOff) {
15311534
this.ctx.showStatus("Thinking is off — enable thinking to show blocks");
15321535
return;
15331536
}

packages/coding-agent/test/input-controller-thinking-visibility.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("InputController thinking visibility", () => {
2121
hideThinkingBlock: false,
2222
effectiveHideThinkingBlock: false,
2323
settings: { set },
24-
session: { agent: { hideThinkingSummary: false } },
24+
session: { agent: { hideThinkingSummary: false }, thinkingLevel: "high" },
2525
chatContainer,
2626
streamingComponent: undefined,
2727
streamingMessage: undefined,
@@ -57,7 +57,7 @@ describe("InputController thinking visibility", () => {
5757
hideThinkingBlock: false,
5858
effectiveHideThinkingBlock: true, // thinking is off → effective is true
5959
settings: { set },
60-
session: { agent: { hideThinkingSummary: false } },
60+
session: { agent: { hideThinkingSummary: false }, thinkingLevel: "off" },
6161
chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() },
6262
streamingComponent: undefined,
6363
streamingMessage: undefined,
@@ -88,7 +88,7 @@ describe("InputController thinking visibility", () => {
8888
hideThinkingBlock: true,
8989
effectiveHideThinkingBlock: true, // thinking is off → effective is true
9090
settings: { set },
91-
session: { agent: { hideThinkingSummary: false } },
91+
session: { agent: { hideThinkingSummary: false }, thinkingLevel: "off" },
9292
chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() },
9393
streamingComponent: undefined,
9494
streamingMessage: undefined,

0 commit comments

Comments
 (0)