Repository navigation
fix(picker): keep the preview at half the width when the terminal is resized - #4867
Merged
Merged
Conversation
The picker's right preview window is an absolute column count fixed at startup, so widening the terminal leaves the split at the old position. The test boots at 120 columns, resizes the pty to 200, and asserts the separator stays in the middle. It fails on main with the separator at column 140. Refs #4793
…lyph The │ border glyph renders inconsistently across platforms (see the LIST_WIDTH comment), so a missing glyph would panic the #4793 repro before its geometry assertions. Find the preview's "1: diff" tab header instead; blank cells skim skips with a cursor move read as empty. Co-Authored-By: Claude <[email protected]>
…size The Right preview was `right:N`, an absolute width taken from the startup terminal, so widening the terminal left the split at the startup column. Ask skim for `right:50%` instead. skim splits a viewport one column narrower than the terminal and counts the separator in the width it reports, so the startup text width is now derived from that geometry (ratatui's own Percentage(50) split of term_width - 1, less the border column). `preview()` derives the same text width from `PreviewContext::width`, so precompute and on-demand renders share entries and no line is drawn into the unpainted column. The in-memory preview cache key gains that width, so a pane rendered for the old size misses after a resize and recomputes. Summary (wrapped at display time) and the forge-fetched panes (Comments, a --prs row's Log, fetched once) key without width so they keep showing their content. skim re-runs the preview on a resize before it records the new pane width, so the re-render lands with the next keystroke. Fixes #4793 Co-Authored-By: Claude <[email protected]>
worktrunk-bot
commented
Nov 20, 2026
Collaborator
Author
There was a problem hiding this comment.
codecov/patch is red, and one added line is actually uncovered: the PreviewLayout::Down arm of PreviewStateData::layout(). No PTY test starts the picker below MIN_COLS_FOR_RIGHT_LAYOUT. The other patch misses (render_listed_pr_mode, the stale-generation spawn_compute closure) are lines that were already uncovered on main and were only re-touched here.
Update: 700fefe replaces layout() with a stored border-column count, which removes that branch, so the narrow-terminal test I planned isn't needed.
…der width The layout flag that preview() read is replaced by the border-column count it actually needs, so the per-layout choice lives in the pure PreviewLayout::text_width. A --prs row's log, fetched once, is now shown through render_preview at a width other than the fetch width. Co-Authored-By: Claude <[email protected]>
1 task
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.
The
wt switchpicker's side-by-side preview now keeps its 50/50 split when the terminal is resized. Before, the split stayed at the startup column (#4793). The preview window is nowright:50%instead of an absoluteright:N. The in-memory preview cache keys on the pane's text width, so after a resize a pane misses and is re-rendered at the new width.test_switch_picker_preview_split_follows_terminal_resize, moved here from #4794, boots the picker at 120 columns, resizes to 200, and checks that the separator follows.What changes for users:
dimensions_forruns ratatui's ownPercentage(50)split onterm_width - 1, minus the border column).preview()turns skim's reported pane width into the same text width withPreviewLayout::text_width. So precomputed and on-demand renders share cache entries, and no line reaches the column skim leaves unpainted. The four snapshot updates are this one-column shift. The list gains a column, the preview loses one, and the controls hint (not width-managed, by design) clips one character sooner.Event::Resizehandler re-runs the preview before the next render records the new pane width. So the first preview after a resize still sees the old width, and the next keystroke brings the new one. This was agreed as fine for now on test: reproduction for #4793 #4794.--prsrow's Log, are fetched once per session. All three key without a width (preview_cache_key). A resize therefore keeps showing their content rather than a loading placeholder that nothing would refill. Theprpane is width-keyed, and its invalidation now drops every width (evict_preview).Where the one-column offset comes from
Tui::new_with_heightin skim 5.9'ssrc/tui/backend.rsbuilds the fixed (non-fullscreen) viewport asbackend.size().width - 1.LayoutTemplateinsrc/tui/layout.rssplits it with[Fill(1), Percentage(p)]. A ratatui probe gives the same areas forPercentage(50)andLength(W/2). The difference from the old geometry comes from the 119-column viewport:right:60gives 59 | 60, while50%gives 60 | 59.cols(reported asPreviewContext::width) is the pane area including its left-border separator, so the text width is one less.Fixes #4793