Repository navigation
feat: add keyboard shortcuts to switch between projects - #6834
realitsyourman wants to merge 6 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughAdds project-level sidebar navigation with next and previous keybinding actions. The new navigation model resolves project groups, orders projects and worktrees, removes duplicate host-qualified identities, and selects targets with wrap-around and visit recency. Sidebar keyboard handling activates and reveals worktrees or folder workspaces. The viewport now receives the required navigation data. Tests cover traversal, ordering, grouping, host identity, filtering, cycle handling, and keybinding metadata. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3936ddf2-4df8-4a64-821e-aceb18bf2601
📥 Commits
Reviewing files that changed from the base of the PR and between 30fc485 and 958b2952b0d917c7cf05b3f9dc19c753e1de4093.
📒 Files selected for processing (5)
src/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/project-navigation.test.tssrc/renderer/src/components/sidebar/project-navigation.tssrc/shared/keybindings.test.tssrc/shared/keybindings.ts
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/sidebar/WorktreeList.tsx (1)
2433-2454: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse the same host-filtered project groups for project navigation.
Rendered rows use
visibleProjectGroupsForRows, butnavigateProjectrebuilds order and folder ancestors from unfilteredprojectGroups. Under a host filter, a visible child group whose parent is filtered out renders as its own top-level sidebar project, while keyboard navigation can collapse it under the hidden parent key/order.Proposed fix
type VirtualizedWorktreeViewportProps = { folderWorkspaces: readonly FolderWorkspace[] /** Host-filtered folder workspaces, mirroring the rendered rows, for project nav. */ visibleFolderWorkspacesForRows: readonly FolderWorkspace[] + visibleProjectGroupsForRows: readonly ProjectGroup[] selectedWorktreeIds: ReadonlySet<string>folderWorkspaces, visibleFolderWorkspacesForRows, + visibleProjectGroupsForRows, selectedWorktreeIds,- projectGroups, + visibleProjectGroupsForRows, new Set(), new Map(),const parentGroupIdById = new Map( - projectGroups.map((group) => [group.id, group.parentGroupId ?? null]) + visibleProjectGroupsForRows.map((group) => [group.id, group.parentGroupId ?? null]) )- projectGroups, + visibleProjectGroupsForRows, projectGroupingprojectGroups, projectGrouping, + visibleProjectGroupsForRows, visibleFolderWorkspacesForRows, lastVisitedAtByWorktreeIdfolderWorkspaces={folderWorkspaces} visibleFolderWorkspacesForRows={visibleFolderWorkspacesForRows} + visibleProjectGroupsForRows={visibleProjectGroupsForRows} selectedWorktreeIds={selectedWorktreeIds}Also applies to: 2470-2479, 2535-2538, 6827-6827
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3248f95b-2a77-4a9e-9611-f88f475624a7
📥 Commits
Reviewing files that changed from the base of the PR and between 958b2952b0d917c7cf05b3f9dc19c753e1de4093 and 2902fae42f8d821b3742aa04fb69a412282f1494.
📒 Files selected for processing (3)
src/renderer/src/components/sidebar/WorktreeList.tsxsrc/renderer/src/components/sidebar/project-navigation.test.tssrc/renderer/src/components/sidebar/project-navigation.ts
Add remappable project.navigateNext / project.navigatePrevious actions that cycle to the next/previous top-level sidebar project (project group when grouped, repo when ungrouped) and activate that project's most-recently- focused worktree, mirroring the existing worktree navigation. Both ship unbound by default and are assignable in Settings > Shortcuts; every natural chord is already taken, so no default is claimed. Phase 1 of stablyai#6674; project.selectByIndex is deferred to a follow-up.
Folder-workspace-only projects were dropped from the project switch cycle: navigateProject only processed worktree rows and never passed folder workspaces to buildRows. Thread the host-filtered folder workspaces through buildRows and convert folder-workspace rows into navigation entries via folderWorkspaceToWorktree, so they share the worktree recency/activation id and dispatch to activateAndRevealFolderWorkspace. Use the host-filtered folder list (not the raw store list) so navigation never lands on a workspace hidden by the active host filter; worktrees are already host-filtered upstream. Extract resolveTopLevelProjectGroupId as a tested pure helper. Addresses review feedback on stablyai#6834.
2902fae to
43045ee
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Readiness verdict: READY (P0: 0, P1: 0, P2: 0 open)Reviewed at Residual issue found and fixed in this pass
Real Windows shortcut behavior — proofBoth actions ship unbound on all three platforms and the platform split is produced entirely by the shared registry — no hardcoded The win32 half of this is committed as a permanent regression test in Cross-platform checklist items with no surface in this diff: file paths, child processes, shells/PTYs, WSL argv, process enumeration, native modules, line endings. Live app proof (macOS dev build, real store: 13 repos / 464 worktrees)New remappable rows render under Settings → Shortcuts → Global, directly beneath "Next worktree", both unbound: With Before ( Note the target is Checklist coverage
Gates run at
|
| Gate | Result |
|---|---|
pnpm typecheck (3 tsgo projects) |
✅ pass |
pnpm lint (oxlint + native/type-aware quality, reliability gates, max-lines ratchet, runtime-electron ratchet, skill guides/manifest, 4× localization verifiers) |
✅ pass |
project-navigation.test.ts |
✅ 20/20 |
keybindings-unassigned-actions.test.ts |
✅ pass |
| Windows/platform proof above | ✅ 3/3 |
| Sidebar + keybindings suites in isolation | ✅ pass |
Full src/renderer/.../sidebar + src/shared/keybindings in one pool |
|
pnpm build |
not run (unchanged from the original PR note) |
The one caveat, stated plainly: running all 277 sidebar test files in a single local vitest pool produced 3, then 11, then 16 failed files across three runs — a different set each time, and every single failure was Error: Test timed out / Hook timed out, zero assertion failures. The affected files (WorktreeCard.*, WorktreeList.lineage*) are untouched by this PR. Re-running the representative failures in isolation: 5 files / 60 tests, all pass in 18s. This is local-machine saturation on heavyweight React component tests, not a regression from this change — CI shards these.
Summary
The change is ready. It adds two remappable, unbound-by-default global actions that cycle the sidebar's top-level project sections and activate each project's most-recently-focused workspace, reusing the existing activateAndRevealWorktree / activateAndRevealFolderWorkspace helpers. Nothing here touches persistence, IPC, the remote wire, Git, or process spawning, so the blast radius is one keydown handler and a pure ordering module.
Reviewing it surfaced exactly one real defect — with a single visible project, "Next project" wrapped onto itself and switched worktrees instead of doing nothing — which is fixed at 003eed38759 with a regression test. Windows behavior is real and proven, not assumed: the actions ship unbound on win32, a Mod+ override resolves to Ctrl there and Cmd on macOS, and the shortcut chips render Ctrl/Alt rather than ⌘/⌥. Live-app capture confirms the shortcut crosses project boundaries in both directions and lands on the recency-correct workspace.
Action required before release: none. The only open item is CI on the shared runner queue, which is external to this change.



Summary
Adds two remappable keyboard actions to switch directly between projects in the sidebar —
project.navigateNextandproject.navigatePrevious— mirroring the existing worktree navigation (worktree.navigateUp/Down). A "project" is a top-level sidebar section: a project group when grouped, or a repo when ungrouped. Switching activates that project's most-recently-focused worktree (same focus-recency rule as the Cmd+J palette), routed through the existingactivateAndRevealWorktreehelper so history and reveal behave exactly like worktree nav.Both actions ship unbound by default and are remappable in Settings → Shortcuts. Every natural chord is already taken (
Cmd+1–9,Cmd+Shift+↑/↓,Cmd/Ctrl+Shift+←/→from #6135), so rather than claim a conflicting default we register the actions with no binding — happy to set a default (e.g.Cmd+Shift+[/]) if maintainers prefer; it's a one-line change. Closes #6674 (Phase 1).project.selectByIndex(Cmd+number jump) from the issue is intentionally deferred to a follow-up — it needs the main-process digit-index IPC chain, separate from these renderer-only actions.Screenshots
No visual change by default (both shortcuts ship unbound). New remappable rows appear under Settings → Shortcuts → Global as "Next project" / "Previous project".
Testing
pnpm lintpnpm typecheckpnpm test(full keybinding/shortcut/sidebar regression: 1397 passed; new unit tests for the pure helpers)pnpm build— not run in this environment;pnpm typecheck(3 tsgo projects) passes cleanproject-navigation.test.ts(9 cases: wrap up/down, no-active default, recency selection, empty→null, order/dedupe/null-skip/input-order) + a registry test asserting both actions ship unbound on all platforms and remap correctlyAI Review Report
Reviewed with an architect agent against the acceptance criteria plus correctness/optimality.
getGroupKeysForWorktree(...)[0]) being sound for grouped (incl. nested groups), ungrouped repos, and non-repo groupings; exact mirror ofnavigateWorktree'sbuildRowsargs; recency selection on a different project; React hook deps; regression to the existing worktree-nav handler.buildProjectNavigationOrderand now drop the Pinned section's duplicate rows (sectionKey === PINNED_GROUP_KEY) before deriving order, so the cycle follows the visible sections. Each worktree still appears under its real section (the layout is fully expanded), so none are dropped. Added unit coverage for the derivation.⌘/⇧on macOS,Ctrl+/Shift+elsewhere) exactly like the sibling worktree actions — no hardcodedmetaKey. No paths, shell, or Electron platform branches touched.lint:switch-exhaustivenesspasses (no exhaustive switch over the action-id union was broken).Security Audit
Low surface. Renderer-only navigation that reuses existing, already-trusted helpers (
buildRows,getGroupKeysForWorktree,orderEmptyQueryWorktrees,activateAndRevealWorktree). No new input handling, no command execution, no path handling, no auth/secrets, and no new IPC (the IPC-bearingproject.selectByIndexis deferred). The pure helpers do bounded array/Map work over in-memory sidebar state. No follow-up needed.Notes
project.selectByIndexdeferred to a follow-up PR.workspace-status/pr-status/none) the action cycles the active grouping's top-level sections — a faithful mirror ofnavigateWorktree, which is itself grouping-agnostic. Can guard togroupBy === 'repo'if maintainers want "project" to always mean repo/project-group.projectGroups(same source asnavigateWorktree), so the two navigators always agree. Under an active SSH/multi-host filter the nav order can differ slightly from the host-filtered visible layout — pre-existing and shared with worktree nav, considered and non-blocking.Files:
src/shared/keybindings.ts(+ union/definitions),src/shared/keybindings-unassigned-actions.test.ts,src/renderer/src/components/sidebar/worktree-list/navigation/use-keyboard.ts(handler +navigateProject),WorktreeList.tsx/viewport/VirtualizedWorktreeViewport.tsx/viewport/viewport-props.ts(navigation-scope prop plumbing), and newsrc/renderer/src/components/sidebar/project-navigation.ts(+ test).Folder workspaces are included in the cycle and activate through
activateAndRevealFolderWorkspace. See the readiness verdict comment for the current gate results, Windows proof, and live-app capture.ELI5
New keyboard shortcuts jump to the next or previous project section in the sidebar, similar to worktree up/down. Focus goes to that project’s most recently used worktree.