Skip to content

Feature/sidebar collections shortcuts#7521

Open
devmuggs wants to merge 4 commits intousebruno:mainfrom
devmuggs:feature/sidebar-collections-shortcuts
Open

Feature/sidebar collections shortcuts#7521
devmuggs wants to merge 4 commits intousebruno:mainfrom
devmuggs:feature/sidebar-collections-shortcuts

Conversation

@devmuggs
Copy link
Copy Markdown

@devmuggs devmuggs commented Mar 18, 2026

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!

image

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:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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.

@devmuggs
Copy link
Copy Markdown
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!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useKeybindings hook and usePlatform hook for cross-platform shortcut handling.
  • Wires keydown handlers into sidebar Collection / CollectionItem rows to trigger existing actions via shortcuts.
  • Updates MenuDropdown to display keybinding hints via a new KeyBindText component.

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',
@devmuggs
Copy link
Copy Markdown
Author

Copilot has come back with some very good points, more than happy to address this tomorrow 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support keyboard shortcuts

2 participants