Skip to content

fix(ui-tui): heal same-dimension alt-screen resize drift (salvage #18499)#25976

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-0d948741
May 14, 2026
Merged

fix(ui-tui): heal same-dimension alt-screen resize drift (salvage #18499)#25976
teknium1 merged 2 commits into
mainfrom
hermes/hermes-0d948741

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #18499 by @luoyuctl.

Summary

In alt-screen mode, terminals can emit a SIGWINCH with unchanged columns/rows to signal a host-side reflow or buffer restore (e.g. focus-restore, multiplexer redraw). Ink's handleResize was 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:
    • handleResize no longer early-returns on same-dim events when alt-screen is active.
    • Extracted the alt-screen resize prep into prepareAltScreenResizeRepaint().
    • Render path emits the erase even when optimized.length === 0, so the needsEraseBeforePaint flag actually flushes.
    • trackDrain widened to follow optimized.length > 0 (covers the erase-only payload).
  • New 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.

张安哲 and others added 2 commits May 14, 2026 15:24
- 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
@teknium1 teknium1 merged commit 34fc94d into main May 14, 2026
14 of 15 checks passed
@teknium1 teknium1 deleted the hermes/hermes-0d948741 branch May 14, 2026 22:26
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-0d948741 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8342 on HEAD, 8342 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4391 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

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/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants