The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep stored overrides for not-yet-registered keybind actions (#116331)
yagna5945cd4ad741
diff --git a/apps/desktop/src/store/keybinds.test.ts b/apps/desktop/src/store/keybinds.test.tsnew file mode 100644index 00000000000..cbc30313783--- /dev/null+++ b/apps/desktop/src/store/keybinds.test.ts@@ -0,0 +1,38 @@+import { beforeEach, describe, expect, it, vi } from 'vitest'++const STORAGE_KEY = 'hermes.desktop.keybinds'++function storedDiff(): Record<string, string[]> {+ return JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? '{}')+}++describe('keybinds store boot persist', () => {+ beforeEach(() => {+ window.localStorage.clear()+ vi.resetModules()+ })++ it('keeps stored overrides for plugin actions that register after boot', async () => {+ // A plugin-action rebind saved by an earlier session. The plugin has not+ // registered yet at boot, so the id is unknown to `allKeybindActions()`.+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify({ 'demo.late': ['mod+alt+l'] }))++ await import('./keybinds')++ // The boot-time subscribe persist must carry the unknown id forward+ // instead of overwriting storage with only the registered actions.+ expect(storedDiff()).toEqual({ 'demo.late': ['mod+alt+l'] })+ })++ it('keeps unregistered overrides when the user rebinds a built-in', async () => {+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify({ 'demo.late': ['mod+alt+l'] }))++ const { setBinding } = await import('./keybinds')+ setBinding('session.new', ['mod+shift+n'])++ expect(storedDiff()).toEqual({+ 'demo.late': ['mod+alt+l'],+ 'session.new': ['mod+shift+n'],+ })+ })+})diff --git a/apps/desktop/src/store/keybinds.ts b/apps/desktop/src/store/keybinds.tsindex 50c50d6bc29..4706ce04e66 100644--- a/apps/desktop/src/store/keybinds.ts+++ b/apps/desktop/src/store/keybinds.ts@@ -65,6 +65,15 @@ function persistBindings(bindings: KeybindBindings): void {}}+ // Actions contributed after boot (plugins register late) are missing+ // from the registry when the boot-time subscribe fires. Carry their+ // stored overrides forward so the persist does not wipe them.+ for (const [id, combos] of Object.entries(storedOverrides)) {+ if (!(id in defaults)) {+ diff[id] = combos+ }+ }+persistString(STORAGE_KEY, JSON.stringify(diff))}