Skip to content

Add ⌘P worktree switcher (VS Code-style) with worktree MRU#1

Open
COCPORN wants to merge 3 commits into
mainfrom
feat/worktree-switcher
Open

Add ⌘P worktree switcher (VS Code-style) with worktree MRU#1
COCPORN wants to merge 3 commits into
mainfrom
feat/worktree-switcher

Conversation

@COCPORN

@COCPORN COCPORN commented Jun 18, 2026

Copy link
Copy Markdown
Owner

What

Reworks the ⌘P switcher from projects to worktrees, per the PR supabitapp#370 review (sbertix). Command Palette stays on ⌘⇧P.

Why

Supacode's core use case is multi-worktree-per-repo. A project-level switcher collapses the whole nav history down to one entry per repo and loses the worktree you actually had open. Worktrees are the primary rows instead.

Behavior

  • ⌘P opens a fuzzy switcher of every worktree, ordered most-recently-used (worktreeMRU). The current worktree renders but is flagged isCurrentWorktree, so ⌘P then Enter is a Cmd+Tab-style toggle to the previous worktree.
  • Fuzzy query matches the combined repo / worktree title — hits either the project name or the worktree name.
  • MRU recorded on both nav paths (hotkey/palette + sidebar click). Single-worktree repos behave exactly as the old project switcher did.
  • Switcher emits selectWorktree directly (no project→worktree resolution step); cancelling refocuses the current terminal.
  • Menu/shortcut renamed "Project Switcher" → "Go to Worktree".

Tests

RepositoriesFeatureWorktreeMRUTests (MRU recording on both nav paths) and switcher cases in CommandPaletteFeatureTests (ordering, current-flag, multi-worktree listing, combined title, mode dispatch).

Note

This is an intra-fork PR for CI verification (build + tests). Local builds are dead on this Mac (Zig/libSystem on macOS 26.x), so CI is the only build path.

🤖 Generated with Claude Code

ungedenstad and others added 3 commits June 18, 2026 08:54
Adds a worktree switcher on ⌘P and moves the existing Command Palette to ⌘⇧P,
aligning with VS Code (⌘⇧P = Command Palette; ⌘P = fast navigation). Both
shortcuts remain user-rebindable via shortcut overrides.

Reworked from the original project switcher per the PR supabitapp#370 review: Supacode's
core use case is multi-worktree-per-repo, where a project-level switcher
collapses the whole history down to one entry per repo and loses the worktree
you actually had open. Worktrees are the primary rows instead.

- ⌘P opens a fuzzy switcher of every worktree, ordered most-recently-used
  (RepositoriesFeature.State.worktreeMRU). The current worktree is rendered (so
  you see where you are) but flagged `isCurrentWorktree` so the default
  selection lands on the *previous* worktree — ⌘P then Enter is a Cmd+Tab-style
  toggle. Typing fuzzy-matches the combined `repo / worktree` title, so a query
  hits either the project name or the worktree name.
- worktreeMRU is recorded on BOTH navigation paths — setSingleWorktreeSelection
  (hotkeys/palette) and reduceSelectionChangedEffect (sidebar clicks) — so it
  tracks however you navigate. Single-worktree repos behave exactly as the
  original project switcher did.
- New PaletteMode (.commands / .worktreeSwitcher). The switcher emits
  `selectWorktree` directly (no project→worktree resolution step), so activation
  lands focus in the chosen terminal; cancelling refocuses the current terminal.

Covered by CommandPaletteFeatureTests (switcher ordering/flagging, MRU sort,
combined title, mode dispatch) and RepositoriesFeatureWorktreeMRUTests (MRU
recording on both nav paths).

Implemented with AI assistance (Claude Code).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `setup-macos` Tuist auth step was gated to skip only cross-fork PRs, so an
intra-fork PR (or a push to a fork's main) still tried `tuist auth login` and
failed with `notAuthenticated` / "No projects linked to the repository" — the
fork isn't linked in the Tuist dashboard. That blocked the whole build job
before lint/build/test ran.

Tuist auth is OIDC against the canonical upstream project and only buys the
remote cache; `tuist generate` (and thus the build) works without it — the
cross-fork-PR path already relies on this. Gate auth on the upstream repo so
forks (and cross-fork PRs) skip it and can run the full build+test job.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The worktree switcher records every concrete selection into the new
`worktreeMRU` state on both nav paths (setSingleWorktreeSelection and
reduceSelectionChangedEffect). TestStore checks state exhaustively, so the 27
selection/history tests that drive those paths now see an unasserted change.
Assert the new MRU head in each — selecting worktree W prepends W; nil/archived
selections leave it untouched (those tests already pass and are unchanged).

Behavior change is intentional (the switcher's whole point), so the tests follow.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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