Skip to content

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

Closed
max-sixty wants to merge 8 commits into
switch-prs-pickerfrom
picker-gutter-search
Closed

max-sixty wants to merge 8 commits into
switch-prs-pickerfrom
picker-gutter-search

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

What

In the interactive wt switch picker, each row carries a 2-cell gutter sigil — @ current worktree, ^ primary worktree, + other/linked worktree, / local branch, | remote branch, # a --prs PR/MR row. Typing into the picker filtered only on each row's branch name + path (its skim text() / search_text), which deliberately excluded the gutter. So typing + matched nothing, even though every linked worktree shows a +.

This folds each row's gutter glyph into the fuzzy-search text, so typing a sigil filters by row kind: + narrows to linked worktrees, @ to the current worktree, and # to --prs rows.

How

A new canonical ItemKind::gutter_glyph() (and BranchScope::gutter_glyph(), replacing the old gutter_sigil()) is the single source of truth for both the rendered Gutter column and the picker's search text — so the displayed glyph and the searchable glyph can't drift. WorktreeSkimItem (worktree/branch rows) and PrSkimItem (--prs rows) each append their glyph to search_text. The render refactor is byte-identical (existing snapshots unchanged).

Rank stability. The glyph is a skeleton-time fact: is_current/is_main are set at item construction and BranchScope is structural (is_previous, set post-skeleton, never changes the glyph — previous worktrees share +). Folding it in therefore keeps skim's fuzzy ranks stable across the picker's progressive column updates, which was the constraint the existing search_text comment guarded.

The ^ / | collision

The picker uses skim's default extended-search mode, where some characters are query operators. Confirmed from skim 0.20.5 source (engine/factory.rs, engine/andor.rs):

  • +, @, #, / are literal — they match in the haystack.
  • ^ is the prefix anchor: a bare ^ is an empty-pattern prefix that matches every row.
  • | is the OR separator: a bare | trims to an empty query that matches nothing.

So ^ and | can't filter to the primary-worktree / remote-branch rows, and / over-matches because every path contains it. Rather than special-case the "good" glyphs, every row folds in its actual glyph uniformly, and the picker help documents which ones filter cleanly (+/@/#). An engine-level test (gutter_glyphs_filter_under_skims_default_engine) pins these semantics against skim's exact default factory stack, so a skim upgrade that changed them would fail loudly.

Verified end-to-end

Driven against a real multi-worktree repo through the actual picker:

  • + → exactly the linked worktrees
  • @ → exactly the current worktree
  • ^ → all rows (collision, as documented)
  • | → no rows (collision, as documented)

This live run also caught a doc bug in an earlier draft (the help had claimed / filters to local branches — it actually over-matches), now corrected.

Testing

  • ItemKind::gutter_glyph mapping per row kind.
  • WorktreeSkimItem / PrSkimItem search_text includes the glyph.
  • Engine-level test pinning the literal-vs-operator semantics.
  • cargo run -- hook pre-merge --yes green (4038 tests; fmt + clippy clean; docs in sync).

Note on the base

This stacks on #3128 (switch-prs-picker) — it edits --prs code (PrSkimItem) that only exists there. The diff below currently includes #3128's commits because origin/switch-prs-picker is behind the local tip this branch was cut from; it narrows to the single commit 7bbd804c5 once switch-prs-picker is pushed. A sibling branch is separately reworking the picker's CI-status path and touches the same two files (items.rs, progressive_handler.rs) but not search_text or the gutter — expect a trivial rebase when both land.

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max

worktrunk-bot and others added 8 commits June 18, 2026 12:05
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.4 → 0.1.6

The committed workflow bodies were stamped `0.1.4` (action ref already
at `0.1.5`); this regen brings both the stamp and the `max-sixty/tend@`
action pin to `0.1.6`. The workflow bodies are otherwise unchanged — the
deltas are the version stamp and action-ref bumps.

**Notable changes** (consumer-relevant):

