Repository navigation
fix(keybinding): sync menu bar and command palette when keybindings change - #4681
Merged
Merged
Conversation
…nt bindings Rebuild every window menu (editor + macOS settings) so accelerators are re-read from the live keybinding map, re-applying the active window's menu. Editor menus preserve their runtime toggle state. This is the capability the keybinding-save flow needs to refresh the menu bar without a restart (#3998). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
After persisting user keybindings, rebuild the application menu via AppMenu.updateKeybindings() and push the refreshed accelerator map to editor windows so the command palette updates too. Previously the new bindings only took effect after an app restart, so the menu bar and command palette kept showing the old shortcuts (#3998). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 task done
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.
Summary
Fixes #3998 — after a user customizes a keyboard shortcut in Preferences, the change was persisted and re-registered, but the application menu bar (and the command palette) kept showing the old accelerator until the app was restarted.
Root cause: the application menu is built once at startup with accelerators baked in from
keybindings.getAccelerator(id). The save handler (mt::keybinding-save-user-keybindings→Keybindings.setUserKeybindings) updated the in-memory key map and re-registered the local shortcuts, but never rebuilt the menu.Changes
AppMenu.updateKeybindings()(new): rebuilds every window menu — editor menus on all platforms and the macOS settings-window menu — so accelerators are re-read from the live keybinding map, and re-applies the active window's menu. Editor menus preserve their runtime toggle state (source-code / typewriter / focus / sidebar / tab-bar).setUserKeybindings, callsmenu.updateKeybindings()and pushes the refreshed accelerator map to editor windows viamt::keybindings-response, so the command palette (which rendersentry.shortcut) updates too.Places that now update live (no restart)
Known limitation (not addressed here)
muya's inline format toolbar (the floating bold/italic/… bar) shows shortcut hints that are hardcoded in
packages/muya/src/ui/inlineFormatToolbar/config.tsand decoupled from the desktop keybinding system (they're hand-aligned to the default bindings). Those hints do not follow user customizations. This spans the self-contained@muyajs/coreengine (whose design keeps the engine unaware of the desktop key map) and is intentionally left out of this PR. There is also a latent behavior nuance there: muya's internalFORMAT_SHORTCUTScan still fire the old default format shortcut after a rebind. Tracked as a follow-up.Testing
keybinding-menu-rebuild.spec.ts(TDD: red → green) covering editor + settings menu rebuild and re-application of the active menu.keybinding-reload.spec.tsandapplication-menu-state.spec.tspass;typecheckandlintclean.electron dev: changing a shortcut updates the menu bar and command palette without restart.🤖 Generated with Claude Code