Skip to content

Unify wt switch and --prs: differ only by the extra PR rows - #3252

Merged
max-sixty merged 2 commits into
mainfrom
picker-filter-pr-number
Jun 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
picker-filter-pr-number

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Previously wt switch and wt switch --prs diverged in more than just which rows they showed: filterability and match text differed between the two. This makes the only difference between them whether the extra (not-checked-out) PR rows are listed — everything else, including what you can filter by, is now identical.

What changed

  • Full filter parity. Every row filters by its branch, path, and — when it has a PR/MR — the PR/MR's number, title, and author. The same fields apply whether the PR is checked out (a worktree row) or listed via --prs. A shared push_pr_search_tokens helper builds the match text for both row types, so they can't drift apart again.
  • Dedup. --prs now lists only the PRs that aren't already shown as worktree rows, instead of duplicating a branch you already have checked out.
  • Live match text. A worktree row's match text folds in PR number/title/author as soon as the live forge fetch lands, rather than freezing at the cache snapshot taken when the picker opened.

Author data is plumbed through both forges (github.rs/gitlab.rs → PrStatus.author) to support author filtering and to show the author in the preview pane.

Reviewer orientation

  • src/commands/picker/items.rs — push_pr_search_tokens + the live text() on the worktree item.
  • src/commands/picker/progressive_handler.rs — collect_shown_branches, the skeleton handoff, search_base construction.
  • src/commands/picker/prs.rs — additional_prs dedup + the per-spawn GridSlot/Skeleton handoff (re-created inside spawn() so alt-r re-fetches don't read a stale snapshot).
  • The rest is author plumbing through the ci_status forge modules + help/doc/snapshot regeneration.

Tested via the picker unit + integration suites (match-engine parity, dedup, live-update, author rendering).

This was written by Claude Code on behalf of max

max-sixty and others added 2 commits June 25, 2026 16:47
Make `wt switch` and `wt switch --prs` differ solely by whether listed
PR/MR rows appear; filterability and row behavior are otherwise identical.

- Dedup: --prs skips a PR already shown as a worktree/branch/remote row
  (was double-listed). on_skeleton hands the shown-branch set to the --prs
  thread via the per-spawn skeleton handoff (prs::Skeleton); additional_prs
  filters. Created fresh per spawn() so an alt-r reload uses that reload's
  set, not a stale first-write-wins one.
- Live filter parity: a worktree row's match text is assembled live in
  WorktreeSkimItem::text() from branch+path + the live pr_status fields
  (reference/title/author) + gutter, so a PR filters by number/title/author
  the moment the CI fetch lands them. Shared push_pr_search_tokens helper
  drives both row types; PrSkimItem drops its old pr/mr label token.
- Plumb PR author into PrStatus (cache-safe serde default) and the GitHub
  and GitLab worktree-row CI fetches; worktree pr preview pane shows it too.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	src/commands/picker/mod.rs
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Approved. Heads-up that test (windows) failed on a flake unrelated to this change — leaving the approval in place rather than dismissing.

The failure is test_switch_picker_worktree_row_comments_tab_shows_thread, which timed out after 30s waiting for the diff preview (diff --git) to render in the PTY. It passed on test (linux) and test (macos) on this same commit, and the diff-preview render path isn't touched by this PR (the change is to --prs dedup, author plumbing, and the live matcher text). A genuine regression in that logic would fail on all three platforms, not just the slower Windows runner. This reads as a PTY screen-stabilization timing flake.

A re-run of test (windows) should clear it. A gh run rerun --failed will return 403 while affected tests (windows, advisory) is still in flight in the same ci run, so it's best kicked off once that job finishes.

Evidence

Failing job: ci / test (windows)

thread '...test_switch_picker_worktree_row_comments_tab_shows_thread' panicked at tests\integration_tests\switch_picker.rs:560:9:
Timed out after 30s waiting for expected content "diff --git" to appear on screen.
Summary [ 468.138s] 3889 tests run: 3888 passed, 1 failed, 35 skipped

test (linux) and test (macos): both SUCCESS on c62368c.

@max-sixty
max-sixty merged commit a725a2d into main Jun 26, 2026
47 of 49 checks passed
@max-sixty
max-sixty deleted the picker-filter-pr-number branch June 26, 2026 00:55
max-sixty added a commit that referenced this pull request Jun 26, 2026
Collapse the picker's two `SkimItem` types into one. `WorktreeSkimItem`
(a checked-out worktree row) and `PrSkimItem` (a listed `--prs` row)
become a single `PickerRow` whose only branching axis is `local:
Option<LocalCheckout>` — `Some` for a worktree row, `None` for a listed
PR. This is the type-level completion of #3252, which made the two row
kinds behave identically; they now share one `text()`, `display()`,
`output()`, `preview()`, and PR-pane renderer instead of two parallel
implementations.

## What changed

- `PrSkimItem` and its standalone `impl SkimItem` are deleted. Listed
`--prs` rows are built by `prs::listed_pr_row` (shared by
`fetch_and_stream` and the row tests) as `PickerRow { local: None, … }`
with a static `pr_status` slot pre-filled by the new
`PrEntry::display_status()`.
- The worktree-only fields (`has_upstream`, `summaries_enabled`,
`local_content`) move into a `LocalCheckout` sub-struct behind `local`.
The frozen `Arc<ListItem>` handle is gone, replaced by a precomputed
`output_token`.
- `pr_status` and the preview cache are shared by both row kinds, keyed
by `PickerRow::preview_key()` — the branch for a worktree row,
`pr:N`/`mr:N` for a listed PR. A `--prs` row's `pr` pane is memoized in
that session-long cache, so `listed_pr_row` drops the prior `(pr:N, Pr)`
entry on each build; an `alt-r` reload then re-renders the freshly
fetched PR metadata instead of the pre-reload pane (the worktree-row
analog of `on_update`'s invalidation).

## Behavior change

A worktree row tracking a draft PR now shows a `state: draft` line in
its `pr` pane. Previously only `--prs` rows surfaced draft state. This
falls out of both kinds sharing `render_pr_pane_body`.

## Reviewer orientation

- `src/commands/picker/items.rs` — the unified
`PickerRow`/`LocalCheckout`, `preview_key()`, `render_pr_pane_body()`,
`render_listed_pr_mode()`.
- `src/commands/picker/prs.rs` — `PrSkimItem` removed;
`PrEntry::display_status()` and the `listed_pr_row` constructor (with
its cache invalidation).
- `src/commands/picker/progressive_handler.rs` — worktree-row
construction with `local: Some(LocalCheckout { … })`.
- The remaining files are call-site and doc renames.

Rendered output is unchanged — the integration snapshots still pass, and
the `loading_placeholder` snapshots change only their `expression:`
metadata line. Rebased on main's #3253 (the `↳` loading-placeholder
glyph), which is preserved.

> _This was written by Claude Code on behalf of max_
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
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
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.

2 participants