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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user