Skip to content

Add ⌘P project switcher (VS Code-style) with per-project worktree memory#370

Open
COCPORN wants to merge 1 commit into
supabitapp:mainfrom
COCPORN:pr/project-switcher
Open

Add ⌘P project switcher (VS Code-style) with per-project worktree memory#370
COCPORN wants to merge 1 commit into
supabitapp:mainfrom
COCPORN:pr/project-switcher

Conversation

@COCPORN

@COCPORN COCPORN commented May 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds a project switcher on ⌘P and moves the existing Command Palette to ⌘⇧P.

Why this binding

Aligns with VS Code muscle memory:

  • ⌘⇧P → Command Palette — exact VS Code match.
  • ⌘P → fast navigation — VS Code's ⌘P (Quick Open) jumps to files; here it jumps to projects.

Both are rebindable or disablable in Settings → Keyboard Shortcuts → General, so this only changes the defaults — anyone who wants ⌘P back on the palette can set it.

Behavior

  • ⌘P opens a fuzzy switcher of repositories, MRU-ordered. The current project is shown but the default selection lands on the previous project — ⌘P then Enter is a Cmd+Tab-style toggle. Typing snaps to the top fuzzy match.
  • Switching returns you to the worktree you last had open in that project, recorded on both navigation paths (sidebar clicks and hotkeys/palette), falling back to main/first.
  • Cancelling the palette refocuses the current terminal.

Tests

CommandPaletteFeatureTests + RepositoriesFeatureProjectMRUTests — switcher ordering/flagging, defaultIndex seeding, and sidebar-path MRU recording. This PR's CI runs them.

Disclosure

Implemented with AI assistance (Claude Code); reviewed and verified in a real build.

Adds a project 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.

- ⌘P opens a fuzzy switcher of repositories ordered most-recently-used. The
  current project is rendered (so you see where you are) but flagged
  `isCurrentProject` so the default selection lands on the *previous* project —
  ⌘P then Enter is a Cmd+Tab-style toggle. Typing snaps to the top fuzzy match.
- Switching to a project resolves to the worktree you last had open there
  (`lastWorktreeByProject`), falling back to main/first. The MRU is recorded on
  BOTH navigation paths — `setSingleWorktreeSelection` (hotkeys/palette) and
  `reduceSelectionChangedEffect` (sidebar clicks) — so it works however you
  navigate.
- New `PaletteMode` (.commands / .projectSwitcher), `selectProject` item/
  delegate, and a `dismissedWithoutSelection` delegate so cancelling the palette
  refocuses the current terminal.
- Command Palette hint text updated ⌘P → ⌘⇧P.

Covered by CommandPaletteFeatureTests and RepositoriesFeatureProjectMRUTests
(switcher ordering/flagging, defaultIndex seeding, sidebar-path MRU recording).

Implemented with AI assistance (Claude Code); reviewed and verified in a real
build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@COCPORN

COCPORN commented May 30, 2026

Copy link
Copy Markdown
Contributor Author

I've made a quick video showcasing the changes. Let me know if you're interested, I'll turn it into two PRs, if not I'm happy to just run off this private fork going forward.

The terminal-focus I actually consider a bug, I'd try to patch that even if you don't care for the project switcher.

Thanks for considering it.

Supacode.PR.Project.Swap.and.Terminal.Focus-web.mp4

@sbertix

sbertix commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Genuinely loving this ❤️ thanks
(I'll try to review it asap)

@sbertix

sbertix commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

So I've played a bit more with this, and I feel like the use case for this, exactly as implemented, relies too much on the assumption from the video that most "projects" only have one worktree. It becomes almost useless for agentic-driven multi-worktree scenarios, which tend to be the main use case for Supacode.

I think the idea still has its merits, though, and I'd be more than happy to merge the two concerns, basically translating this into a palette for worktree selection history plus fuzzy search for everything not in history. Wdyt? @COCPORN

@COCPORN

COCPORN commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

I am not sure exactly what you mean, I don't really understand how the extra navigation palette interferes with worktrees. I'll probably just be running off my own fork going forward, because I actually need some other features that I'm fairly certain(?) won't be merged, so I am going to have to go off non mainline code personally anyway.

Thanks for considering it!

@sbertix

sbertix commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

I don't really understand how the extra navigation palette interferes with worktrees.

It doesn't. But the main use case for Supacode is:

  • repo A:
    • worktree 1
    • worktree 2
    • worktree 3
  • repo B:
    • worktree 4
    • worktree 5
    • worktree 6

If I go through W1, W3, W5, W4, it collapses to just the latest from A and the latest from B.
The case for this, without changes, works best specifically for the cases you're showing in the video, which are significantly less common:

  • repo A: worktree 1
  • repo B: worktree 2
  • repo C: worktree 3
  • repo D: worktree 4

My suggestion was just to update this so worktrees are the main rows in the palette, not "projects". It'd return the same exact result for single-worktree scenarios like the one you're highlighting, but provide the full picture for every other case. And I said it specifically because I want to merge this, because I feel like it's the right abstraction, it just needs to expand to cover more use cases, instead of just a personal one.

because I actually need some other features that I'm fairly certain(?) won't be merged

I'm always open to evaluating and discussing stuff. If you open an issue you'll know for sure how I feel about it, instead of guessing 😅

Thanks for considering it!

I'm not just considering this. I'm 100% merging this cause you had a great idea with this 🙇‍♂️. But if you're not interested in expanding it, I can take it from here.

@COCPORN

COCPORN commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Ah, I see what you're saying. I think. You want the worktree-switch to also be added to the stack, so the quick-switching includes flipping between them with the keyboard?

Also being able to address the worktree directly somehow in the navigation palette by fuzzy-finding it on worktree-name combined with the project name?

Are we on the same page? Because if we are, I think this makes a LOT of sense, and I'm happy to implement that.

EDIT: I'll make a PR for the other feature when it lands with an accompanying video.

@sbertix

sbertix commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Yep. Precisely that 💪

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.

3 participants