fix(tmux): pre-size destination window before switch-client - #58
Open
vimeh wants to merge 1 commit into
Open
Conversation
With window-size latest, attaching a window last viewed at a different client size rescales every pane proportionally: the sidebar balloons (32 -> 48/56/103 observed) for a visible frame until the width-repair hook snaps it back, a double reflow of ~100-300ms on ~20% of switches. Pre-size the destination session's active window and its sidebar pane to the switching client's current window size before switch-client so the attach is a layout no-op, then restore window-size tracking (resize-window pins the window to manual).
There was a problem hiding this comment.
inspect review
Triage: 16 entities analyzed | 0 critical, 0 high, 9 medium, 7 low
Verdict: standard_review
Findings (0)
Reviewed by inspect | Entity-level triage found 0 high-risk changes
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.
Problem
With
window-size latest, every tmux window keeps the size of the last client that viewed it. When the user's terminal size changes over the day (monitor moves, font zoom), switching into a session whose window was last viewed at a different size makes tmux rescale the whole window at attach time: panes are redistributed proportionally, so the sidebar balloons (observed 32 -> 48/56/103 columns) for a visible frame until theafter-resize-panewidth-repair hook snaps it back.The user-visible effect is a double reflow on every switch into a stale-sized window: land on a garbled layout, main-pane TUIs start redrawing at the wrong width, then the sidebar snaps back. Measured live this was ~100-300ms of visual churn on ~20% of switches (95 width-repairs across 486 switches in one day's debug log), plus occasional repair storms when consecutive repairs re-trigger the resize hooks.
Fix
TmuxProvider::switch_sessionnow pre-sizes the destination session's active window off-screen beforeswitch-client:resize-windowthe destination to the client's size, put the sidebar pane back to@opensessions_width, then switch.set-window-option -u window-sizerestores automatic size tracking, sinceresize-windowpins the window towindow-size manual. At that point the recomputed size equals the one just set, so this is never a visible resize.Attach becomes a layout no-op; the existing width-repair hooks remain as a backstop.
Testing
cargo test --workspace: unit suites green; tmux E2E 22/23 with the one failure (tmux_sidebar_stays_closed_across_session_and_window_switch_hooks) also failing identically on the unmodified base in this environment (host tmux config leaking into the test lab).