diff --git a/packages/coding-agent/src/modes/controllers/input-controller.ts b/packages/coding-agent/src/modes/controllers/input-controller.ts index e77b4e0e4..bb48391f5 100644 --- a/packages/coding-agent/src/modes/controllers/input-controller.ts +++ b/packages/coding-agent/src/modes/controllers/input-controller.ts @@ -1690,7 +1690,7 @@ export class InputController { // 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; + const thinkingOff = ((this.ctx.viewSession ?? 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 d4d4219d4..b059e002f 100644 --- a/packages/coding-agent/test/input-controller-thinking-visibility.test.ts +++ b/packages/coding-agent/test/input-controller-thinking-visibility.test.ts @@ -74,6 +74,35 @@ describe("InputController thinking visibility", () => { expect(resetDisplay).not.toHaveBeenCalled(); expect(showStatus).toHaveBeenCalledWith("Thinking is off — enable thinking to show blocks"); }); + + it("refuses to toggle when the focused view session has thinking off", () => { + const assistant = new AssistantMessageComponent(); + const setHideThinkingBlock = vi.spyOn(assistant, "setHideThinkingBlock"); + const set = vi.fn(); + const showStatus = vi.fn(); + const resetDisplay = vi.fn(); + const ctx = { + hideThinkingBlock: false, + effectiveHideThinkingBlock: true, + settings: { set }, + session: { agent: { hideThinkingSummary: false }, thinkingLevel: "high" }, + viewSession: { thinkingLevel: "off" }, + chatContainer: { children: [assistant], clear: vi.fn(), addChild: vi.fn() }, + streamingComponent: undefined, + streamingMessage: undefined, + showStatus, + ui: { resetDisplay }, + } as unknown as InteractiveModeContext; + + new InputController(ctx).toggleThinkingBlockVisibility(); + + expect(ctx.hideThinkingBlock).toBe(false); + expect(set).not.toHaveBeenCalled(); + expect(setHideThinkingBlock).not.toHaveBeenCalled(); + expect(resetDisplay).not.toHaveBeenCalled(); + expect(showStatus).toHaveBeenCalledWith("Thinking is off — enable thinking to show blocks"); + }); + it("refuses to toggle when thinking is off even if hideThinkingBlock is already true", () => { // The persisted preference may already be true from a prior session // where thinking was on. With thinking off, effectiveHideThinkingBlock