fix(desktop): make keyboard shortcuts work on Windows and Linux - #919
Open
ozymandiashh wants to merge 1 commit into
Open
fix(desktop): make keyboard shortcuts work on Windows and Linux#919ozymandiashh wants to merge 1 commit into
ozymandiashh wants to merge 1 commit into
Conversation
Closes getagentseal#918. The renderer's keydown handler required event.metaKey and explicitly rejected event.ctrlKey, so every shortcut was dead outside macOS: on Windows and Linux metaKey is the Super key, which the OS shell takes. Navigation (1-8), Settings (,) and Refresh (R) all did nothing. The sidebar and footer hints also hardcoded the Cmd glyph, so a Windows user was shown chords that could not fire. Add app/renderer/lib/platform.ts as the single source of truth for platform-aware shortcuts, reading the platform the preload already exposes (window.codeburn.platform) with a user-agent fallback for the non-Electron cases. isModifierChord accepts Cmd-without-Ctrl on darwin and Ctrl-without-Cmd elsewhere; altKey stays rejected on both, because AltGr on European Windows layouts arrives as Ctrl+Alt and must not hijack a typed character. Every visible shortcut label now resolves through shortcutLabel() at render time, so the sidebar shows Ctrl+1 where macOS shows the Cmd glyph. The mac chord condition is unchanged: the old guard admitted metaKey && !altKey && !ctrlKey && !shiftKey, and the new one admits exactly the same set on darwin. The Electron application menu is deliberately left alone. It ships no reload/forceReload role and no CmdOrCtrl+R accelerator, which is what leaves Ctrl+R free for the renderer to handle on Windows. Also corrects the Settings navigation hint, which read 1-7 while the sidebar has eight numbered destinations. Tests cover both platforms for labels and dispatch, including the negatives: Meta on win32, Ctrl on darwin, and the Ctrl+Alt AltGr shape.
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
event.metaKeyand explicitly rejectedevent.ctrlKey(app/renderer/App.tsx:443), so navigation (1-8), Settings (,) and Refresh (R) were dead everywhere except macOS, wheremetaKeyis Cmd. On Windows and LinuxmetaKeyis the Super key, which the OS shell takes.app/renderer/lib/platform.tsas the single source of truth:isModifierChord()accepts Cmd-without-Ctrl on darwin and Ctrl-without-Cmd elsewhere, andshortcutLabel()resolves every visible keycap at render time, so Windows showsCtrl+1where macOS shows⌘1(the reporter's screenshot shows the macOS glyphs on Windows 10).altKeystays rejected on both platforms. This is load-bearing on Windows: AltGr on European layouts is delivered as Ctrl+Alt, soCtrl+Alt+<digit>must not hijack a character the user is typing.The macOS chord condition is unchanged. The old guard admitted
metaKey && !altKey && !ctrlKey && !shiftKey; the new one admits exactly the same set on darwin.The Electron application menu is deliberately untouched. It ships no
reload/forceReloadrole and noCmdOrCtrl+Raccelerator, which is what leaves Ctrl+R free for the renderer to handle on Windows —app/electron/main.test.tsalready pins that invariant.Also corrects the Settings navigation hint, which read
1-7while the sidebar has eight numbered destinations (⌘8→ Plans has always worked).Note on the report: the issue attributes the failure to running without administrator rights. That turned out to be a red herring —
globalShortcutappears nowhere inapp/electron, so nothing here needs elevation.Testing
npm testpassesnpm run buildsucceedsUnit tests cover both platforms for labels and for keydown dispatch, including the three negatives: Meta on win32, Ctrl on darwin, and the Ctrl+Alt (AltGr) shape.
Beyond the unit tests, I ran the actual renderer under
vitewith the preload bridge reporting each platform, and drove realkeydownevents against the mounted app:Layout was checked too, since
Ctrl+1is a wider keycap than⌘1in a fixed 186px sidebar: all nine rows stay single-line, with the tightest row ("Pull requests") keeping about 10px of slack.npm testinapp/: 468 passed across 38 files.npm run buildandtsc --noEmitare clean.I do not have a Windows machine, so the verification above forces the platform the preload reports rather than running on real Windows hardware. Happy to have @thatsam-brainiac or another Windows user confirm on the packaged build.
Known limitation (deliberately out of scope)
Keyboard layouts where the digit row requires Shift (AZERTY and similar) still will not trigger the numbered shortcuts, because the handler matches on
event.key. Fixing that means matchingevent.codeand allowing Shift for digits, which is a behaviour change worth its own PR. Happy to follow up if you want it.