fix(coding-agent): restore assistant/user turn spacing

This commit is contained in:
Mario Zechner
2026-04-17 00:52:14 +02:00
parent e5f86f25f2
commit 3ba0d85fa2
4 changed files with 100 additions and 20 deletions

View File

@@ -2,6 +2,10 @@ import type { AssistantMessage } from "@mariozechner/pi-ai";
import { Container, Markdown, type MarkdownTheme, Spacer, Text } from "@mariozechner/pi-tui";
import { getMarkdownTheme, theme } from "../theme/theme.js";
const OSC133_ZONE_START = "\x1b]133;A\x07";
const OSC133_ZONE_END = "\x1b]133;B\x07";
const OSC133_ZONE_FINAL = "\x1b]133;C\x07";
/**
* Component that renders a complete assistant message
*/
@@ -11,6 +15,7 @@ export class AssistantMessageComponent extends Container {
private markdownTheme: MarkdownTheme;
private hiddenThinkingLabel: string;
private lastMessage?: AssistantMessage;
private hasToolCalls = false;
constructor(
message?: AssistantMessage,
@@ -54,6 +59,17 @@ export class AssistantMessageComponent extends Container {
}
}
override render(width: number): string[] {
const lines = super.render(width);
if (this.hasToolCalls || lines.length === 0) {
return lines;
}
lines[0] = OSC133_ZONE_START + lines[0];
lines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];
return lines;
}
updateContent(message: AssistantMessage): void {
this.lastMessage = message;
@@ -108,6 +124,7 @@ export class AssistantMessageComponent extends Container {
// Check if aborted - show after partial content
// But only if there are no tool calls (tool execution components will show the error)
const hasToolCalls = message.content.some((c) => c.type === "toolCall");
this.hasToolCalls = hasToolCalls;
if (!hasToolCalls) {
if (message.stopReason === "aborted") {
const abortMessage =