- Nightly sweep now skips stamp-only workflow regen PRs and scopes its
"Notable changes" list to consumer-relevant entries (max-sixty/tend#689,
max-sixty/tend#690).
- CI monitoring: a pushed fix now waits for and owns its CI
(max-sixty/tend#700).
- Triage/skills: issue-comment templates reframed as examples;
over-stringent guidance softened into examples and open frames
(max-sixty/tend#692, max-sixty/tend#693).
- `running-tend`: added a weekly task to bump `claude_version` to latest
(max-sixty/tend#696).
- Skills: replaced duplicated guidance with `running-in-ci` references
(max-sixty/tend#703).

Compare: max-sixty/tend@0.1.4...0.1.6

Co-authored-by: worktrunk-bot <[email protected]>
Release v0.60.0 (minor bump from 0.59.0).

Minor because semver-checks flagged a breaking library-API change and
five new features landed since v0.59.0. The data-loss surface review (4
independent finders) cleared the one change that touches it (relocating
dirty linked worktrees, #3104).

### Improved
- Package installs now complete branch/worktree names via dynamic
registration (#3105, thanks @bendrucker)
- `wt step relocate` moves dirty linked worktrees (#3104, thanks
@lunaynx for reporting)
- `--dry-run` previews print to stdout (#3085)
- Picker gutter distinguishes local (`/`) and remote (`|`) branches
(#3115)
- `wt list --format=json` gains structured `repo`/`ci.repo` metadata
(#3021, thanks @jeremy0dell)
- `wt step eval --format=json` (#3106)
- `--format=claude-code` rejected on `wt list` / `wt config state get`
(#3116)

### Fixed
- `cargo install worktrunk` builds from crates.io again (#3124, fixes
#3123, thanks @kerrickstaley for reporting)
- Tab-completion works in repos with no commits (#3097, closes #3094)
- `wt config state get ci-status --format=json` honors
`[forge].platform` (#3120)

### Documentation
- `wt list --help` example tables fit the terminal (#3125)
- `/wt-switch-create` cross-repo handling reworked (#3118)
- Help-text and web-doc refinements (#3096, #3108, #3110, #3112, #3126)

Full notes in `CHANGELOG.md`.

> _This was written by Claude Code on behalf of max_
…ilds (#3130)

Follow-up to #3124, requested in [this
thread](#3124 (comment)):
turn the "build/package environment differs from the dev checkout" class
inner-loop.

#3123 (`env!("VERGEN_GIT_DESCRIBE")` failing on the crates.io archive)
was one instance of a general pattern — *something read at compile time
that exists in our git checkout but may be absent in a packaged build*.
There are three mechanisms in the crate that do this, and a missing file
in any of them is a hard compile error, exactly the #3123 failure mode:

| Mechanism | Embeds |
|-----------|--------|
| `include_str!` / `include_bytes!` | `dev/*.example.toml`,
`dev/opencode-plugin.ts`, `gemini-extension.json` |
| askama `#[template(path = …)]` (reads files at compile time via
proc-macro) |
`templates/{bash.sh,zsh.zsh,fish.fish,fish_wrapper.fish,nushell.nu,powershell.ps1}`
|

The detection gap: a plain `cargo build`/`cargo test` always sees these
files (they're in the working tree), so it can never catch a packaging
drop. Today that's only caught by the nightly Nix build (slow) or by
crates.io itself after publish (the worst loop). The realistic future
regression is someone adding a new `include_str!("../../assets/foo")` or
`#[template]` outside the currently-packaged dirs — it passes every PR
check, then breaks Nix that night and `cargo install` at the next
release.

This adds a fast guard (`embedded_assets_ship_in_package`, no build,
runs on every PR) that scans `src/` for every embedded path and asserts
each is:

1. **present in `cargo package --list`** — so it ships in the crates.io
archive (the #3123 surface), and
2. **covered by the `flake.nix` source filter** — so it survives the Nix
build.

Both currently pass. I verified the test isn't vacuous: pointing an
`include_str!` at a tracked-but-unpackaged file
(`tests/helpers/wt-perf/src/lib.rs`) fails it with both violations
reported, distinct from the compiler's own "file not found" for a path
that doesn't exist at all.

This sits alongside the existing `version_build.rs` guards (the fast
`env!`-vs-`option_env!` mechanism check on every PR, and the
`#[ignore]`d full-archive build in nightly), extending the same
philosophy to the file-presence half of the class.

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
…er (#3073)

Two display features for `wt list` and the interactive picker, developed
together because they share the column-layout and progressive-rendering
machinery.

## Custom columns (`[list.custom-columns]`)

Each `[list.custom-columns.<Header>]` entry in user config adds a `wt
list` column: a minijinja template rendered per row over `branch`,
`worktree_path`, `worktree_name`, and `vars.*`, with optional `width`
and drop priority. Values expand before the skeleton renders, from
in-memory data only — `vars` come from the bulk git-config snapshot, so
no subprocess runs per cell. Widths are measured from content like the
Branch and Path columns; a column that is empty on every row is dropped.

Unknown variables and misspelled filters abort `wt list` with the
available-variables hint; undefined values render as empty cells (the
intended sparse-column shape). `wt list --format json` gains a `columns`
map per item, and its `vars` field now reads from the snapshot too (the
previous `--get-regexp` line-parse truncated multiline values). The
picker shares the row renderer, so the columns appear there as well; a
broken definition degrades to no columns plus a stashed warning, since
collect runs while skim owns the terminal.

The key is `[list.custom-columns]`, not `[list.columns]`, to avoid
colliding with the column-visibility toggles in #3065 (which claims
`[list.columns]` as a flat map of built-in-column bools — a mutually
exclusive serde shape for the same protected key). Namespacing here lets
both land independently.

Ref #1982 — the custom-columns proposal lives in that thread. The
issue's own title is a separate directory-naming request, so this
doesn't close it.

## Cached PR/MR numbers in the picker

The picker skips the networked CiStatus task, so until now it had no CI
column at all. Cached statuses are local data, though: collect now fills
rows from `.git/wt/cache/ci-status/` when the task is skipped under a
progressive handler, so PR/MR numbers fetched by earlier `wt list
--full` or statusline runs render in the picker — aligned with the same
`MaxPrNumber` ratchet width `wt list` uses, and with zero network
access.

A valid cache entry renders as-is. An entry whose TTL passed or whose
branch head moved keeps its PR/MR number dimmed: the number still
identifies the PR when the pipeline color may be outdated. Expired
entries without a number are dropped. The CI column is allocated only
when some row had a usable entry, and rows the cache can't fill resolve
to blank rather than a pending placeholder, since no task repaints them.

## Key files

- `src/config/expansion.rs`, `src/config/user/sections.rs`,
`src/git/repository/config.rs` — column resolution, the template
environment, and the bulk git-config snapshot.
- `src/commands/list/layout.rs`, `src/commands/list/render.rs` — column
width allocation and cell rendering.
- `src/commands/list/ci_status/mod.rs` — `populate_from_cache`, the
cache-only fill.
- `src/commands/picker/mod.rs` — the dry-run dump
(`WORKTRUNK_PICKER_DRY_RUN`) that makes picker row content assertable in
tests.

## Testing

Integration tests cover both features: custom columns (table render,
JSON output, empty-column drop, invalid-template error) and the picker
(cached PR numbers appear in the dry-run dump, uncached branches stay
blank). Unit tests cover the cache-population logic (valid,
expired-with-number, head-moved, dropped). Verified against the full
`cargo run -- hook pre-merge --yes` gate locally.

> _This was written by Claude Code on behalf of max_

---------

Co-authored-by: Claude Fable 5 <[email protected]>
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]>
Typing into the `wt switch` picker filtered only on branch name + path, so
typing a gutter sigil like `+` matched nothing. 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), so `+` filters to linked
worktrees, `@` to the current worktree, and `#` to `--prs` rows.

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 `|` 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's default stack.

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

Copy link
Copy Markdown
Owner Author

Closing as superseded. The gutter-filter change on this branch landed on main directly via #3143 (the port) and #3154 (the WorktreePresence refactor), and the one piece unique to this branch — the # PR-row arm — is being folded into #3128 (switch-prs-picker) directly. Nothing here is lost.

This was written by Claude Code on behalf of max

@max-sixty max-sixty closed this Jun 22, 2026
@max-sixty
max-sixty deleted the picker-gutter-search branch June 22, 2026 18:10
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