fix(tui): stop Warp resize feedback-loop redraw storm

The non-multiplexer resize fast path borrows the alternate screen for
throwaway drag frames. Warp reports a terminal height one row different
for the alt buffer, so each alt enter/leave emits a fresh SIGWINCH that
re-enters the fast path — a self-sustaining loop that floods ED3 full
repaints with completely stable geometry (observed ~130
fullPaint(clearScrollback) frames over 15s, continuing after the drag
stopped). PI_FORCE_SYNC_OUTPUT cannot help (it is a loop, not tearing);
tmux works because the multiplexer path never toggles the alt buffer.

Route resize through the in-place repaint path (no alt-screen borrow, no
ED3 rewrap) for multiplexers and for terminals that re-report size on
alt-screen toggles, via resizeRepaintsInPlace(). Default-on for Warp,
overridable with PI_TUI_RESIZE_IN_PLACE=1|0. Tradeoff matches a
multiplexer: scrollback above the window keeps its old wrap.

Tests assert no alt-screen borrow / no ED3 across a Warp resize burst and
that the override toggles both ways; existing direct-terminal resize
tests now pin TERM_PROGRAM so they stay deterministic under Warp.
This commit is contained in:
sorphwer
2026-06-16 12:27:53 +08:00
parent e24f789de4
commit 89fb1b0a49
10 changed files with 213 additions and 10 deletions
+1
View File
@@ -340,6 +340,7 @@ default-on only for kitty/ghostty (`PI_NO_KITTY_PLACEHOLDERS` /
| `PI_HARDWARE_CURSOR=1` | Show the real hardware cursor instead of a rendered one. |
| `PI_NOTIFICATIONS=off\|0\|false` | Suppress terminal notifications. |
| `PI_DEBUG_REDRAW=1` | Log the chosen render intent + ledger state per frame to the debug log. |
| `PI_TUI_RESIZE_IN_PLACE=1\|0` | Force resize to repaint in place (no alt-screen borrow, no ED3 rewrap) on / off. Default-on for terminals that re-report size on alt-screen toggles (Warp). |
Removed with the old engine: `PI_TUI_ED3_SAFE` (no ED3-risk lever exists),
`PI_CLEAR_ON_SHRINK` (shrinks always clear exactly), `PI_TUI_DEBUG` (per-render