fix: respect focused session thinking toggle
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user