Skip to content

Commit f8ec048

Browse files
committed
fix: propagate thinking level changes to existing components and use viewSession
Address 4 P2 review comments on PR #3314: 1. effectiveHideThinkingBlock now uses viewSession.thinkingLevel instead of session.thinkingLevel — in focused-agent mode, the viewed transcript may have a different thinking level than the main session. 2. thinking_level_changed handler now iterates existing AssistantMessageComponent children and calls setHideThinkingBlock with the new effective value, then resetDisplay() to repaint. Previously only new/streaming messages got the updated visibility. 3. Changed AssistantMessageComponent import from type-only to value import for instanceof check. 4. Agent Hub callback already uses effectiveHideThinkingBlock which now reflects viewSession — no separate fix needed.
1 parent ff249f1 commit f8ec048

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { INTENT_FIELD } from "@oh-my-pi/pi-wire";
55
import { extractTextContent } from "../../commit/utils";
66
import { settings } from "../../config/settings";
77
import { getFileSnapshotStore } from "../../edit/file-snapshot-store";
8-
import type { AssistantMessageComponent } from "../../modes/components/assistant-message";
8+
import { AssistantMessageComponent } from "../../modes/components/assistant-message";
99
import { detectCacheInvalidation } from "../../modes/components/cache-invalidation-marker";
1010
import {
1111
ReadToolGroupComponent,
@@ -120,7 +120,20 @@ export class EventController {
120120
thinking_level_changed: async () => {
121121
this.ctx.statusLine.invalidate();
122122
this.ctx.updateEditorBorderColor();
123-
this.ctx.ui.requestRender();
123+
// Propagate visibility to existing rendered messages — thinking level
124+
// changes mid-session must update already-rendered AssistantMessageComponents,
125+
// not just new ones. Streaming reads effectiveHideThinkingBlock at construction.
126+
const hideThinking = this.ctx.effectiveHideThinkingBlock;
127+
for (const child of this.ctx.chatContainer.children) {
128+
if (child instanceof AssistantMessageComponent) {
129+
child.setHideThinkingBlock(hideThinking);
130+
}
131+
}
132+
if (this.ctx.streamingComponent && this.ctx.streamingMessage) {
133+
this.ctx.streamingComponent.setHideThinkingBlock(hideThinking);
134+
this.ctx.streamingComponent.updateContent(this.ctx.streamingMessage);
135+
}
136+
this.ctx.ui.resetDisplay();
124137
},
125138
goal_updated: async () => {},
126139
} satisfies AgentSessionEventHandlers;

packages/coding-agent/src/modes/interactive-mode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export class InteractiveMode implements InteractiveModeContext {
414414
* respects the user's intent when they set thinking to "off" (#626).
415415
*/
416416
get effectiveHideThinkingBlock(): boolean {
417-
return this.hideThinkingBlock || (this.session?.thinkingLevel ?? ThinkingLevel.Off) === ThinkingLevel.Off;
417+
return this.hideThinkingBlock || (this.viewSession?.thinkingLevel ?? ThinkingLevel.Off) === ThinkingLevel.Off;
418418
}
419419
proseOnlyThinking = true;
420420
compactionQueuedMessages: CompactionQueuedMessage[] = [];

0 commit comments

Comments
 (0)