Add ⌘P project switcher (VS Code-style) with per-project worktree memory#370
Add ⌘P project switcher (VS Code-style) with per-project worktree memory#370COCPORN wants to merge 1 commit into
Conversation
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>
|
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 |
|
Genuinely loving this ❤️ thanks |
|
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 |
|
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! |
It doesn't. But the main use case for Supacode is:
If I go through W1, W3, W5, W4, it collapses to just the latest from A and the latest from B.
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.
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 😅
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. |
|
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. |
|
Yep. Precisely that 💪 |
What
Adds a project switcher on ⌘P and moves the existing Command Palette to ⌘⇧P.
Why this binding
Aligns with VS Code muscle memory:
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
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.