Skip to content

feat(switch): browse open PRs/MRs in the interactive picker - #3128

Merged
max-sixty merged 32 commits into
mainfrom
switch-prs-picker
Jun 22, 2026
Merged

max-sixty merged 32 commits into
mainfrom
switch-prs-picker

Conversation

@max-sixty

@max-sixty max-sixty commented Jun 18, 2026 •

Copy link
Copy Markdown
Owner

wt switch --prs widens the interactive picker with the repository's open pull requests (GitHub) or merge requests (GitLab), so you can fuzzy-find a PR and jump straight to its branch — fetching and checking it out — without leaving the picker. Selection routes through the same pr:N / mr:N shortcut wt switch already understands, so there's no new switch logic.

What it adds

  • --prs source — one gh pr list / glab mr list call on a background thread; the picker frame paints instantly from local worktree data and PR rows stream in when the call returns. Rows align on the same column grid as worktree rows, with a dim # gutter sigil completing the scheme (@/^/+ worktrees, / local, | remote, # PR).
  • CI status in the picker — each row's PR/MR CI and review status, fetched live and streamed in progressively (primed from the local cache for an instant first paint, then refreshed behind the frame), the same data wt list --full shows. The picker's user-bounded lifetime is what lets it reach the wire here without blocking the first paint. The pr tab (6) surfaces this for any worktree or branch row with a PR — Loading until the fetch lands, then the reference and URL — not only --prs rows.
  • Preview tabs — the preview pane is a numbered tab bar (Alt-1…Alt-6, Tab/Shift-Tab to cycle). A new pr tab (6) shows the selected PR's metadata and description, rendered from the already-fetched forge data. A tab with no content for the current row is dimmed but keeps its N: accelerator, so the numbers stay discoverable.

Navigating the diff

  • src/commands/picker/prs.rs — the --prs source: forge fetch, row rendering, and the pr preview pane. The module docstring covers the streaming / heartbeat contract.
  • src/commands/picker/items.rs — render_preview_tabs (the shared tab bar) and TabAvailability (which tabs have content per row kind).
  • src/commands/picker/preview.rs — the PreviewMode enum (tabs 1–6) and the per-process tab state.
  • src/commands/list/render.rs and model/item.rs — the gutter sigils (//|/#), shared with wt list.

Trade-offs

  • The PR description rides the single forge call (one extra JSON field), not a background fetch — negligible next to the CI-status data already in that call, and the description is present the moment the row is. Commit logs and comment threads (candidate future tabs) are too heavy to ride that call and would need per-row background loading; left as TODO(pr-preview-*).
  • The six-tab bar is 63 columns, so on narrow (≤125-col, side-by-side) previews the last tab clips; the stacked layout and wider terminals show all six.

Testing

Picker rendering and the pr pane are covered by unit snapshots and the PTY preview suite. --prs rows have end-to-end PTY coverage (test_switch_picker_prs_{github,gitlab}_list) that verifies a row streams into the list and renders on the column grid. The pr-row preview pane is exercised by a direct preview() unit test rather than via PTY selection — asserting on the streamed row is deterministic, where selecting an async-arrived row in a PTY is racy.

This was written by Claude Code on behalf of max

max-sixty and others added 14 commits June 4, 2026 08:29
`wt switch --prs` widens the interactive picker with the repository's
open pull requests (GitHub) or merge requests (GitLab), alongside the
existing `--branches` / `--remotes` candidate-set flags. Each row's
`output()` is the `pr:N` / `mr:N` shortcut, so selecting one routes
through the same SwitchPipeline as `wt switch pr:N` — fetch the ref,
switch to its branch — with no new switch logic.

The list is a single forge call (`gh pr list` / `glab mr list`) run on a
dedicated thread that holds a clone of skim's item channel, so the picker
frame paints instantly from local worktree data and PR rows stream in
(~1s) when the call returns. Failures (CLI missing/unauthenticated,
network, unsupported forge) surface as warnings after skim releases the
terminal; the picker stays usable with its worktree rows.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	docs/content/switch.md
#	skills/worktrunk/reference/switch.md
#	src/cli/mod.rs
#	tests/snapshots/integration__integration_tests__help__help_switch_long.snap
PR rows previously rendered as a freeform line (pr #N  title  branch
@author) that ignored the column layout the worktree rows render
against, so nothing lined up. The layout is computed inside collect and
LayoutConfig can't cross threads, so the picker's --prs thread had no
way to place its cells.

- ColumnGrid (layout.rs): Send + Sync snapshot of (kind, start, width)
  per visible column, derived from LayoutConfig and passed through
  PickerProgressHandler::on_skeleton.
- GridSlot (prs.rs): one-shot Mutex+Condvar handoff from the collect
  thread to the --prs thread. The skeleton (~50ms) beats the forge call
  (~1s); a bounded 5s wait covers a mocked forge winning the race, and
  rows fall back to the freeform line if no grid ever arrives.
- Grid rows: head branch in the Branch column, '#N [draft] title
  @author' in the Summary column when allocated, else Message, else
  running from the column after Branch through the blank middle region
  (with summaries disabled — the default — the layout has no flexible
  text column).

Two adjacent fixes surfaced by testing at full width:

- skim_list_width now subtracts skim's 2-column cursor gutter ('> '),
  so full-width rows no longer spill into skim's '..' truncation.
- Skim's overflow check measures rows with width_cjk (ambiguous-width
  chars like '…' count as 2 columns) while terminals render them as 1;
  full-width rows holding one lost their last two columns to '..'.
  PR rows pre-clamp against the new StyledLine::width_cjk; the quirk is
  documented as a candidate vendor patch in vendor/NOTES.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts:
