From 2ae12a7cee17efa48a22f2c5f1d6aa160a7eca81 Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 29 Jan 2026 11:19:33 +0100 Subject: [PATCH] fix(tui): split multi-line strings in renderOutputBlock to prevent width overflow Multi-line bash commands (e.g., for loops with newlines) were being passed as single "lines" to renderOutputBlock. Since visibleWidth() treats newlines as width 0, truncateToWidth() calculated incorrect truncation points. The result was rendered lines with embedded newlines that exceeded terminal width, causing "Rendered line N exceeds terminal width" crashes. Split section lines by newlines before processing so each line gets properly truncated and wrapped with box borders. --- packages/coding-agent/src/tui/output-block.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/tui/output-block.ts b/packages/coding-agent/src/tui/output-block.ts index 279ffd29f..83a6ae318 100644 --- a/packages/coding-agent/src/tui/output-block.ts +++ b/packages/coding-agent/src/tui/output-block.ts @@ -67,7 +67,8 @@ export function renderOutputBlock(options: OutputBlockOptions, theme: Theme): st padToWidth(buildBarLine(theme.boxSharp.teeRight, theme.boxSharp.teeLeft, section.label), lineWidth, bgFn), ); } - for (const line of section.lines) { + const allLines = section.lines.flatMap(l => l.split("\n")); + for (const line of allLines) { const text = truncateToWidth(line, contentWidth, theme.format.ellipsis); const innerPadding = " ".repeat(Math.max(0, contentWidth - visibleWidth(text))); const fullLine = `${contentPrefix}${text}${innerPadding}${contentSuffix}`;