Files
oh-my-pi/packages/coding-agent/src/modes/utils/interactive-context-helpers.ts
T
roboomp 62d8b0d3ad fix(tui): initialized provider errors from expand state
New live, rebuilt, and transcript-builder assistant components now inherit the active tool-output expansion state before provider errors render.

Added regression coverage for an error arriving after expanded mode was already enabled.

Fixes #6555
2026-07-25 00:32:52 +00:00

31 lines
1.1 KiB
TypeScript

/**
* Small helpers over {@link InteractiveModeContext} shared between
* {@link UiHelpers} and the input/event controllers, so the live chat surfaces
* construct components and reset editor state identically.
*/
import type { AssistantMessage } from "@oh-my-pi/pi-ai";
import { AssistantMessageComponent } from "../components/assistant-message";
import type { InteractiveModeContext } from "../types";
/**
* Construct an {@link AssistantMessageComponent} wired to the live context's
* thinking/image settings. `message` is omitted for the streaming placeholder
* component and supplied when rendering a persisted turn.
*/
export function createAssistantMessageComponent(
ctx: InteractiveModeContext,
message?: AssistantMessage,
): AssistantMessageComponent {
const component = new AssistantMessageComponent(
message,
ctx.effectiveHideThinkingBlock,
() => ctx.ui.requestRender(),
ctx.viewSession.extensionRunner?.getAssistantThinkingRenderers(),
ctx.ui.imageBudget,
ctx.proseOnlyThinking,
);
component.setImagesVisible(ctx.settings.get("terminal.showImages"));
component.setExpanded(ctx.toolOutputExpanded);
return component;
}