Skip to content

fix(tui): clear terminal on resize to prevent ghost separator lines#23034

Closed
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix/22976-tui-resize-clear
Closed

fix(tui): clear terminal on resize to prevent ghost separator lines#23034
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix/22976-tui-resize-clear

Conversation

@KhanCold

Copy link
Copy Markdown

Problem

When the terminal is resized while the TUI is running, Ink's VDOM reconciliation does not handle geometry changes. Old separator lines (──────) accumulate on screen, creating visual garbage.

Solution

Add a raw ANSI escape sequence (\x1b[2J\x1b[H) to the resize handler to clear the terminal before Ink re-renders. This is a targeted fix that does not affect normal rendering.

Testing

  • Resized terminal during active TUI session
  • No ghost lines observed after fix

Fixes #22976

Fixes NousResearch#22976

Ink's VDOM reconciliation does not handle terminal geometry changes. Old separator lines accumulate. This adds a raw ANSI clear sequence to the resize handler.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 10, 2026
@liw71750-dotcom

Copy link
Copy Markdown

This PR addresses one specific symptom of a broader issue: the CLI/TUI does not reflow content on terminal resize. There are 34+ open bugs about various manifestations of this problem.

I've opened a tracking feature request (#24164) that proposes a comprehensive solution — a SIGWINCH handler triggering full re-render at new viewport dimensions, comparable to how opencode and Claude Code handle resize smoothly.

If this PR gets merged, please consider whether the underlying architecture supports full reflow, or if we still need a systematic fix. The tracking issue consolidates all related work:

#24164

@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded — the Ink renderer already handles this atomically inside the alt-screen path. ui-tui/packages/hermes-ink/src/ink/ink.tsx (handleResize line 484, needsEraseBeforePaint line 283, plus the BSU/ESU-atomic erase block in the render commit) covers what your PR does at the React layer, via commits 1e445b2, 279b656 (Apple Terminal deep clear), 3e01de0, and f7e8657. A second uncoordinated \\x1b[2J\\x1b[H from React would race with the Ink-layer clear+paint and reintroduce flicker. And #25976 (just merged) extends the same-dim alt-screen path for terminals that emit reflow events without changing columns/rows. Thanks @KhanCold!

@teknium1 teknium1 closed this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI: Terminal resize accumulates blank separator lines

4 participants