9f16ca4797
- Added new `tui.tight` setting with default `false` and documented behavior. - Added global tight-mode APIs and `setIgnoreTight` propagation across Box, Text, and Markdown. - Handled `tui.tight` updates to refresh UI borders and trigger rerendering. - Updated key message components to ignore tight mode selectively and preserve intended spacing.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { TextContent } from "@oh-my-pi/pi-ai";
|
||
import { Container, Markdown, Text } from "@oh-my-pi/pi-tui";
|
||
import type { CollabPromptDetails } from "../../collab/protocol";
|
||
import type { CustomMessage } from "../../session/messages";
|
||
import { getMarkdownTheme, theme } from "../theme/theme";
|
||
|
||
/**
|
||
* Renders a collab guest prompt on every participant's transcript: a
|
||
* user-message-styled bubble prefixed with the author's name.
|
||
*/
|
||
export class CollabPromptMessageComponent extends Container {
|
||
constructor(message: CustomMessage<CollabPromptDetails>) {
|
||
super();
|
||
const from = message.details?.from?.trim() || "guest";
|
||
const authorText = new Text(theme.fg("accent", `\x1b[1m«${from}»\x1b[22m ›`), 1, 0);
|
||
authorText.setIgnoreTight(true);
|
||
this.addChild(authorText);
|
||
const text =
|
||
typeof message.content === "string"
|
||
? message.content
|
||
: message.content
|
||
.filter((content): content is TextContent => content.type === "text")
|
||
.map(content => content.text)
|
||
.join("");
|
||
const md = new Markdown(text, 1, 1, getMarkdownTheme(), {
|
||
bgColor: (value: string) => theme.bg("userMessageBg", value),
|
||
color: (value: string) => theme.fg("userMessageText", value),
|
||
});
|
||
md.setIgnoreTight(true);
|
||
this.addChild(md);
|
||
}
|
||
}
|