fix(ui-tui): heal same-dimension alt-screen resize drift#18499
Conversation
e0c7880 to
3d2e254
Compare
|
Pushed two small improvements after review:
Test still passes: |
- Treat same-dimension resize events in alt-screen mode as a repaint signal, because terminal hosts can reflow or restore the physical buffer without changing columns/rows. - Ensure pending resize erases are emitted even when the virtual diff is empty, so stale physical glyphs are still cleared. - Extract alt-screen resize repaint into prepareAltScreenResizeRepaint() for readability. - Add defensive clearTimeout in prepareAltScreenResizeRepaint so rapid resize bursts don't stack redundant delayed repaints. - Add a focused regression test for same-dimension alt-screen resize healing. Addresses NousResearch#18449 Related to NousResearch#17961
3d2e254 to
59d89f8
Compare
|
@teknium1 here's background |
|
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: |

Summary
columns/rows.Root cause
The TUI renderer tracks a virtual previous frame and normally writes only the cells that changed. After a terminal resize, focus restore, or host-side reflow, the physical terminal buffer can contain stale glyphs that do not exist in Ink's virtual frame. If the next virtual frame has no diff, the old code skipped the erase/repaint path, leaving those physical cells visible.
Related issues
Validation
npm test -- --run packages/hermes-ink/src/ink/ink-resize.test.ts packages/hermes-ink/src/ink/log-update.test.tsnpm run type-checknpm testnpm run buildgit diff --check