Skip to content

Commit 5c8318d

Browse files
committed
fix(tui): guard both no-op cases for thinking toggle when thinking is off
1 parent fcdd563 commit 5c8318d

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,8 +1525,9 @@ export class InputController {
15251525
toggleThinkingBlockVisibility(): void {
15261526
// When thinking is "off", thinking blocks are always hidden (some
15271527
// providers return them regardless). The toggle is meaningless in
1528-
// that state — inform the user instead of silently no-op'ing.
1529-
if (this.ctx.effectiveHideThinkingBlock && !this.ctx.hideThinkingBlock) {
1528+
// that state regardless of the persisted preference — inform the
1529+
// user instead of silently flipping the persisted value.
1530+
if (this.ctx.effectiveHideThinkingBlock) {
15301531
this.ctx.showStatus("Thinking is off — enable thinking to show blocks");
15311532
return;
15321533
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,35 @@ describe("InputController thinking visibility", () => {
7474
expect(resetDisplay).not.toHaveBeenCalled();
7575
expect(showStatus).toHaveBeenCalledWith("Thinking is off — enable thinking to show blocks");
7676
});
77+
it("refuses to toggle when thinking is off even if hideThinkingBlock is already true", () => {
78+
// The persisted preference may already be true from a prior session
79+
// where thinking was on. With thinking off, effectiveHideThinkingBlock
80+
// is true regardless, so any toggle is a no-op — guard it rather than
81+
// flipping the persisted preference back to false.
82+
const assistant = new AssistantMessageComponent();
83+
const setHideThinkingBlock = vi.spyOn(assistant, "setHideThinkingBlock");
84+
const set = vi.fn();
85+
const showStatus = vi.fn();
86+
const resetDisplay = vi.fn();
87+
const ctx = {
88+
hideThinkingBlock: true,
89+
effectiveHideThinkingBlock: true, // thinking is off → effective is true
90+
settings: { set },
91+
session: { agent: { hideThinkingSummary: false } },
92+
chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() },
93+
streamingComponent: undefined,
94+
streamingMessage: undefined,
95+
showStatus,
96+
ui: { resetDisplay },
97+
} as unknown as InteractiveModeContext;
98+
99+
new InputController(ctx).toggleThinkingBlockVisibility();
100+
101+
// Persisted preference unchanged, no component updates, no reset.
102+
expect(ctx.hideThinkingBlock).toBe(true);
103+
expect(set).not.toHaveBeenCalled();
104+
expect(setHideThinkingBlock).not.toHaveBeenCalled();
105+
expect(resetDisplay).not.toHaveBeenCalled();
106+
expect(showStatus).toHaveBeenCalledWith("Thinking is off — enable thinking to show blocks");
107+
});
77108
});

0 commit comments

Comments
 (0)