Feature/sidebar collections shortcuts#7521
Open
devmuggs wants to merge 4 commits intousebruno:mainfrom
Open
Conversation
added 4 commits
March 19, 2026 02:58
Author
|
Have been meaning to make this pr for a week or so now, I'm sure there are points to polish, is like 3:08am JST though so I'm off to bed! Have a good one! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds keyboard shortcut support for sidebar collection/folder/request actions and surfaces those shortcuts in dropdown menus to improve keyboard-driven navigation/workflows (issue #6855).
Changes:
- Introduces a reusable
useKeybindingshook andusePlatformhook for cross-platform shortcut handling. - Wires keydown handlers into sidebar Collection / CollectionItem rows to trigger existing actions via shortcuts.
- Updates
MenuDropdownto display keybinding hints via a newKeyBindTextcomponent.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/bruno-app/src/ui/MenuDropdown/index.js | Renders keybinding hints in menu item labels when item.keyBinding is provided. |
| packages/bruno-app/src/hooks/usePlatform/index.js | Adds a platform-detection hook used for Cmd/Ctrl display. |
| packages/bruno-app/src/hooks/useKeybindings/index.js | Adds key/modifier constants and a hook to map keydown events to actions. |
| packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js | Adds keybindings for collection-level actions and attaches handler to the collection row. |
| packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js | Adds keybindings for folder/request actions and attaches handler to the item row. |
| packages/bruno-app/src/components/Keybindings/KeyBindText.jsx | New component to render menu label + keyboard hint text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
84
to
88
| const collectionRef = useRef(null); | ||
|
|
||
| const platform = usePlatform(); | ||
| // Only count persisted items; transients don't affect empty state | ||
| const itemCount = collection.items?.filter((i) => !i.isTransient).length || 0; |
| }) | ||
| .join('+'); | ||
|
|
||
| const keyLabel = keybinding.length === 1 ? keybinding.toUpperCase() : keybinding.join('/'); |
Comment on lines
+9
to
+23
| export default function usePlatform() { | ||
| const [platform, setPlatform] = useState(null); | ||
|
|
||
| useEffect(() => { | ||
| // use navigator to detect platform | ||
| const platform = navigator.platform.toLowerCase(); | ||
| if (platform.includes('mac')) { | ||
| setPlatform(PlatformKind.MacOS); | ||
| } else if (platform.includes('win')) { | ||
| setPlatform(PlatformKind.Windows); | ||
| } else if (platform.includes('linux')) { | ||
| setPlatform(PlatformKind.Linux); | ||
| } else { | ||
| setPlatform(PlatformKind.Windows); // Default to Windows if platform is unrecognized | ||
| } |
Comment on lines
+83
to
+98
| /** | ||
| * Factory function to create a keybinding configuration object. | ||
| * @param {Object} params | ||
| * @param {Function} params.actionFn - The function to execute when the keybinding is triggered. | ||
| * @param {Array} params.modifiers - An array specifying which modifier keys are required for the keybinding (e.g., [Modifier.Meta]). | ||
| * @param {string} params.alias - A unique alias for the keybinding, used for internal registry and debugging. | ||
| * @param {string} params.description - A description of the keybinding's action, used for documentation and debugging. | ||
| * @returns {Object} A keybinding configuration object that can be used with the useKeybindings hook. | ||
| * | ||
| * Example usage: | ||
| * const renameKeybinding = createKeybinding({ | ||
| * actionFn: () => console.log('Rename action'), | ||
| * modifiers: [Modifier.Meta], | ||
| * alias: 'rename', | ||
| * description: 'Triggers the rename action when Meta+R is pressed' | ||
| * }); |
Comment on lines
+141
to
+152
| const handleKeyPress = useCallback((e) => { | ||
| const pressedKey = e.key; | ||
| const keyBinding = keybindings?.[pressedKey.toLowerCase()]; | ||
| if (!keyBinding) return; | ||
|
|
||
| const { actionFn, modifiers = [] } = keyBinding; | ||
|
|
||
| // Merge default modifiers with provided modifiers | ||
| const effectiveModifiers = modifiers; | ||
| const doModifiersMatch = evaluateModifiersMatch(e, effectiveModifiers); | ||
|
|
||
| if (!doModifiersMatch) return; |
| import { useBetaFeature, BETA_FEATURES } from 'utils/beta-features'; | ||
| import { useSidebarAccordion } from 'components/Sidebar/SidebarAccordionContext'; | ||
| import { createEmptyStateMenuItems } from 'utils/collections/emptyStateRequest'; | ||
| import useKeybindings, { createKeybinding, Key, Modifier, getKeybindingTooltip } from 'hooks/useKeybindings'; |
Comment on lines
+481
to
+486
| acc[keyBinding] = createKeybinding({ | ||
| actionFn: item.onClick, | ||
| modifiers: item.modifiers || [], | ||
| alias: item.id, | ||
| description: item.label | ||
| }); |
| modifiers: [Modifier.CmdOrCtrl], | ||
| leftSection: IconFolder, | ||
| label: getRevealInFolderLabel(), | ||
| label: 'Show in Folder', |
Author
|
Copilot has come back with some very good points, more than happy to address this tomorrow 🫡 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #6855
Description
Was wanting to interact with the side panel via keyboard shortcuts, so I set up a very lightweight hook and integrated with existing code to best of my ability.
This is my first time contributing to open source, but really love this project and have really been enjoying using it.
Thanks for all your hard work!
Note: In an attempt to limit scope and breadth of changes, it's quite intentionally low spec, not allowing for custom shortcuts, or anything like that - more than happy to move in that direction if it would be welcome 😄
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.