fix(ui-tui): heal same-dimension alt-screen resize drift (salvage #18499)#25976
Merged
Conversation
- 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 #18449 Related to #17961
Contributor
🔎 Lint report:
|
This was referenced May 14, 2026
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.
Salvage of #18499 by @luoyuctl.
Summary
In alt-screen mode, terminals can emit a SIGWINCH with unchanged
columns/rowsto signal a host-side reflow or buffer restore (e.g. focus-restore, multiplexer redraw). Ink'shandleResizewas short-circuiting those events, leaving stale physical glyphs visible. Now they trigger a repaint with erase-before-paint, and the repaint path runs even when the virtual diff is empty.Changes
ui-tui/packages/hermes-ink/src/ink/ink.tsx:handleResizeno longer early-returns on same-dim events when alt-screen is active.prepareAltScreenResizeRepaint().optimized.length === 0, so theneedsEraseBeforePaintflag actually flushes.trackDrainwidened to followoptimized.length > 0(covers the erase-only payload).ink-resize.test.ts— focused regression covering same-dim alt-screen resize → erase emitted before next render.Validation
npm test -- --run packages/hermes-ink— 80/80 pass (including the new regression).npm run type-check— clean.Refs #18449 #17961.
Original PR: #18499. Contributor authorship preserved via cherry-pick (
张安哲 <zhanganzhe@tenclass.com>).Closes #18499.