Desktop: Fixes #11670: Allow shortcut saving when pre-existing keymap conflicts exist#15024
Conversation
…ng keymap conflicts exist Split the monolithic validation try/catch in ShortcutRecorder into two sequential stages: 1. Structural validation (validateAccelerator) — malformed accelerator strings still block save, as before. 2. Conflict validation (validateKeymap) — duplicate-accelerator errors now surface as a warning via onError but NO LONGER set saveAllowed=false. Previously, a plugin could register a shortcut that clashed with a built-in command (e.g. Ctrl+0 for both zoomActualSize and a plugin command). When the user opened the Keyboard Shortcuts screen, every ShortcutRecorder row would call validateKeymap() which scanned the entire live keymap, found the pre-existing collision, and threw an error that disabled the Save button even for completely unrelated rows the user was trying to edit. This made it impossible to save any shortcut change while any conflict existed. The warning triangle icon and red error text still appear for conflicting shortcuts, giving the user the full picture, while the Save button remains usable so they can proceed with their intended changes. Added ShortcutRecorder.test.tsx with 6 tests covering: - laurent22#11670 regression: conflict in other commands does not block save - conflict on the edited command itself does not block save - onError is called with the conflict error (warning surfaces) - structurally invalid accelerators still block save - empty accelerator (disable shortcut) is always saveable - valid accelerator with no conflicts is saveable
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughConfiguration files were updated to exclude a test file from linting and version control. A new test suite for the Changes
Suggested labels
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
|
||
| expect(isSaveDisabled()).toBe(false); | ||
| }); | ||
| }); |
|
Closed stale PR |
Problem
Fixes #11670.
When a user has an existing shortcut conflict (e.g., from a plugin), the
ShortcutRecordercomponent'suseEffecthook throws an error viavalidateKeymap(). This permanently setssaveAllowed = falsefor that row, deadlocking the UI and preventing the user from saving completely unrelated, valid shortcut changes.Solution
I split the validation logic in
ShortcutRecorder.tsxinto two distinct paths:onError), but they no longer block the save action (setSaveAllowed(true)is preserved).This allows users to save valid changes even if a pre-existing conflict exists elsewhere in their keymap.
Test Plan
Added 6 unit tests to
ShortcutRecorder.test.tsxverifying thatsaveAllowedremains true when a non-structural keymap conflict is detected, while preserving existing structural validation checks. All tests pass.(Note: I am currently experiencing
yarn installbuild chain failures on my local machine and cannot record a UI demonstration video at this exact moment, but the unit tests verify the deadlock is resolved.)AI Assistance Disclosure
Used AI (Antigravity / Claude) to assist with analyzing the React state deadlock and generating the corresponding Jest tests.