Repository navigation
test: reproduction for #4793 - #4794
worktrunk-bot wants to merge 2 commits into
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
worktrunk-bot
left a comment
There was a problem hiding this comment.
separator_col finds the split by matching the │ border glyph. This file warns against relying on that glyph: the LIST_WIDTH comment says it "renders inconsistently across platforms", and wait_for_stable_with_content says to avoid │ in assertions. On a platform where the glyph doesn't come through as │, expect("startup split") panics before either geometry assertion runs. The test would then keep failing on that platform after #4793 is fixed, for a reason that has nothing to do with the resize. I'll push a version that locates the preview pane by its tab header (1: diff) instead.
…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]>
|
@worktrunk-bot let's fix #4793 rather than leave the workaround:
Re-wrapping on the next keystroke is fine for now. Move this repro test into the fix PR and close this one, since a red test can't land.
|
|
The fix is in #4867, with this repro test moved over. The preview spec is now |
…resized (#4867) 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`](https://github.com/max-sixty/worktrunk/blob/d3c1697663531d7fcf771197ccde26bc148f70b5/src/commands/picker/preview.rs#L276-L292) 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 #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`](https://github.com/max-sixty/worktrunk/blob/d3c1697663531d7fcf771197ccde26bc148f70b5/src/commands/picker/items.rs#L156-L182)). 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`). <details><summary>Where the one-column offset comes from</summary> - `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. </details> Fixes #4793 --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude <[email protected]>
This PR adds a failing reproduction on purpose, without a fix.
test_switch_picker_preview_split_follows_terminal_resizeboots the picker in a 120-column pty, resizes it to 200 columns, and checks that the list/preview separator stays near the middle. On main the separator stays at column 140: theright:60window is an absolute width taken from the startup size.I tried the obvious fix, and it isn't ready to ship. With
spec_foremittingright:50%, this test passes, but three existing picker tests fail, and both remaining problems need a decision about how the picker sizes its preview:context.width59 instead of 60. Thedimensions_fortext width is still 59, so the last painted column is dropped: inswitch_picker_abort_escape_previewthe tab hint loses its trailinga.test_switch_picker_scrollbar_on_overflowandswitch_picker_preview_log_previewmove by the same column. The text width would have to be re-derived for skim's percentage geometry, which isn't the same as theLength(N)geometry. A ratatui probe showsPercentage(50)andLength(W/2)split identically, so the difference comes from skim's own handling.Event::Resizearm callsrun_previewbefore the next render updatespreview.cols, sopreview()gets the pre-resizecontext.width. I logged 60, then 60 again after resizing to 200. The new width (100) only arrives with the next keystroke. Adding width to the in-memoryPreviewCachekey would therefore re-render the pane on the next keystroke, not when the resize happens.Measurements
All measured in the PTY harness, logging
PreviewContext.widthfromPickerRow::preview:context.widthright:60(main)right:50%The in-memory cache key
(PickerRowId, PreviewMode)ignores width, and--prsrows fetch theirlog/commentspanes once at the startup width. A width-keyed cache would leave those two tabs on their loading placeholder after a resize unless they are exempted or re-fetched.Automated triage for #4793