From af12464217555fa36d372e6ff1c6203720bf6e93 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 2 Apr 2026 01:31:09 +0200 Subject: [PATCH] fix(tui): avoid overlay scrollback inflation on widen --- packages/tui/CHANGELOG.md | 1 + packages/tui/src/tui.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index faecd143..9a517bb5 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed markdown H1 headings ending with inline code from leaking underline styling into trailing line padding - Fixed slash-command argument autocomplete to await async `getArgumentCompletions()` results and ignore invalid return values, preventing crashes when extension commands provide asynchronous completions ([#2719](https://github.com/badlogic/pi-mono/issues/2719)) +- Fixed non-capturing overlay padding from inflating scrollback and corrupting the viewport on terminal widen ([#2758](https://github.com/badlogic/pi-mono/pull/2758) by [@dotBeeps](https://github.com/dotBeeps)) ## [0.64.0] - 2026-03-29 diff --git a/packages/tui/src/tui.ts b/packages/tui/src/tui.ts index b0e6d86d..b8189db3 100644 --- a/packages/tui/src/tui.ts +++ b/packages/tui/src/tui.ts @@ -722,9 +722,10 @@ export class TUI extends Container { minLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length); } - // Ensure result covers the terminal working area to keep overlay positioning stable across resizes. - // maxLinesRendered can exceed current content length after a shrink; pad to keep viewportStart consistent. - const workingHeight = Math.max(this.maxLinesRendered, minLinesNeeded); + // Pad to at least terminal height so overlays have screen-relative positions. + // Excludes maxLinesRendered: the historical high-water mark caused self-reinforcing + // inflation that pushed content into scrollback on terminal widen. + const workingHeight = Math.max(result.length, termHeight, minLinesNeeded); // Extend result with empty lines if content is too short for overlay placement or working area while (result.length < workingHeight) {