Files
oh-my-pi/packages/coding-agent/src/modes/utils/interactive-context-helpers.ts
T
2026-08-02 22:59:48 -04:00

32 lines
1.2 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.setToolResultImagesVisible(!ctx.hideToolActivity);
component.setExpanded(ctx.toolOutputExpanded);
return component;
}