feat(tab-bar): add shortcut to open commands for active tab group#6325
feat(tab-bar): add shortcut to open commands for active tab group#6325agch-dev wants to merge 6 commits into
Conversation
- New `tab.openQuickCommandsMenu` keybinding action (no default binding) - TabBarQuickCommandsMenu listens for the binding and toggles open/closed - Scoped to the active tab group naturally since the component only mounts when its group is focused
- Replace `setMenuOpen` toggle with `handleOpenChange(!menuOpen)` so closing via keyboard runs the same reset logic (query, focus frame, value override) - Guard against key-repeat events to prevent rapid toggling on held key - Wrap `handleOpenChange` in `useCallback` so it's stable enough to include in the `useEffect` dependency array without causing spurious re-registrations - Update tests to reflect that re-running the effect between presses is required for the close path, and add a repeat-event test
📝 WalkthroughWalkthroughAdded a new 🚥 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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e337f717-924a-4147-9316-626bfc0a3e97
📒 Files selected for processing (5)
src/renderer/src/components/tab-bar/TabBarQuickCommandItem.tsxsrc/renderer/src/components/tab-bar/TabBarQuickCommandsMenu.keyboard.test.tssrc/renderer/src/components/tab-bar/TabBarQuickCommandsMenu.tsxsrc/shared/keybindings.test.tssrc/shared/keybindings.ts
| function withShortcutHint(label: string, shortcutLabel: string | null): string { | ||
| return shortcutLabel ? `${label} (${shortcutLabel})` : label | ||
| } |
There was a problem hiding this comment.
There is an identical function at src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx. I wanted to extract it into somewhere so that it could be reused but wasn't sure of the placement.
Happy to move it and reuse if placement guidance is given.
There was a problem hiding this comment.
this comment is not outdated, I just added a docstring on top
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/tab-bar/TabBarQuickCommandsMenu.tsx (1)
346-353: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRoute item-action closes through
handleOpenChange.These handlers close with
runAndClose/setMenuOpen(false), bypassing the cleanup inhandleOpenChange(false), so query and selection override can remain stale when reopening after run/edit/delete.Proposed fix
const runAndClose = useCallback( (command: TerminalQuickCommand): void => { - setMenuOpen(false) + handleOpenChange(false) onRunCommand(command) }, - [onRunCommand] + [handleOpenChange, onRunCommand] )onEdit={() => { - setMenuOpen(false) + handleOpenChange(false) onEditCommand(command) }} onDelete={() => { - setMenuOpen(false) + handleOpenChange(false) onDeleteCommand(command) }}onEdit={() => { - setMenuOpen(false) + handleOpenChange(false) onEditCommand(command) }} onDelete={() => { - setMenuOpen(false) + handleOpenChange(false) onDeleteCommand(command) }}Also applies to: 364-371
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4cc91c55-0705-4ce3-bdd4-7bebd305454c
📒 Files selected for processing (2)
src/renderer/src/components/tab-bar/TabBarQuickCommandsMenu.keyboard.test.tssrc/renderer/src/components/tab-bar/TabBarQuickCommandsMenu.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/tab-bar/TabBarQuickCommandsMenu.keyboard.test.ts
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai run pre-merge checks |
✅ Actions performedRunning Pre-merge checks. Results will be posted in the summary comment once complete. |
|
@coderabbitai generate docstrings |
|
This command requires write access to the repository. Only users with write or admin permissions can trigger CodeRabbit to commit or create pull requests. |
Summary
Implements #6266
Users will now be able to open the Quick Commands Menu with a keyboard shortcut of their choosing. Making it easier to continue with the natural flow of using the keyboard to start searching for the command to run. Eliminating the necessary step of using the mouse to interact with the feature.
Screenshots
quick-commands-shortcut-demo.mp4
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI Review Report
metaKey/ctrlKeykeybindingMatchesAction+getShortcutPlatform()⌘/⇧, Linux/Windows getsCtrl+/Shift+capture: true+stopImmediatePropagation(), scoped to component lifecycleSecurity Audit1
keydownlistener useskeybindingMatchesActionfor key comparison — no eval orrunAndClosedispatches a pre-stored quick command — existing behavior, no newwithShortcutHintreturns a plain string usedstopImmediatePropagationon capture phase is intentional scoping,Follow-up needed: None.
Notes
TabBarQuickCommandsMenuand extract therenderItemintoTabBarQuickCommandItem(src/renderer/src/components/tab-bar/TabBarQuickCommandItem.tsx). This is because the file reached the 400 lines limit. Let me know if another approach would have been better.