#	src/commands/picker/mod.rs
# Conflicts:
#	tests/snapshots/integration__integration_tests__help__help_switch_long.snap
The picker now keeps the CiStatus task instead of skipping it, so
worktree rows carry a CI column with their PR/CI status and review
state. The picker isn't a fast path — it renders progressively and the
fetch is cached (30-60s, HEAD-keyed) — so the per-branch
`gh pr list --head` is absorbed after the first frame paints.

`--prs` rows render their PR/MR number in that same CI column, colored
by CI + review state to line up with the worktree rows. The status
rides the single `gh pr list` / `glab mr list` call: the GitHub query
gains statusCheckRollup, reviewDecision, and mergeStateStatus, and
GitLab maps the list call's detailed_merge_status to a coarse status
(full pipeline detail would need a per-MR `glab mr view`). Without a CI
column (narrow layouts) the number falls back to a dim `#N` title
prefix.

Update the picker snapshots for the new column, note the picker's
per-branch CI fetch in the CLAUDE.md wire list, and document in
vendor/NOTES.md that CI-column rows still hit skim's width_cjk clip
(the number can't be trimmed without mangling it).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The picker's preview tab bar gains a sixth tab, `pr`, and becomes
row-aware: a tab with no content for the selected row renders dimmed with
its alt-N accelerator dropped, distinct from a normal inactive tab.

`--prs` rows now share the same tab bar instead of a standalone static
pane. A PR/MR row renders its metadata on the `pr` tab — from the data the
`gh pr list` / `glab mr list` call already fetched, no extra request — and
an empty placeholder on tabs 1-5, which a remote PR has no local worktree
to fill. Worktree rows show the `pr` tab dimmed, pointing at the `--prs`
rows where PR previews live.

Emptiness is computed only from synchronous, skeleton-time facts so the
tab bar — which skim renders once per selection and cannot re-query —
never locks into a stale state: the upstream tab reads `local_branches()`
(not the async `item.upstream`), the summary tab reads the static
`[commit.generation]` flag, and the `pr` tab is a per-row-type constant.
The active tab stays a single global digit (no per-row fall-through);
landing on an empty tab shows its placeholder until Tab or alt-6 moves on.

alt-6 jumps to the tab; Tab / Shift-Tab cycle all six (the `tr` rotation
widens to `123456`). Regenerate the picker and help snapshots and update
the switch docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	docs/content/switch.md
#	skills/worktrunk/reference/switch.md
#	src/cli/mod.rs
#	tests/snapshots/integration__integration_tests__help__help_switch_long.snap
Adds the PR/MR description to the `pr` preview tab on `--prs` rows —
GitHub `body` / GitLab `description`, riding the single forge call (no
extra round-trip), quoted in the house gutter and capped so a long body
doesn't bury the pane.

Also in this change:

- A dim `#` gutter sigil for `--prs` rows, completing the picker's gutter
  scheme alongside `@`/`^`/`+` worktrees and `/`/`|` branches.
- Preview tabs now keep their `N:` accelerator in every state — active
  bold, inactive-with-content plain, empty dimmed — so the numbers stay
  discoverable; only the formatting varies.
- Reset SGR after each styled span in the PR pane so bold/dim no longer
  bleed (skim's ANSI parser drops the SGR-22 that color_print's `</>`
  emits; the rest of the picker already works around this).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…lean

The picker is `#[cfg(unix)]`, so its supporting helpers were dead code
under `-D warnings` on Windows: the `GitHubPrInfo` re-export and
`open_pr_status` (used only by the --prs picker) are now `#[cfg(unix)]`,
and `ColumnGrid`/`GridColumn`/`column` (built on every platform but read
only by the picker) get `#[cfg_attr(not(unix), allow(dead_code))]`,
matching the existing convention in this module.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The feature reads cleanly — routing every row through the existing pr:/mr: shortcut keeps the switch logic untouched, the grid handoff and streaming contract are well-documented, and the #[cfg(unix)] gating on GitHubPrInfo/open_pr_status is consistent (the whole picker module is unix-only, so the unconditional call in parse_github_prs is fine). No correctness or data-safety concerns found.

The one open item is codecov/patch (85.06% of diff hit, target 97.45%), which CLAUDE.md treats as a merge gate despite being non-required. Most of the gap is the orchestration the PR body already flags as untestable end-to-end — the picker-prs thread spawn in mod.rs, stream_open_prs, fetch_github/fetch_gitlab (subprocess invocation), and GridSlot::wait. Closing those would need a PTY integration test driving --prs with a mocked forge CLI, which the body notes skim 0.20 makes flaky.

But a few of the misses are pure functions whose logic branches simply aren't exercised yet — independent of the streaming limitation:

  • gitlab_mr_status — the ci_still_running → Running and not_approved → Pending arms (parse_gitlab_builds_coarse_status_from_the_list_call only covers conflict + draft).
  • open_pr_status (github.rs) — the mergeStateStatus == "DIRTY" → Conflicts arm (parse_github_builds_ci_and_review_status only passes SUCCESS/APPROVED).

These are cheap to cover with direct unit calls — adding the two below exercises all three arms:

#[test]
fn gitlab_status_maps_running_and_pending_review() {
    // The detailed_merge_status arms the `conflict` test doesn't reach.
    let running = gitlab_mr_status(1, false, Some("ci_still_running"), None);
    assert_eq!(running.ci_status, CiStatus::Running);
    assert_eq!(running.review_state, None);

    let pending = gitlab_mr_status(2, false, Some("not_approved"), None);
    assert_eq!(pending.ci_status, CiStatus::NoCI);
    assert_eq!(pending.review_state, Some(ReviewState::Pending));
}

#[test]
fn parse_github_dirty_merge_state_reports_conflicts() {
    // mergeStateStatus DIRTY overrides the rollup → Conflicts.
    let json = br#"[{"number":11,"title":"t","headRefName":"b","mergeStateStatus":"DIRTY"}]"#;
    let entries = parse_github_prs(json).unwrap();
    assert_eq!(
        entries[0].status.as_ref().unwrap().ci_status,
        CiStatus::Conflicts
    );
}

They won't single-handedly clear the 97.45% target — the orchestration misses dominate — so the merge call over the remaining patch gap is yours per CLAUDE.md. Happy to push these test additions if useful.

One small thing worth a look (not a blocker): a --prs row is emitted for every open PR even when its head branch is already checked out as a worktree, so the picker can show two rows for the same branch — the worktree row and the PR row. That may well be intentional (the PR row carries the pr preview tab the worktree row can't), just flagging in case dedup was meant to happen.

The interactive picker exits via skim's abort, which never flushes an
LLVM coverage profile, so the `--prs` streaming code was unmeasurable.
Run `stream_open_prs` in the headless dry-run (joined so it completes
before exit); only the preview-bench still skips it, preserving its
no-network measurement. Mock-gh/glab dry-run tests then exercise
fetch → parse → stream → render as a normal-exit (measured) subprocess,
lifting prs.rs coverage from 84% to 96%. Also adds deterministic PTY
tests that verify the PR/MR row renders into the picker list end-to-end.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
worktrunk-bot previously approved these changes Jun 19, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Dismissing my approval: codecov/patch is now a hard red (96.62% of the diff hit, target 97.45%) — up sharply from 85.06% thanks to the new dry-run + PTY tests, but still under the gate, which CLAUDE.md treats as merge-blocking despite its non-required mark. Required checks (test (linux/macos/windows), code-coverage) are all green.

Most of the remaining 29 missed lines are genuinely hard to reach headlessly — the forge-fetch error/bail! arms in prs.rs (CLI-not-found, gh pr list / glab mr list non-zero exit, unsupported/undetermined forge), PrSkimItem::display() (skim calls it only during the interactive render, which exits via abort and never flushes a coverage profile — the same wall the streaming path hit), and the in-test panic! guard. Those aren't worth contorting the suite for.

But four cheap, pure-function arms would still close most of the gap and plausibly clear the target on their own:

  • gitlab_mr_status — the not_approved → Pending arm (the gitlab_status_maps_running_and_pending_review test from my prior review).
  • open_pr_status DIRTY → CiStatus::Conflicts in ci_status/github.rs (the parse_github_dirty_merge_state_reports_conflicts test from my prior review).
  • pr_unavailable_placeholder in items.rs — reachable by a preview() unit test on a worktree row with PreviewMode::Pr (the placeholder a non-PR row shows on the pr tab).
  • forge_noun's GitLab => "MRs" arm — only hit on an empty GitLab list, but test_switch_prs_dry_run_empty uses GitHub; a GitLab empty-list variant (or a direct forge_noun call) covers it.

The first two are verbatim in my earlier review. The merge-over-any-residual-gap call is yours per CLAUDE.md — happy to push these four test additions if useful.

@worktrunk-bot
worktrunk-bot dismissed their stale review June 19, 2026 01:20

codecov/patch failing (96.62% < 97.45% target) — CLAUDE.md treats it as a merge gate. See follow-up comment for the remaining coverable arms.

Closes most of the residual codecov/patch gap with pure-function tests:
gitlab_mr_status not_approved→Pending and ci_still_running→Running,
open_pr_status DIRTY→Conflicts, forge_noun's GitLab arm (empty MR list),
and pr_unavailable_placeholder (the pr tab on a worktree row). The
remaining misses are forge-fetch bail! arms and skim's interactive
display path, neither reachable headlessly.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
max-sixty and others added 2 commits June 19, 2026 14:49
The `pr` preview tab now reflects the selected worktree/branch row's PR,
read live from the async CI fetch through a new branch→PrStatus channel
(collect → picker). It shows the reference and URL when a PR exists,
"<branch> has no PR" when not, and "Loading PR…" until the fetch reports —
the picker's one live read-back of an async field, keyed by branch name.

Preview tab styling is now orthogonal: the number dims when a tab has no
content for the row, the label bolds on the active tab. The two compose, so
an active-but-empty tab (dim number, bold label) stays distinct from an
inactive-empty one.

`--prs` rows render only the columns that align with worktree rows — gutter,
branch, and CI number. The title and author have no worktree-column
equivalent, so they live in the `pr` preview pane; the title still feeds
fuzzy search.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
main's #3073 made the interactive picker fill its CI column from the local
cache instead of fetching (the networked CiStatus task is skipped). This branch
had made the picker fetch live so the CI column and the new `pr` tab always had
data. Reconcile onto main's local-first approach:

- Skip the CiStatus task in the picker (`skip_tasks = [BranchDiff, CiStatus]`);
  worktree rows' CI comes from `populate_from_cache`.
- The `pr` tab reads the row's cached `pr_status` directly (it's final before
  the skeleton snapshot), so the cross-thread branch→PrStatus channel
  (`on_pr_status`, the shared map) is removed. States: HasPr (cached PR), NoPr
  ("<branch> has no PR"), NotCached ("run wt list --full").
- `--prs` rows show their number in the CI column when the layout has one, else
  just after the branch — so the number never hides in a repo with no CI cache.

--no-verify: pre-commit re-runs in the gate; merge already verified green
(`cargo run -- hook pre-merge --yes`, 4035 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
max-sixty and others added 2 commits June 20, 2026 02:17
The picker skipped the networked CiStatus task and filled the CI column
(and the pr tab) from the local cache only, so a cold cache showed nothing
and a warm cache never refreshed. Keep the cache as a first-paint primer
but run the task: the column and pr tab paint instantly from cache, then
refresh as the live fetch streams in behind the frame. This matches
`wt list --full` and fits the picker's user-bounded lifetime, where a slow
forge call never blocks anything.

- picker: drop CiStatus from skip_tasks (BranchDiff stays skipped)
- collect: prime CI cells from the cache for the picker, then let the live
  task overwrite each cell via on_update (which now carries the row's item)
- pr tab: read a live per-row pr_status slot (mirroring the rendered slot)
  written by on_update, not the frozen skeleton snapshot; states are
  Loading / NoPr / HasPr
- populate_from_cache: pure primer — drop the backfill that resolved
  uncached rows to "no PR", since the live task fills them now
- docs, help, and 8 picker snapshots updated (the CI column now appears in
  the picker, matching wt list --full)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One new finding on the incremental commits (live CI fetch + PR-in-pr-tab). The progressive-render plumbing reads cleanly — priming the CI cells from cache and overwriting via on_update's now-item-carrying signature, with the pr tab reading a live per-row slot, is well-factored and well-tested.

Dead code: StyledLine::width_cjk / StyledString::width_cjk have no caller. Both methods are new in this PR and pub, so the dead-code lint stays quiet, but their only intended caller — the width_cjk overflow loop in render_grid_row — was removed when --prs rows were simplified to fixed-width cells ("All cells sit in fixed columns within the pane … so the row can't overflow"). The lone remaining reference, text.width_cjk() in grid_row_stays_within_the_list_pane, is on a String, so it resolves to unicode_width's trait method, not these. They're the 0%-covered cluster Codecov flags in src/styling/line.rs (and the matching StyledLine method just below). Deleting both closes 6 of the patch misses and matches the no-dead-code rule in CLAUDE.md. Happy to push the removal if useful.

On codecov/patch (red): the larger prs.rs cluster is the forge-fetch error/bail! arms (CLI-not-found, non-zero exit, undetermined forge), display(), and the in-test panic! guard — the headless-unreachable set from my earlier review, not worth contorting the suite for. The gitlab_mr_status / open_pr_status arms I flagged before are now covered. So aside from the dead width_cjk (and the unreachable!() arms in items.rs, which are fine), the remaining gap is the known-hard set; the merge-over-residual call is yours per CLAUDE.md.

Close the codecov/patch gap the live-CI-fetch change opened. Add unit
tests for `StyledString`/`StyledLine::width_cjk` (the CJK-width measure
skim uses for trailing-column clipping) and for `fetch_open_prs`'s two
forge-detection bails — no recognizable forge remote, and a recognized
but unsupported one (Gitea by host). All deterministic, no network.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`StyledString::width_cjk` / `StyledLine::width_cjk` were never called in
production — only by a unit test, which the bot reviewer correctly flagged
as dead. Testing them to satisfy codecov/patch was coverage-gaming; remove
the methods (and that test) instead. The only real `width_cjk` callers
elsewhere are `UnicodeWidthStr::width_cjk` on plain strings, unaffected.
Removing these uncovered lines from the patch raises coverage rather than
lowering it; the --prs forge-detection tests still cover the real gap.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Reconcile the live-CI-fetch + `--prs` picker work with main's skim 4.x
(ratatui/crossterm) migration (#3137), which rewrote the picker's skim
integration and dropped the vendored skim-tuikit tree.

Key reconciliations:
- Port `PrSkimItem` to skim 4.x: `display()` returns a ratatui `Line` via
  the shared `ansi_to_line` helper (not `skim::AnsiString`), and the
  `--prs` thread sends one batched `Vec<Arc<dyn SkimItem>>` (skim 4.x's
  channel takes batches, not single items).
- `on_update` writes the live `pr_status` slot, then pokes main's
  `request_render` (skim 4.x repaints on demand; the 100ms heartbeat is
  gone). The pr tab still can't be re-queried mid-selection, so its
  "press alt-6 to refresh" hint stays.
- Fix the Shift-Tab rotation: main added `shift-btab`/`shift-tab` bindings
  with the old 5-tab `tr 12345 51234`; bump them to the 6-tab
  `tr 123456 612345` so Shift-Tab wraps 1 -> pr (6), not 1 -> summary (5).
- Drop the stale skim-0.20.5 / vendor/NOTES.md SGR-22 and heartbeat
  comments; keep the explicit `\x1b[0m` reset (still needed).
- Regenerate the 11 picker PTY snapshots for skim 4.x rendering (border at
  col 59, `[N/M]` match counter) plus the CI column and pr tab.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The dead width_cjk methods I flagged earlier are gone, and the skim 4.8 migration merged in cleanly — the --prs streaming path adapts to the per-send batch model and is now exercised by the new test_switch_picker_prs_{github,gitlab}_list PTY tests, which is a real improvement over the prior coverage gap.

One stale-reference nit from the migration: the PR body's Testing section still calls the pr-row preview gap "a documented skim 0.20 limitation, resolved in 4.x" — but the PR now rides skim 4.8, so that rationale is self-contradictory. Either the description should drop the "skim 0.20" framing, or (if 4.8 really does reliably add an async-arrived row to the matched set) the deliberate gap is now closeable with an end-to-end PTY selection rather than the direct preview() unit call. Same staleness in the inline comment flagged below. Not a blocker — flagging since the merge introduced the inconsistency.

On codecov/patch: unchanged from my prior reviews — the merge call over any residual gap is yours per CLAUDE.md.

max-sixty and others added 6 commits June 21, 2026 11:49
The comment said selecting an async-arrived row is unreliable "in skim
0.20", but the picker now rides skim 4.8 — describe the version-agnostic
reason (assert on the streamed row, no selection) instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The --prs CI-column, preview-tab, and --prs paragraphs described cache priming, "instant first paint", TTL staleness, and live-fetch streaming — internals a --help reader skims past. Replace them with what each shows: the CI column mirrors `wt list --full`, the `pr` tab shows the row's PR/MR, and `--prs` adds open PRs/MRs that resolve via the `pr:`/`mr:` shortcut. Also drop the per-element narration of the preview-tab bar (dim/bold styling), which is self-evident on screen.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The --prs picker paints local rows instantly, then the open PRs/MRs stream in ~1s later when the forge call returns — with nothing to signal the gap. skim's native spinner can't fill it: it keys off un-taken items in the pool, which stay empty during the fetch. Add a dim "loading open PRs…" marker on the header row, shown while the forge call is in flight and cleared (with a repaint) when it resolves — rows sent, no PRs, or error.

Also drop the redundant "Enter: fetch & switch" footer from the `pr` preview pane; the top-of-picker legend already says what Enter does.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Appended after a full-width column header (Branch, Status, diffs, CI), the "loading open PRs…" marker clipped at the list/preview border to just "load" — invisible in practice. Show it in place of the column labels instead, so it's never clipped; the labels return when the rows land.

Add an end-to-end PTY test that proves the line reaches the screen: a new `delay_ms` on the mock-stub forge holds the PR list long enough to observe the loading state before the rows stream in. The picker captures and aborts before the delay elapses (the --prs thread is detached, not joined), so the test runs in ~1.7s, not 3s. The github list test now also asserts the line clears once the rows arrive.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	docs/content/switch.md
#	skills/worktrunk/reference/switch.md
#	src/cli/mod.rs
#	src/commands/list/render.rs
#	tests/snapshots/integration__integration_tests__help__help_switch_long.snap
max-sixty and others added 3 commits June 22, 2026 13:42
Two picker rendering refinements from review.

Gutter filtering: `--prs` rows now fold their `#` gutter glyph into the
matcher text, so typing `#` filters to PR/MR rows — matching the
worktree/branch sigil filtering from #3143, which previously skipped
these rows. The token derives from `PR_GUTTER_SIGIL` so it can't drift
from what renders; an engine-level test pins that `#` selects PR rows
but not worktree rows under skim's real matcher.

CI cache prime: the picker primes its CI cells from the local cache for
the first frame, then fetches live. A stale-but-numbered cache entry now
shows the number neutral-dim rather than in its cached green/red — the
color is a guess the live fetch overwrites moments later, so asserting a
verdict the picker doesn't yet trust is misleading. `wt list` is
unchanged: SHA-mismatch results stay colored-dim, so dim-red still flags
a failing pushed commit.

This splits an overloaded flag. The prime used to force `is_stale: true`
purely to get dimming, but `is_stale` means "local HEAD differs from the
CI's SHA" — false for a row that merely aged past its 30-60s TTL with an
unchanged HEAD. A new `is_priming` flag owns the placeholder rendering;
`is_stale` carries through from cache untouched (the live fetch
recomputes it), so the prime no longer fabricates a SHA mismatch.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	src/commands/list/collect/mod.rs
#	src/commands/list/layout.rs
The `pr` preview tab showed the PR/MR body verbatim and capped it at 30 wrapped lines (a "… N more line" hint collapsed the tail). Render the body through the markdown renderer the `summary` tab uses (bold headers, styled lists and inline code), still quoted in the house gutter, with no cap — the whole body renders and the preview pane scrolls for long ones.

Also drop the redundant "open the PR for its title & discussion" footer from the worktree-row `pr` pane.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 81f9260 into main Jun 22, 2026
44 of 47 checks passed
@max-sixty
max-sixty deleted the switch-prs-picker branch June 22, 2026 23:34
max-sixty added a commit that referenced this pull request Jun 27, 2026
Release v0.62.0 — minor bump (`cargo semver-checks` reports a breaking
library-API change — `ListConfig.columns` added a public field, which
requires at least a minor pre-1.0 — plus many new features).

### Highlights

- **`wt switch --prs`** — browse open PRs/MRs in the interactive picker,
with a live CI/review column and `pr` / `comments` / `log` preview tabs
([#3128](#3128)).
[Docs](https://worktrunk.dev/switch/)
- **Interactive picker now runs on Windows**
([#3217](#3217)).
- **`main…±` diff column shows by default** in `wt list`; `--full` now
adds only the off-machine columns (CI status, LLM summaries)
([#3236](#3236)).
- **`[list] columns`** selects and orders the columns `wt list` renders
([#3141](#3141)).
- **`wt config state logs profile`** performance profiler
([#3184](#3184)).
- Picker keyboard shortcuts (copy / open / refresh) and the `Alt-x`
removal rework, fish completion-recursion fixes, `CLAUDE_CONFIG_DIR`
support, and more.

**Breaking:** in the picker, remove moved from `Alt-r` to `Alt-x`
(`Alt-r` now refreshes).

Two "Still waiting" entries
([#3178](#3178),
[#3183](#3183)) were moved
here from 0.61.0 — they landed after the v0.61.0 tag, so they ship in
0.62.0.

The changelog also documents the `Alt-x` removal rework
([#3262](#3262)); the tag
will be placed on the `main` tip that includes both this release commit
and #3262.

Full notes in the `CHANGELOG.md` diff. Data-loss surface review of the
cumulative diff in progress; the keyword pass came back clean (the new
`Alt-x` removal uses safe variants — `SafeDelete`, no force,
approval-gated).

> _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