fix(coding-agent): stabilize user message OSC 133 padding closes #3090

This commit is contained in:
Mario Zechner
2026-04-17 00:22:39 +02:00
parent 624a7f794f
commit b0490310c3
3 changed files with 35 additions and 7 deletions

View File

@@ -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;
}
}