From ef333af3d1e1f51aab95a2c2bbe659d87706e987 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 5 Dec 2025 12:17:56 +0100 Subject: [PATCH] fix: footer overflow crash on narrow terminals Footer stats line now truncates gracefully when terminal width is too narrow to fit all stats, instead of overflowing and crashing the TUI. --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/src/tui/footer.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 0c1efed1..139d62d4 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -11,6 +11,7 @@ - **Print mode error handling**: `-p` flag now outputs error messages and exits with code 1 when requests fail, instead of silently producing no output. - **Branch selector crash**: Fixed TUI crash when user messages contained Unicode characters (like `✔` or `›`) that caused line width to exceed terminal width. Now uses proper `truncateToWidth` instead of `substring`. - **Bash output escape sequences**: Fixed incomplete stripping of terminal escape sequences in bash tool output. `stripAnsi` misses some sequences like standalone String Terminator (`ESC \`), which could cause rendering issues when displaying captured TUI output. +- **Footer overflow crash**: Fixed TUI crash when terminal width is too narrow for the footer stats line. The footer now truncates gracefully instead of overflowing. ### Added diff --git a/packages/coding-agent/src/tui/footer.ts b/packages/coding-agent/src/tui/footer.ts index b38f8936..3f1e1986 100644 --- a/packages/coding-agent/src/tui/footer.ts +++ b/packages/coding-agent/src/tui/footer.ts @@ -196,7 +196,7 @@ export class FooterComponent implements Component { } statsParts.push(contextPercentStr); - const statsLeft = statsParts.join(" "); + let statsLeft = statsParts.join(" "); // Add model name on the right side, plus thinking level if model supports it const modelName = this.state.model?.id || "no-model"; @@ -210,9 +210,17 @@ export class FooterComponent implements Component { } } - const statsLeftWidth = visibleWidth(statsLeft); + let statsLeftWidth = visibleWidth(statsLeft); const rightSideWidth = visibleWidth(rightSide); + // If statsLeft is too wide, truncate it + if (statsLeftWidth > width) { + // Truncate statsLeft to fit width (no room for right side) + const plainStatsLeft = statsLeft.replace(/\x1b\[[0-9;]*m/g, ""); + statsLeft = plainStatsLeft.substring(0, width - 3) + "..."; + statsLeftWidth = visibleWidth(statsLeft); + } + // Calculate available space for padding (minimum 2 spaces between stats and model) const minPadding = 2; const totalNeeded = statsLeftWidth + minPadding + rightSideWidth;