You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Empty userAgentData.platform is treated as non-Apple, so mod hotkeys and Kbd show Ctrl on macOS #5253
isApplePlatform() in packages/core/src/hooks/useHotkeys.ts and the matching detection in packages/core/src/Kbd/Kbd.tsx commit to userAgentData and can never fall through:
When userAgentData.platform is present but empty, the 'platform' in uaData guard passes, /mac/i.test('') is false, and the navigator.platform branch — which would answer correctly — is never reached. An empty string is being read as a negative answer rather than as no answer.
Electron builds that rewrite the app's user-agent / client-hints identity ship exactly that: platform: ''. On macOS the result is that every mod combo registered through useHotkeys listens for Ctrl instead of Cmd, and every <Kbd> renders Ctrl.
Both surfaces are wrong and consistent with each other, so nothing looks broken — the shortcut simply never fires, and the hint tells you to press the key that also doesn't work.
The two call sites are independent copies of the same logic, and the useHotkeys docstring states it "Mirrors the detection used by Kbd so displayed and handled shortcuts agree", so they need the same change.
Suggested direction: treat a blank platform as unknown and fall through to the existing navigator.platform branch, instead of as not Apple. We have this running locally as a patch and are happy to open a PR — but since it touches packages/core/ and changes behavior, tell us whether you want it through the specification protocol first.
Diagnosis and draft prepared with Claude Code; reviewed and verified by the contributor before filing.
Reproduction
In any context where UA-CH is present but blank:
Object.defineProperty(navigator,'userAgentData',{value: {platform: ''}});// isApplePlatform() === false, on macOS
End to end: run an Electron build on macOS with an overridden user agent, register useHotkeys('mod+k', fn) and render <Kbd keys="mod+k" />. Cmd+K does not fire and the Kbd shows Ctrl. The same code in Safari/Chrome on the same machine behaves correctly.
Astryx Version
0.4.5 (verified against the published tarball; also present in 0.4.0)
Environment
macOS, Electron / Chromium, any build that overrides the user-agent or client-hints identity.
Verified against current main: both isApplePlatform() in useHotkeys.ts (line 84-88) and the matching detection in Kbd.tsx (line 135-140) have the identical structure you describe. 'platform' in uaData is true whenever the key exists at all, blank or not, so an Electron build shipping platform: '' commits to the UA-CH branch, tests /mac/i.test('') (always false), and never reaches the navigator.platform fallback that would answer correctly. Confirmed on both call sites, matching the docstring's claim that they're kept in sync.
Since you already have a patch running locally, I'll leave the PR to you rather than duplicate the work, happy to review once it's up. Your suggested direction (blank platform treated as unknown, fall through to navigator.platform) matches the actual bug precisely; the one thing I'd flag for the PR itself is keeping both call sites' fix in the same commit given they're documented as needing to stay identical.
Activity
HelloOjasMutreja commentedon Aug 21, 2026
Verified against current main: both
isApplePlatform()inuseHotkeys.ts(line 84-88) and the matching detection inKbd.tsx(line 135-140) have the identical structure you describe.'platform' in uaDatais true whenever the key exists at all, blank or not, so an Electron build shippingplatform: ''commits to the UA-CH branch, tests/mac/i.test('')(always false), and never reaches thenavigator.platformfallback that would answer correctly. Confirmed on both call sites, matching the docstring's claim that they're kept in sync.Since you already have a patch running locally, I'll leave the PR to you rather than duplicate the work, happy to review once it's up. Your suggested direction (blank platform treated as unknown, fall through to
navigator.platform) matches the actual bug precisely; the one thing I'd flag for the PR itself is keeping both call sites' fix in the same commit given they're documented as needing to stay identical.fix(core): read a blank client-hints platform as unknown, not as non-…
fix(core): read a blank client-hints platform as unknown, not as non-…
fix(core): read a blank client-hints platform as unknown, not as non-…