32 lines
1.2 KiB
TypeScript
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;
|
|
}
|