Skip to content

feat(switch): make the picker filter text match the gutter sigil - #3143

Merged
max-sixty merged 3 commits into
mainfrom
gutter-search
Jun 21, 2026
Merged

max-sixty merged 3 commits into
mainfrom
gutter-search

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

What

Typing into the wt switch picker only ever filtered on branch name + path, so typing a gutter sigil like + matched nothing — which is why + couldn't narrow the list to the linked worktrees. Each row now folds its gutter glyph into the matcher's search_text, so a sigil filters by row kind: + → linked worktrees, @ → the current worktree.

Diagnosis

The picker's SkimItem::text() (the matcher haystack) is built in progressive_handler::on_skeleton from branch_name + path only; the gutter glyph lived solely in the rendered Gutter column. So the glyph was visible but unsearchable.

The fix introduces one canonical ItemKind::gutter_glyph() -> char (replacing BranchScope::gutter_sigil() -> &'static str) as the single source shared by the rendered Gutter column and the search text — the glyph you see is the glyph you can type. It's a skeleton-time fact (is_current/is_main set at construction, BranchScope structural), so folding it into the search text keeps fuzzy ranks stable across the picker's progressive column updates, and the rendered Gutter column stays byte-identical (no picker snapshot churn).

Which sigils filter, and the ^/| collision

+ and @ are literal characters, so they filter cleanly to their row kind. The others can't, because they collide with skim's extended-search query operators — handled by documenting rather than fighting them:

  • ^ is skim's prefix anchor; a bare ^ is an empty prefix pattern that matches every row, so it can't isolate the primary worktree.
  • | is skim's OR operator; a bare | has empty operands and matches nothing, so it can't isolate remote-branch rows.
  • / matches most rows because every worktree path contains it.

The picker --help text states which sigils filter cleanly, and an engine-level test (gutter_glyphs_filter_under_skims_default_engine) pins these semantics against skim's real default matcher — an AndOrEngineFactory wrapping an ExactOrFuzzyEngineFactory, the same factory the picker gets when it sets neither --exact nor --regex.

skim 4.8 port notes

This is the port of #3142 onto main after the skim 4.8 migration (#3137) landed — #3137 was a backend rewrite, not a version bump, so this is a re-application rather than a cherry-pick. The search_text fold and the gutter_glyph canonicalization transplant cleanly onto the rewritten picker. I re-verified the operator semantics from primary evidence under skim 4.8 (the OR regex changed from r" +\| +" to r" *\|+ *") and they're unchanged: ^ still matches all, | still matches nothing. The old engine-level test's API (AndOrEngineFactory::new(ExactOrFuzzyEngineFactory::builder().build())) survives the rewrite verbatim.

The # PR-row gutter arm from #3142 is intentionally not included here: src/commands/picker/prs.rs exists only on the switch-prs-picker branch (#3128), not on main. It lands separately once #3128 merges. This PR supersedes #3142 for everything except that # arm.

Tests

  • gutter_glyph_marks_each_row_kind (item.rs) — glyph correctness per kind.
  • search_text_folds_in_gutter_glyph (progressive_handler.rs) — on_skeleton appends the glyph to the matcher text.
  • gutter_glyphs_filter_under_skims_default_engine (progressive_handler.rs) — operator semantics under skim 4.8's default engine.
  • test_switch_picker_gutter_glyph_filters_by_kind (switch_picker.rs) — end-to-end PTY test: typing + in the real picker narrows to the linked worktree only. The matched row has no literal + in its name or path, so the match succeeds only via the folded-in glyph — a regression would empty the list and fail the test.

Full gate green locally (cargo run -- hook pre-merge --yes: 4036 tests, clippy + lints).

This was written by Claude Code on behalf of max

Typing into the `wt switch` picker filtered only on branch name + path, so
typing a gutter sigil like `+` matched nothing — it could never narrow to the
linked worktrees. Each row now folds its gutter glyph into the fuzzy-search text
via a canonical `ItemKind::gutter_glyph` (the single source shared with the
rendered Gutter column, replacing `BranchScope::gutter_sigil`), so `+` filters
to linked worktrees and `@` to the current worktree.

The glyph is a skeleton-time fact (`is_current`/`is_main` set at construction,
`BranchScope` structural), so folding it in keeps fuzzy ranks stable across the
picker's progressive column updates, and the rendered Gutter column stays
byte-identical.

`^` and `|` collide with skim's prefix-anchor and OR query operators (so `^`
matches everything and `|` nothing), and `/` over-matches because every path
contains it; the picker help documents which sigils filter cleanly, and an
engine-level test pins the operator semantics against skim 4.8's default stack.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit c5c2742 into main Jun 21, 2026
34 checks passed
@max-sixty
max-sixty deleted the gutter-search branch June 21, 2026 22:36
max-sixty added a commit that referenced this pull request Jun 22, 2026
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]>
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