Skip to content

feat: implement customizable shortcuts#166

Open
ldm0 wants to merge 1 commit intomasterfrom
customize_shortcut
Open

feat: implement customizable shortcuts#166
ldm0 wants to merge 1 commit intomasterfrom
customize_shortcut

Conversation

@ldm0
Copy link
Collaborator

@ldm0 ldm0 commented Mar 15, 2026

  • Introduced a new shortcut management system allowing users to configure keyboard shortcuts.
  • Added a dedicated Shortcut Settings overlay in Preferences for users to modify shortcuts.
  • Implemented functionality to pause all shortcut handlers while the settings are open.
  • Updated context menus, tray, and application menus to reflect current shortcut values.
  • Enhanced shortcut capture and formatting utilities for better user experience.
  • Added tests for shortcut storage, capture, and settings overlay functionality.

- Introduced a new shortcut management system allowing users to configure keyboard shortcuts.
- Added a dedicated Shortcut Settings overlay in Preferences for users to modify shortcuts.
- Implemented functionality to pause all shortcut handlers while the settings are open.
- Updated context menus, tray, and application menus to reflect current shortcut values.
- Enhanced shortcut capture and formatting utilities for better user experience.
- Added tests for shortcut storage, capture, and settings overlay functionality.
Copy link

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 a configurable shortcut system to the Cardinal (macOS) frontend, including persistence, runtime hotkey handling, and a Preferences-driven UI for editing shortcuts.

Changes:

  • Introduces a canonical shortcut data model + localStorage persistence, plus parsing/capture/format utilities.
  • Adds a Shortcut Settings overlay reachable from Preferences, and wires shortcut updates through app hotkeys, context menus, app menu, tray menu, and the global quick-launch registration.
  • Adds i18n strings and test coverage for shortcut capture, persistence, overlay UX, and updated hotkey behaviors.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents that shortcuts are now configurable and adds the new default binding for copying filenames.
doc/inner/shortcut-customization.md Internal documentation describing the architecture and integration points for shortcut customization.
cardinal/src/utils/shortcutCapture.ts New utility module for parsing/normalizing/capturing/matching shortcuts and converting to display/menu formats.
cardinal/src/utils/globalShortcuts.ts Refactors global quick-launch registration to use stored shortcuts, support updates, and allow pausing while capturing.
cardinal/src/utils/tests/shortcutCapture.test.ts Adds tests for capture/normalize/match/format and menu accelerator mapping.
cardinal/src/tray.ts Updates tray menu to source accelerator from stored shortcuts and adds a refresh API.
cardinal/src/shortcuts.ts New persisted shortcut model (defaults, storage key, hydration, and menu/tray accelerator derivation).
cardinal/src/menu.ts Uses stored accelerators for Preferences/Hide menu items and supports temporarily disabling menu shortcuts.
cardinal/src/i18n/resources/zh-CN.json Adds translations for Preferences shortcut row + shortcut settings overlay labels/errors.
cardinal/src/i18n/resources/en-US.json Adds translations for Preferences shortcut row + shortcut settings overlay labels/errors.
cardinal/src/hooks/useShortcutSettingsController.ts New controller hook coordinating open/close, pause behavior, and save pipeline (global/menu/tray refresh).
cardinal/src/hooks/useFilesTabState.ts Makes search-history navigation configurable via ShortcutMap and allow disabling while capturing.
cardinal/src/hooks/useContextMenu.ts Displays per-action shortcut accelerators from the current shortcut config.
cardinal/src/hooks/useAppHotkeys.ts Replaces hardcoded app hotkeys with rules driven by ShortcutMap and an enabled toggle.
cardinal/src/hooks/tests/useFilesTabState.test.ts Updates tests for new shortcuts/shortcutsEnabled options.
cardinal/src/hooks/tests/useContextMenu.test.tsx Updates tests to pass shortcut config and validate accelerators.
cardinal/src/hooks/tests/useAppHotkeys.test.ts Updates tests for shortcut-config-driven behavior and adds filename-copy coverage.
cardinal/src/components/ShortcutSettingsOverlay.tsx New modal UI for recording/editing/resetting/saving shortcuts with capture error handling.
cardinal/src/components/PreferencesOverlay.tsx Adds a “Shortcuts” row to open the shortcut settings overlay.
cardinal/src/components/tests/ShortcutSettingsOverlay.test.tsx Tests shortcut recording + save pipeline and capture error rendering.
cardinal/src/components/tests/PreferencesOverlay.test.tsx Tests the Preferences row triggers opening shortcut settings.
cardinal/src/App.tsx Wires shortcut controller + shortcut props into hotkeys, context menu, files tab state, and overlay rendering.
cardinal/src/App.css Styles for the new Preferences manage button and the shortcut settings modal.
cardinal/src/tests/shortcuts.test.ts Tests storage defaults, persistence, invalid payload fallback, and accelerator derivation.
cardinal/src/tests/App.contextMenu.test.tsx Updates mocks for new ShortcutSettingsOverlay usage and menu/tray refresh calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +112 to +116
return definitions.map((definition) => ({
id: definition.id,
text: definition.text,
accelerator: formatShortcutForDisplay(shortcuts[definition.shortcutId]),
action: definition.action,
event.preventDefault();
event.stopPropagation();

const result = captureShortcutFromKeydown(event, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants