fix(ui): prevent terminal screen cheese on TUI resize#76
Merged
digitarald merged 2 commits intomainfrom Mar 22, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Ink TUI “screen cheese” artifacts that appear when resizing the terminal by clearing the visible terminal area before Ink processes the resize, ensuring the next render starts from a clean screen.
Changes:
- Clears the terminal (
\x1b[2J\x1b[H) on every resize event to avoid stale line-tracking artifacts. - Uses
stdout.prependListener("resize", ...)so the clear runs before Ink’s internal resize handler. - Keeps
columnsstate updated on resize for responsive layout.
readers are not exposed to raw ANSI noise on resize. The columns state update still fires, keeping layout responsive in accessible mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resizing the terminal while the TUI is running causes "screen cheese" — old renders stack and overlap instead of being replaced, producing multiple AGENTRC ASCII banners on screen simultaneously.
Root Cause
Ink 6.x tracks
previousLineCountin itslog-updatemodule for cursor math (eraseLines,cursorUp). When the terminal resizes, the emulator reflows existing text — changing how many visual lines the content occupies — but Ink's internal counters stay stale.Ink's own
resized()handler only callsthis.log.clear()on width decrease. Width increases and height-only changes leave the stale state in place, causing partial erasure and ghost content on the next render.Fix
Clear the visible terminal area (
\x1b[2J\x1b[H) in theuseTerminalColumnsresize handler, usingprependListenerso it fires before Ink's ownresized(). This ensures Ink re-renders onto a clean slate on every resize direction — no wasted double-paint.Details
stdout.prependListener("resize", ...)to run before Ink's handler\x1b[2Jclears the visible area (not scrollback);\x1b[Hhomes the cursorresized()→onRender()paints fresh content immediatelyuseTerminalColumns)Verification