fix(coding-agent): stabilize user message OSC 133 padding closes #3090
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Container, Markdown, type MarkdownTheme, Spacer } from "@mariozechner/pi-tui";
|
||||
import { Box, Container, Markdown, type MarkdownTheme } from "@mariozechner/pi-tui";
|
||||
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
||||
|
||||
const OSC133_ZONE_START = "\x1b]133;A\x07";
|
||||
@@ -9,15 +9,17 @@ const OSC133_ZONE_FINAL = "\x1b]133;C\x07";
|
||||
* Component that renders a user message
|
||||
*/
|
||||
export class UserMessageComponent extends Container {
|
||||
private contentBox: Box;
|
||||
|
||||
constructor(text: string, markdownTheme: MarkdownTheme = getMarkdownTheme()) {
|
||||
super();
|
||||
this.addChild(new Spacer(1));
|
||||
this.addChild(
|
||||
new Markdown(text, 1, 1, markdownTheme, {
|
||||
bgColor: (text: string) => theme.bg("userMessageBg", text),
|
||||
color: (text: string) => theme.fg("userMessageText", text),
|
||||
this.contentBox = new Box(1, 1, (content: string) => theme.bg("userMessageBg", content));
|
||||
this.contentBox.addChild(
|
||||
new Markdown(text, 0, 0, markdownTheme, {
|
||||
color: (content: string) => theme.fg("userMessageText", content),
|
||||
}),
|
||||
);
|
||||
this.addChild(this.contentBox);
|
||||
}
|
||||
|
||||
override render(width: number): string[] {
|
||||
@@ -27,7 +29,7 @@ export class UserMessageComponent extends Container {
|
||||
}
|
||||
|
||||
lines[0] = OSC133_ZONE_START + lines[0];
|
||||
lines[lines.length - 1] = lines[lines.length - 1] + OSC133_ZONE_END + OSC133_ZONE_FINAL;
|
||||
lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user