Skip to content

fix(picker): keep the preview at half the width when the terminal is resized - #4867

Merged
max-sixty merged 4 commits into
mainfrom
fix/picker-preview-resize-4793
Nov 20, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix/picker-preview-resize-4793

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

The wt switch picker'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 now right:50% instead of an absolute right: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:

  • The startup pane is one column narrower. skim builds its startup viewport one column narrower than the terminal and splits that, so a 120-column terminal now splits 60 | 59 instead of 59 | 60. The text width is now derived from that same geometry (dimensions_for runs ratatui's own Percentage(50) split on term_width - 1, minus the border column). preview() turns skim's reported pane width into the same text width with PreviewLayout::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.
  • The re-wrap lands on the next keystroke, not on the resize itself. skim 5.9's Event::Resize handler 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.
  • Summary and forge-fetched panes keep their startup wrapping. A Summary is stored raw and wrapped at display time. Comments, and a --prs row'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. The pr pane is width-keyed, and its invalidation now drops every width (evict_preview).
Where the one-column offset comes from
  • Tui::new_with_height in skim 5.9's src/tui/backend.rs builds the fixed (non-fullscreen) viewport as backend.size().width - 1.
  • LayoutTemplate in src/tui/layout.rs splits it with [Fill(1), Percentage(p)]. A ratatui probe gives the same areas for Percentage(50) and Length(W/2). The difference from the old geometry comes from the 119-column viewport: right:60 gives 59 | 60, while 50% gives 60 | 59.
  • The preview's cols (reported as PreviewContext::width) is the pane area including its left-border separator, so the text width is one less.
  • After a resize, skim sizes the viewport to the full new width, which is why the live width comes from skim rather than from startup arithmetic.

Fixes #4793

worktrunk-bot and others added 3 commits November 20, 2026 19:15
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 worktrunk-bot left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@max-sixty
max-sixty merged commit 38051df into main Nov 20, 2026
36 checks passed
@max-sixty
max-sixty deleted the fix/picker-preview-resize-4793 branch November 20, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Picker preview width is fixed at startup, doesn't follow terminal resizes

2 participants