Repository navigation
feat(picker): reclaim table width when the preview toggles - #3214
Conversation
Review-only design proposal (lives under design/, closed without merging). Weighs three ways to give the freed horizontal space to the table when the `wt switch` picker's preview pane is hidden with alt-p, against the constraint that the columns the user is already reading must not move. Recommends rendering the table at full width always and letting skim's split clip it at the preview boundary (Option 3): the layout is computed once, so no column ever moves. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…sign Illustrative prototype for design/picker-preview-toggle-width.md (Option 3); not intended to land. Renders the table at full terminal width regardless of layout, adds no_hscroll(true) so a match deep in the search key can't scroll the leading columns away, and sets an empty ellipsis for a clean clip. With the preview shown, skim clips the full-width row at the boundary; alt-p reveals the right-hand columns with no reload and no column movement. Picker dry-run tests are unaffected (they render at usize::MAX width). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
Reviewed the doc and independently verified the load-bearing skim claims against the 4.8.0 source — the recommendation rests entirely on them, so they're the part worth an uncorrelated check. They all hold (notes folded below). Option 3 is the right call given the stated constraint: it's the only option that computes the layout once and therefore the only one where no column moves on toggle, and it adds zero runtime machinery.
The one thing I'd surface for the decision, since the doc states it fairly but neutrally: the cost and the benefit land on opposite states. The benefit (reclaimed width) is in the preview-hidden state, which is opt-in behind an explicit alt-p. The cost (a row clipped mid-cell at the split boundary) is in the preview-shown state, which is the default every user sees on every launch. So Option 3 trades a small, permanent cosmetic regression in the common case for a clean reveal in the opt-in case. That's defensible — the bisected cell is genuinely minor in the prototype frames — but it's the actual crux of the choice, and "the user asked for the preview to cover the RHS" is one user's stated preference weighed against the default-state experience of everyone. Worth confirming the bisected-cell default is acceptable before building, since that's where the regression permanently lives.
One smaller note: no_hscroll(true) and ellipsis("") are global SkimOptions, so they also apply to the Down layout and the --prs grid. Both are no-ops there (rows already fit the full-width pane, so there's nothing to scroll or clip), so this is harmless — just worth a line in the eventual implementation PR so a future reader doesn't wonder why a "full-width-clip" setting is on when the preview is below.
Nothing blocking — this is a strong, well-grounded proposal and I'd build Option 3.
skim 4.8.0 verification notes
Checked against the v4.8.0 source (skim-rs/skim, tag v4.8.0):
- Split, never overlay —
LayoutTemplate::applycarvesareainto disjointwork_area/preview_areavia a ratatuiLayout(src/tui/layout.rs,apply);Rightmaps to[rest_c, preview_c]. No floating list. ✓ toggle-previewonly flipshidden—TogglePreviewarm setsself.options.preview_window.hidden = !…, rebuildsself.layout_template = LayoutTemplate::from_options(...), callsneeds_render(). Nothing touches ratio or orientation. ✓Action::Customcan change orientation at runtime —App.options,App.layout_template, andApp.headerare allpub, so a callback can mutatepreview_windowand rebuild the template. ✓ (contrary to the picker's own// skim doesn't support change-preview-windowcomment, as the doc notes)- Empty ellipsis is the runtime default —
SkimOptionsdefault isellipsis: Default::default()(emptyString). Theellipsis: ".."I found in the source is inside#[cfg(test)] mod tests(therenderer()fixture), not a runtime default — so.ellipsis(String::new())is genuinely belt-and-suspenders as the doc claims. ✓ no_hscroll(true)pins shift to 0 —apply_hscroll'sbase_shiftisif self.no_hscroll { 0 } else { … }. With manual hscroll unbound, the proposed shift stays 0, anchoring every row left. ✓- Horizontal overflow ≠
trim_with_ellipsis—needs_ellipsisis set only fromis_top_cutoff || is_bottom_cutoff(multiline vertical), so single-line horizontal clipping never appends the ellipsis regardless. ✓
The interactive `wt switch` picker laid its table out for the list pane's width, so in the side-by-side layout it was sized for half the terminal and toggling the preview off with alt-p left the freed space empty. Lay the table out at full terminal width regardless of layout: skim clips the overflow under the preview while it is shown, and hiding the preview reveals the right-hand columns with no reload or re-layout, so the leading columns never move. `no_hscroll` keeps those columns anchored and an empty ellipsis makes the clip clean. Update the picker PTY snapshots, which now capture the full-width row clipped at the preview boundary, and drop the design proposal that explored this; its rationale now lives in the code comments. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The core change is sound and matches the design we landed on (Option 3): laying the table out at full width once, so toggling the preview off reveals the right-hand columns with no reload and no column movement. The --prs grid gets the same full-width treatment via skim_list_width, so it benefits from the same reclaim-on-toggle behavior — consistent, not a regression. Snapshots reflect the wider layout (the bisected column at the 59-col split boundary is the accepted cosmetic cost from the design discussion).
One nit: .no_hscroll(true) is now set twice in the builder — the pre-existing call (with its detailed gutter-clip rationale) and the newly-added one. The second is a redundant idempotent call. Suggestion below drops it and keeps the ellipsis. The new comment block above it still documents why no_hscroll matters for the full-width overflow, which now overlaps with the existing comment on the earlier call — worth a glance to decide whether to consolidate the two rationales, but the only load-bearing change is removing the duplicate setter.
| .no_hscroll(true) | ||
| .ellipsis(String::new()) |
There was a problem hiding this comment.
.no_hscroll(true) is already set earlier in this builder chain (alongside its detailed gutter-clip rationale), so this second call is redundant. Drop it and keep the ellipsis:
| .no_hscroll(true) | |
| .ellipsis(String::new()) | |
| .ellipsis(String::new()) |
Reconciles the canonical terminal-reader change with #3214 (the picker now lays its table out at full width regardless of preview layout): `skim_list_width` takes the full width from the same `term_dims` snapshot, dropping the obsolete Right/Down split. Also refines the layout fallback: a width-only `COLUMNS` reading (height `None`) now falls back to 80x24 for the layout, exactly as before — the layout trusts `term_dims` only when a real terminal supplied both dimensions, while `skim_list_width` still uses the `COLUMNS` width. This keeps the change a no-op for real terminals and preserves the prior headless behavior, so the two added dry-run tests (which targeted the now-removed COLUMNS-drives-layout arms) are dropped — existing PTY and dry-run tests cover both layout arms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
) PR #3210 collapsed the picker's repeated `terminal_size()` reads into one, but left the startup path reading dimensions from two different sources: the layout sizing used `terminal_size::terminal_size()` (stdout-first, `(80, 24)` fallback) while `skim_list_width` used `display::terminal_width()` (stderr-first, `COLUMNS` fallback). On a terminal where stdout and stderr point to different places, the preview sizing and the list-column width could observe different widths. This adds `terminal_dimensions() -> Option<(usize, Option<usize>)>` in `styling/mod.rs` as the single canonical reader, with the existing probe chain: stderr, then stdout, then `COLUMNS`. `terminal_width()` becomes its width projection (`terminal_dimensions().map(|(w, _)| w)`), so its external contract and all six other callers are untouched. The height is `Option` because `COLUMNS` supplies a width with no height counterpart. The picker reads the canonical source once as `term_dims` and derives both the layout and `skim_list_width` from that one snapshot. ## The height carries the "real terminal detected" signal The layout needs both width and height, so it trusts the snapshot only when a real terminal supplied both — `Some((w, Some(h)))`. A width-only `COLUMNS` reading (`Some((w, None))`), or no reading at all, falls back to `80x24` for the layout, exactly as the old stdout-only read did. `skim_list_width` needs only a width, so it still uses the `COLUMNS` width via the same snapshot. This resolves the `COLUMNS`/height asymmetry cleanly: the same read serves both callers, the `Option<height>` is load-bearing, and the prior fallback behavior is preserved. ## Behavior For a real terminal — the picker requires a TTY, so the normal case — both the layout and `skim_list_width` see the detected dimensions, so the change is a no-op. `terminal_width()` is byte-identical for every input, leaving its callers (`progress`, `help`, `styling::format`, `commands::mod`, `list::layout`, `list::collect`) unaffected. The one observable change is the rare split where stdout is not a TTY but stderr is: the layout now tracks the real terminal via the stderr probe (matching `skim_list_width` and what skim renders on) instead of falling back to `80x24`. `list::progressive_table` keeps its own stdout-only height probe: `wt list` renders to stdout, so it must detect a real stdout TTY rather than a stderr/`COLUMNS` fallback; folding it into the stderr-first reader would change its behavior, so it stays separate. This branch also merges `main`, reconciling with #3214 (the picker now lays its table out at full width regardless of preview layout): `skim_list_width` takes the full width from the same `term_dims` snapshot, dropping the obsolete Right/Down split. Both layout arms and the width derivation are covered by the existing PTY picker tests (real terminal) and dry-run tests (`COLUMNS`-only fallback); two unit tests lock the `terminal_width` ↔ `terminal_dimensions` delegation. The full local gate is green apart from `test_switch_picker_alt_l_does_not_hscroll`, a picker PTY snapshot that is environment-sensitive on macOS (it fails the same way on `main` locally) and passes on CI — the change is output-neutral for it. > _This was written by Claude Code on behalf of max_ --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk 0.62.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Browse open PRs/MRs in the `wt switch` picker, with live CI**: The picker now streams a live CI/review-status column per row — priming from the local cache, then fetching live (it previously showed only cached numbers with no network). A new `--prs` flag adds the repository's open PRs (GitHub) / MRs (GitLab) as rows alongside your worktrees, each with `pr` / `comments` / `log` preview tabs loaded from the forge in the background; selecting one fetches its branch and switches. Rows whose branch is already shown aren't duplicated, so `--prs` differs from plain `wt switch` only by the extra rows. [Docs](https://worktrunk.dev/switch/) ([#3128](max-sixty/worktrunk#3128), [#3169](max-sixty/worktrunk#3169), [#3189](max-sixty/worktrunk#3189), [#3252](max-sixty/worktrunk#3252)) - **`main…±` diff column shows by default in `wt list`**: The `main…±` column (lines changed since the merge-base with the default branch) now renders in the default `wt list` and picker, served from a persistent cache rather than a history walk. `--full` now adds only the columns that reach off-machine — CI status and LLM branch summaries — and `wt list --format=json` populates `main.diff` for every item, not just under `--full`. ([#3236](max-sixty/worktrunk#3236)) - **`[list] columns` selects and orders the columns `wt list` shows**: A new `[list] columns` user-config key (also settable via `--config-set`) takes an ordered array of column names — built-in (`branch`, `status`, `ci`, `path`, …) and `[list.custom-columns]` headers alike — and renders exactly those, in that order. Where v0.61.0's custom columns *add* columns, this *selects and reorders* the whole set; omit the key for the default layout. (`WORKTRUNK__LIST__COLUMNS` isn't supported yet and warns if set.) ([#3141](max-sixty/worktrunk#3141)) - **Picker PR preview shows full PR/MR detail**: The `pr` tab now renders the PR/MR title, markdown description, author, draft state, comment count, bold branch name, and underlined URL for any row whose branch has an open PR — not just `--prs` rows — and the `comments` tab fetches the real thread. The title and description ride the CI fetch the picker already makes; the comment thread is fetched lazily in the background, once per row. ([#3167](max-sixty/worktrunk#3167), [#3197](max-sixty/worktrunk#3197), [#3223](max-sixty/worktrunk#3223), [#3195](max-sixty/worktrunk#3195), [#3231](max-sixty/worktrunk#3231)) - **Interactive picker runs on Windows**: The `wt switch` picker was Unix-only because its preview-tab keys shelled out through a per-process state file `cmd.exe` lacks; tab state moved to an in-memory atomic with native skim callbacks, lifting the platform gate. ([#3217](max-sixty/worktrunk#3217)) - **Picker keyboard shortcuts**: `Alt-y` copies the selected branch name, `Alt-o` opens the row's PR/MR in the browser, and `Alt-r` refreshes the list (picking up worktrees created or removed elsewhere). (Breaking: in the picker, remove moved from `Alt-r` to `Alt-x`) ([#3233](max-sixty/worktrunk#3233)) - **Picker uses the full terminal**: List height scales with the terminal (a roughly even split with the preview, minimum 3 rows) instead of a fixed 12-row cap, the table lays out at full width so toggling the preview off with `Alt-p` reveals the freed columns with no reflow, and a scrollbar appears when the list overflows. ([#3205](max-sixty/worktrunk#3205), [#3214](max-sixty/worktrunk#3214), [#3198](max-sixty/worktrunk#3198)) - **Picker filters on more of each row**: Typing a gutter sigil filters by row kind (`+` for linked worktrees, `@` for the current one), the fuzzy matcher ranks on the distinguishing path segment rather than the shared parent prefix, and rows with a PR/MR also match on its number, title, and author. ([#3143](max-sixty/worktrunk#3143), [#3208](max-sixty/worktrunk#3208), [#3252](max-sixty/worktrunk#3252)) - **Picker visual polish**: The legend recolored to dim-cyan and reordered so navigation leads, and preview loading placeholders moved to the dim-hint style (`↳` transient, `○` settled, `▲` failed). ([#3237](max-sixty/worktrunk#3237), [#3253](max-sixty/worktrunk#3253)) - **"Still waiting" status for slow commit-message generation**: A configured `commit.generation` command captures stdout, so a slow or hung LLM previously showed nothing while `wt step commit`/`squash` waited. After a 2s delay worktrunk now shows a dim, in-place `○ Waiting for the commit message (Ns)` status, escalating at 10s to reveal the exact shell-escaped invocation in a gutter beneath it; the block clears on completion, mirroring `wt list`'s stall footer. ([#3178](max-sixty/worktrunk#3178)) - **"Still waiting" status extended to more slow commands**: The same waiting status now covers three more foreground commands that were silent while a captured subprocess ran — the `wt config show --full` commit-generation self-test, the `wt switch pr:`/`mr:` host lookup, and the `wt config show --full` version check. The version check no longer caps its fetch at an aggressive 5s, instead showing the status while a slow-but-working request completes (with a generous ceiling so a non-interactive run can't hang). ([#3183](max-sixty/worktrunk#3183)) - **`wt config state logs profile` performance profiler**: A new subcommand turns a `-vv` `[wt-trace]` capture (a path argument, `-` for stdin, or the default `trace.log`) into a performance profile: subprocess time by command shape, the slowest calls, parallelism and peak concurrency, redundant cache-miss re-runs, and — for `wt list`/picker captures — derived latencies and a collect timeline. `--format=json` emits the same data, and every `-vv` bug-report bundle now inlines a rendered profile. ([#3184](max-sixty/worktrunk#3184), [#3186](max-sixty/worktrunk#3186)) - **`WORKTRUNK_VERBOSE` env var**: `WORKTRUNK_VERBOSE=0|1|2` mirrors `-v`/`-vv`, combined with any flag via `max` (the env sets a floor the flag can raise). Unlike the flags it's honored on the shell-completion path, which returns before flag parsing — so a slow tab-completion can be profiled for the first time. ([#3166](max-sixty/worktrunk#3166)) - **Aliases inherit the wrapped command's completion**: An alias that forwards `{{ args }}` to a single `wt` command (`co = "wt switch {{ args }}"`) now completes that command's arguments and flags — `wt co <Tab>` completes branches like `wt switch <Tab>` — instead of a generic stub. Bare dispatchers and multi-`{{ args }}` aliases keep the stub. ([#3172](max-sixty/worktrunk#3172), thanks @yzx9) - **`wt step copy-ignored --require-include`**: A new `--require-include` flag makes the copy a no-op unless a `.worktreeinclude` file exists in the source worktree (matching Claude Code desktop, where that file is required), reporting why it skipped as a hint in text mode and a `reason` field in `--format=json`. ([#3196](max-sixty/worktrunk#3196), thanks @yzx9) - **`wt step tether` honors `-C`**: The global `-C <path>` flag now sets the tethered command's working directory (`wt step tether -C frontend -- npm run dev`); teardown still watches the worktree root, so the command is reaped when the worktree is removed. ([#3207](max-sixty/worktrunk#3207)) - **Statusline rate-limit pace color grades by severity**: The pace segment's color now deepens (dim → dim-yellow → yellow) with the projected throttling severity, so an early-window burst stays muted while a costly projected lockout stands out. The displayed pace number is unchanged. ([#3229](max-sixty/worktrunk#3229)) ### Fixed - **Picker `Alt-x` removal updates the row in place**: Removing a worktree no longer re-collects the whole list (a flicker that reset the cursor to the top): an unmerged worktree's row morphs into a branch-only row while the worktree is removed in the background, and a merged worktree's row drops with the cursor landing on the row that slid up. A removal that can't safely happen — the current or main worktree, or a dirty or locked one — is declined with the same diagnostic `wt remove` prints, rather than a dead keypress or a disruptive `cd` home. The post-removal cursor lands by row identity, so it stays correct even under an active filter. ([#3262](max-sixty/worktrunk#3262), [#3199](max-sixty/worktrunk#3199), [#3211](max-sixty/worktrunk#3211), [#3225](max-sixty/worktrunk#3225)) - **Picker preview refreshes when its background fetch lands**: A diff/log/PR-view fetch that completed after its triggering keystroke used to sit unshown until the next keypress; the pane now updates on its own when the fetch lands. ([#3247](max-sixty/worktrunk#3247)) - **Picker rows stay aligned while filtering**: Typing a filter no longer slides the matched row left and drops its leading sigil, and `Alt-l`/`Alt-h` no longer scroll the list off its gutter. ([#3213](max-sixty/worktrunk#3213), [#3226](max-sixty/worktrunk#3226)) - **fish completions no longer recurse to the call-stack limit**: With worktrunk's fish lazy-load wrapper installed, co See merge request: Harmonybrew/homebrew-core!12862
What
The interactive
wt switchpicker now lays its table out at full terminal width regardless of the preview layout. Previously, in the side-by-side (Right) layout the table was sized for the list pane (about half the terminal), so toggling the preview off withalt-pleft the freed horizontal space empty.How
The table is laid out once at full width. skim splits the screen and renders the full-width rows into the left pane, clipping the overflow at the boundary; toggling the preview off widens the list pane and the same rows reveal their right-hand columns, with no reload and no re-layout. Because the layout is computed once, the leading columns never move when the preview toggles.
Three small changes in
src/commands/picker/mod.rs:skim_list_widthis the full terminal width (minus skim's 2-column cursor gutter), instead of half width in the Right layout.no_hscroll(true)anchors the leading columns: a fuzzy match deep in the search key can no longer shift them out of view.ellipsismakes the clip a clean left-anchored cut with no... (Empty is already the library default underdefault-features = false; it is pinned explicitly because the clean clip is load-bearing.)The Down (stacked) layout already used full width, so it is unchanged.
Tradeoff
With the preview shown, the narrow left pane now shows the leftmost slice of the full table rather than a layout optimized to fit the pane. Because
Remote⇅precedesCIin the column order, the full-width layout can surface an often-emptyRemote⇅at the pane edge and pushCI/Age/Pathunder the preview. Hiding the preview reveals all of them in their natural positions. This is the inherent shape of the chosen approach: the leading columns stay fixed, and the right edge is whatever the full-width table places there. The picker PTY snapshots capture this clipped-at-the-boundary state.Background
This started as a design exploration weighing three approaches: (1) re-layout the table on toggle, (2) add an orientation toggle plus re-layout, and (3) render at full width and let the preview cover the right. skim splits the screen rather than overlaying, so option 3 reduces to clipping a full-width row at the split boundary. It is the smallest change and the only one that never moves the leading columns, so it was chosen. The design proposal that compared the options has been removed (design docs are review-only by convention); its rationale now lives in the code comments and this PR's history.
Testing
cargo run -- hook pre-merge --yes: all 4182 tests pass, clippy and fmt clean.switch_picker_abort_escape_list,switch_picker_with_branches_list,switch_picker_multiple_worktrees_list) were regenerated; they confirm the leading columns are unchanged and the boundary now reveals the next column.