fix(coding-agent): apply output padding to user messages

closes #6168
This commit is contained in:
Mario Zechner
2026-06-30 11:55:40 +02:00
parent 6564d94717
commit 9be55bc773
8 changed files with 60 additions and 23 deletions
@@ -111,7 +111,7 @@ export class AssistantMessageComponent extends Container {
if (this.hideThinkingBlock) {
// Show static thinking label when hidden
this.contentContainer.addChild(
new Text(theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel)), 1, 0),
new Text(theme.italic(theme.fg("thinkingText", this.hiddenThinkingLabel)), this.outputPad, 0),
);
if (hasVisibleContentAfter) {
this.contentContainer.addChild(new Spacer(1));
@@ -144,7 +144,7 @@ export class AssistantMessageComponent extends Container {
"error",
"Error: Model stopped because it reached the maximum output token limit. The response may be incomplete.",
),
1,
this.outputPad,
0,
),
);
@@ -155,11 +155,11 @@ export class AssistantMessageComponent extends Container {
? message.errorMessage
: "Operation aborted";
this.contentContainer.addChild(new Spacer(1));
this.contentContainer.addChild(new Text(theme.fg("error", abortMessage), 1, 0));
this.contentContainer.addChild(new Text(theme.fg("error", abortMessage), this.outputPad, 0));
} else if (message.stopReason === "error") {
const errorMsg = message.errorMessage || "Unknown error";
this.contentContainer.addChild(new Spacer(1));
this.contentContainer.addChild(new Text(theme.fg("error", `Error: ${errorMsg}`), 1, 0));
this.contentContainer.addChild(new Text(theme.fg("error", `Error: ${errorMsg}`), this.outputPad, 0));
}
}
}
@@ -683,7 +683,7 @@ export class SettingsSelectorComponent extends Container {
items.splice(editorPaddingIndex + 1, 0, {
id: "output-padding",
label: "Output padding",
description: "Horizontal padding for assistant messages and thinking",
description: "Horizontal padding for user messages, assistant messages, and thinking",
currentValue: String(config.outputPad),
values: ["0", "1"],
});
@@ -9,24 +9,39 @@ const OSC133_ZONE_FINAL = "\x1b]133;C\x07";
* Component that renders a user message
*/
export class UserMessageComponent extends Container {
private contentBox: Box;
private text: string;
private markdownTheme: MarkdownTheme;
private outputPad: number;
constructor(text: string, markdownTheme: MarkdownTheme = getMarkdownTheme()) {
constructor(text: string, markdownTheme: MarkdownTheme = getMarkdownTheme(), outputPad = 1) {
super();
this.contentBox = new Box(1, 1, (content: string) => theme.bg("userMessageBg", content));
this.contentBox.addChild(
this.text = text;
this.markdownTheme = markdownTheme;
this.outputPad = outputPad;
this.rebuild();
}
setOutputPad(padding: number): void {
this.outputPad = padding;
this.rebuild();
}
private rebuild(): void {
this.clear();
const contentBox = new Box(this.outputPad, 1, (content: string) => theme.bg("userMessageBg", content));
contentBox.addChild(
new Markdown(
text,
this.text,
0,
0,
markdownTheme,
this.markdownTheme,
{
color: (content: string) => theme.fg("userMessageText", content),
},
{ preserveOrderedListMarkers: true, preserveBackslashEscapes: true },
),
);
this.addChild(this.contentBox);
this.addChild(contentBox);
}
override render(width: number): string[] {