Repository navigation
feat(sidebar): show Cmd/Ctrl+1-9 index badges on workspace cards - #16083
BinyaminEden wants to merge 2 commits into
Conversation
Hold the workspace.selectByIndex modifiers (Cmd on Mac, Ctrl elsewhere) and each of the first nine sidebar cards overlays the digit that jumps to it, the way Safari numbers tabs. Release, or move focus off the window, and they go. The digits come from getRenderedWorktreeEntriesInSidebarOrder — the same row walk the sidebar publishes as the shortcut's target cache — so a badge can never label a card the chord would not activate. Badges stay hidden outside the terminal view and while Cmd+J owns the digits, matching the handler. The armed modifiers are read from the user's effective binding rather than hardcoded, so a remapped or unbound row is reflected. A 400ms hold delay keeps ordinary chords (Cmd+C, Cmd+S) from strobing the sidebar. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SdXFcR11WcqQXiSRo4Jj1G
|
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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds platform-aware modifier-chord utilities for workspace digit shortcuts. It preserves sidebar row keys during rendered worktree ordering. New hooks track held shortcut chords and map visible rows to digits 1–9. The virtualized sidebar passes this map through row contexts. Item and folder workspace rows render accessibility-hidden shortcut badges when an index is available. Tests cover modifier resolution and rendered row ordering. Merge Risk: 🟡 Moderate · up to The new badges can advertise a custom Shift+digit workspace shortcut that does not activate on macOS, potentially misleading users and preventing the indicated workspace from being selected. Merge readiness is moderate until this is corrected or explicitly accepted. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 00e1f61d-f2b2-45aa-9181-0f76e57a75d9
📒 Files selected for processing (10)
src/renderer/src/components/sidebar/WorkspaceShortcutIndexBadge.tsxsrc/renderer/src/components/sidebar/workspace-index-shortcut-badges.tssrc/renderer/src/components/sidebar/worktree-list/rows/folder-row.tsxsrc/renderer/src/components/sidebar/worktree-list/rows/item-row.tsxsrc/renderer/src/components/sidebar/worktree-list/viewport/VirtualizedWorktreeViewport.tsxsrc/renderer/src/components/sidebar/worktree-list/viewport/virtual-row-context.tssrc/renderer/src/components/sidebar/worktree-sidebar-row-preference.test.tssrc/renderer/src/components/sidebar/worktree-sidebar-row-preference.tssrc/shared/keybindings-digit-index.test.tssrc/shared/keybindings.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
canonicalizeDigitIndexBinding accepts a bare "1" — the settings UI rejects it, but a hand-edited keybindings.json reaches getDigitIndexModifierChords with no modifier at all. The resulting empty chord matched every ordinary keystroke, so the badges would appear mid-typing and stay until a modifier or a blur. Skip empty chords. Also drop the Shift+digit example from the test: macOS reports '!' rather than '1' for Shift+1, so matchKeybindingDigitIndex cannot match a Shift binding today and this must not claim it can. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SdXFcR11WcqQXiSRo4Jj1G
|
Strong support for this interaction. I hit a real discoverability problem with The strongest invariant here is the one this PR is built around: the badge and activation target must come from the same rendered-row walk, including grouping, collapsed sections, folder workspaces, and sidebar-open/closed behavior. That is consistent with #9497 / #10693. One pinned-row detail seems worth making explicit before merge: when The branch currently reports conflicts with |
|
Follow-up to my pinned-row note above: I implemented the pinned-first shortcut behavior downstream and found an important coupling in the current API. So this PR does not currently introduce that regression—its Suggested split:
That preserves both invariants: the Pinned card owns the earliest visible digit, while Shift-clicking its natural-group duplicate uses the natural row position. A focused regression should anchor after the natural duplicate, Shift-click that duplicate, and assert that rows between the Pinned section and natural group are not selected. The PR is still |
What
Hold ⌘ (Ctrl on Windows/Linux) and each of the first nine workspace cards in the sidebar overlays the digit that jumps to it — the way Safari numbers tabs. Release the key, or move focus off the window, and the badges go away.
Before this,
workspace.selectByIndex("Select Workspace 1–9") was invisible: nothing told you which card a given number would land on.How the numbering stays honest
The jump handler resolves its target from the row order the sidebar publishes through
setVisibleWorktreeShortcutTargets. The badges read the row keys out of that same walk (getRenderedWorktreeEntriesInSidebarOrder) instead of a second copy, so a badge can never label a card the chord would not activate. Pinned-row de-duping, folder workspaces, grouping and lineage nesting all follow from that one function.Badges stay hidden whenever the chord would not act:
Cross-platform
The armed modifiers come from the user's effective binding, not a hardcoded
metaKey:getDigitIndexModifierChords()resolvesModto Meta on darwin and Control elsewhere, and honours overrides — remap the row toCtrl+Shift+1and the badges arm on that chord instead.A 400 ms hold delay keeps ordinary chords (⌘C, ⌘S) from strobing the sidebar.
Files
src/shared/keybindings.tsgetDigitIndexModifierChords()+ chord equality helpersrc/renderer/src/components/sidebar/workspace-index-shortcut-badges.tssrc/renderer/src/components/sidebar/WorkspaceShortcutIndexBadge.tsxShortcutKeyCombowith sidebar tokensworktree-sidebar-row-preference.tsitem-row.tsx,folder-row.tsx,virtual-row-context.ts,VirtualizedWorktreeViewport.tsxTest plan
pnpm typecheckandpnpm lintpass (lint covers the max-lines ratchet, localization and code-quality audits).vitest src/renderer/src/components/sidebar src/shared/keybindings— 276 files / 2386 tests pass, including two new cases: the row-key entries walk, and the platform/override resolution of the armed modifiers.src/main/claude-accounts,src/main/skills,src/relay(keychain / filesystem / subprocess). Nothing in this diff reaches those areas, but I did not confirm they fail on a clean tree.Not done: no rendered check in the running app — badge placement (card top-right) and light/dark contrast are reasoned from the tokens, not seen. Worth an eye during review.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SdXFcR11WcqQXiSRo4Jj1G