fix(terminal): flush pending PTY resize on teardown (tmux pane-bleed)#1010
Open
griffinwork40 wants to merge 2 commits into
Open
fix(terminal): flush pending PTY resize on teardown (tmux pane-bleed)#1010griffinwork40 wants to merge 2 commits into
griffinwork40 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughChangesPTY resize synchronization
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The renderer pool refits the xterm grid synchronously on resize but debounces the PTY winsize update by PTY_RESIZE_DEBOUNCE_MS (256ms). If a leaf was hidden or evicted inside that window, detachSlotFromLeaf cleared the pending resize timer without flushing it, so the queued winsize update was dropped and the PTY stayed behind the rendered grid. releaseSlot then reported the uncommitted grid size as the session size, and a retained fast rebind suppressed the size-matched resizePty, so the two stayed diverged until an unrelated later resize resynced them. tmux positions every pane by absolute coordinates against the size it was told, so the stale winsize made it draw pane content across the dividers. Extract the grid/PTY delta into a pure pendingPtyResize() helper and commit it on every teardown path, not only when the debounce timer fires, so the winsize can never lag the grid. Refs crynta#981
griffinwork40
force-pushed
the
fix/tmux-winsize-desync
branch
from
July 16, 2026 14:15
bf63e0c to
588a7f8
Compare
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.
What
The terminal PTY winsize could lag the rendered xterm grid after a resize, so tmux (and any multiplexer) drew pane content across the dividers. This commits any pending PTY resize on every renderer-pool teardown path so the winsize always converges to the grid.
Why
Closes #981.
The renderer pool refits the grid synchronously on resize but debounces the PTY resize by
PTY_RESIZE_DEBOUNCE_MS(256ms). If a tmux leaf is hidden/evicted inside that window,detachSlotFromLeafcleared the pending timer without flushing it, so the queued winsize update was dropped.releaseSlotthen reported the uncommitted grid size as the session size, and a retained fast rebind suppressed the now-size-matchedresizePty, so the PTY and grid stayed diverged until some unrelated later resize resynced them. tmux positions panes by absolute coordinates against the size it was told, so the stale winsize smeared content across the pane dividers.How
pendingPtyResize(grid, committed)inrendererResize.ts: returns the size still owed to the PTY, ornullwhen they already agree, and never emits a degenerate (<= 0) resize.rendererPool.ts:flushPty(the debounce timer) anddetachSlotFromLeaf(every teardown path) now both route through a singlecommitPendingResize()that calls the helper and updatesslot.lastCols/lastRows. Dropping the queued resize on teardown is no longer possible, so the winsize cannot lag the grid.Single concern, 3 files, no
src-tauri/changes, no new dependencies.Testing
pnpm lintcleanpnpm check-typescleanpnpm testclean (264 tests; newrendererResize.test.tscovers match / grow / shrink, the degenerate-dimensions deny path, and the interrupted-debounce regression)pnpm buildandpnpm sizeclean (size well within budget)Verification level is unit test plus a static trace of the resize path (
ResizeObserver-> debouncedresizePty->pty_resize->master.resize), matching the triage note in #981. I have not captured a live before/after tmux recording: the trigger is timing-dependent (hide/show a leaf within the 256ms debounce) and does not reproduce deterministically in a headless run. Glad to add an integration-level test arounddetachSlotFromLeafif you prefer that over the pure-helper unit test.pnpm lintcleanpnpm check-typescleanpnpm testcleansrc-tauri/)cargo clippy- N/A, frontend onlysrc-tauri/)cargo nextest run- N/A, frontend only#[tauri::command]signature) - N/A, no command changespnpm tauri dev- N/A, no UI/visual changepnpm build+pnpm sizeclean (extra CI gates)Screenshots / GIFs
N/A - no visual/UI change; this is terminal-to-PTY size plumbing.
Notes for reviewer
detachSlotFromLeafis the teardown path that dropped the resize; the debounce timer now shares the samecommitPendingResize()so there is one source of truth for "what the PTY was last told".Summary by CodeRabbit