Skip to content

fix(web): a letter key that types a symbol no longer records as the symbol's own key - #47126

Open
maria-rcks wants to merge 1 commit into
mainfrom
t3/keybinding-layout-symbol-recording
Open

maria-rcks wants to merge 1 commit into
mainfrom
t3/keybinding-layout-symbol-recording

Conversation

@maria-rcks

Copy link
Copy Markdown
Collaborator

On a keyboard layout that types a symbol on a letter key while the symbol's own key still types it (#35787: a custom XKB layout with . on the physical H key and on Period), Ctrl+H and Ctrl+. both recorded as mod+. in Settings > Keybindings. A mod+. binding fired on both keys and beat a mod+h binding on H. Reported on X: https://x.com/niknal0/status/2126529316561244460

A letter key now resolves as its letter when the browser's keyboard layout map shows the symbol's own key types the same symbol. Recording and matching both use this rule, so H records and fires mod+h and Period keeps mod+.. Layouts with only one key for the symbol keep it, so Dvorak's , on KeyW and AZERTY's , on KeyM still record mod+,. Without a layout map (Firefox, Safari), behavior is unchanged.

This follows up #36532 by @farseenmanekhan1232, which the conflict window closed. That PR resolved every symbol on a letter key as the letter, which would record Dvorak's comma as mod+w, so this version gates the rule on the layout map and is rewritten against today's matcher.

Before (main): Ctrl + physical H records mod+.

main: Ctrl + physical H on a layout with "." on H records mod+.

After: the same chord records mod+h

head: Ctrl + physical H records mod+h

After: Ctrl + Period still records mod+.

head: Ctrl + Period records mod+.

Proof:

Surfaces: the shared matcher (packages/shared) and the web recorder cover web and the desktop renderer. html_render previews and the desktop preview's main-process forwarding pre-filter keys without a layout map, so they may still forward H when only mod+. is bound; the app's matcher then resolves it as mod+h, so the wrong command does not run. Mobile hardware-keyboard shortcuts are native key commands with fixed keys and no recorder, so they don't share this code.

Not verified: a real XKB layout on Linux desktop (the layout map was emulated); the html_render and desktop preview forwarding paths; Firefox and Safari, which have no layout map and keep the old behavior.

Fixes #35787. Follows up #36532.

Written by claude-opus-5-5 in Claude Code, on behalf of Maria.

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 03a1b0a

Macroscope's review found this PR approvable — Shortcut recording and matching now distinguish letter keys that produce punctuation from the punctuation’s dedicated key. The adjustment is limited to layouts where that duplication is confirmed, with existing fallback behavior preserved.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: e9143bf · PR result: 03a1b0a · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Shortcut matching and settings recording now distinguish punctuation produced by letter keys from punctuation produced by dedicated symbol keys. Regression tests cover both cases across keyboard layouts.

Changes: Shortcut disambiguation

Layer / File(s) Summary
Shared duplicate-symbol matching
packages/shared/src/keybindingMatching.ts, packages/shared/src/keybindings.ts
Adds duplicateSymbolLetterKey and checks its letter-key result before matching resolved event keys.
Web shortcut event resolution
apps/web/src/keybindings.ts, apps/web/src/keybindings.test.ts
Shortcut event resolution checks for a duplicate-symbol letter key first. Tests cover . on KeyH versus Period and , on Dvorak KeyW.
Settings shortcut recording
apps/web/src/components/settings/KeybindingsSettings.logic.ts, apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
Settings recording checks for a duplicate-symbol letter key before existing key resolution. A test checks punctuation recorded from letter keys and dedicated punctuation keys.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: bugfix

Suggested reviewers: saphid, macroscopeapp, aymankhan9

Merge Risk: Minimal · up to 03a1b

Letter keys that type a symbol also available on its own key now record and match as the letter. Ctrl+H and Ctrl+Period become separate shortcuts, and layouts with only one key for the symbol are unchanged. The change is narrowly scoped, covered by new tests, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the core fix: a letter key that types a symbol no longer records as that symbol's own key. The changeset adds a layout-map-gated rule in recording and matching so H records and fires a…
Description check Passed The description follows the template: it has a problem statement (#35787 collision of Ctrl+H and Ctrl+. on a custom XKB layout), a change section (layout-map-gated letter-key resolution in recording a…
Linked Issues check Passed [#35787] requires that physical H and physical Period with . on a custom XKB layout record and match as different shortcuts (ctrl+h and ctrl+.). The reviewed head implements this through `duplic…
Out of Scope Changes check Passed The changed files are the shared matcher (keybindingMatching.ts, plus its re-export in keybindings.ts), the web shortcut helper (apps/web/src/keybindings.ts), the web recorder (KeybindingsSettings.log…
Full details: Title check

Explanation

The title names the core fix: a letter key that types a symbol no longer records as that symbol's own key. The changeset adds a layout-map-gated rule in recording and matching so H records and fires as mod+h instead of mod+. Title follows conventional commit form and is specific to the bug.

Full details: Description check

Explanation

The description follows the template: it has a problem statement (#35787 collision of Ctrl+H and Ctrl+. on a custom XKB layout), a change section (layout-map-gated letter-key resolution in recording and matching), scope (issue #35787 and follow-up to #36532, with a reason no separate issue is needed), and verification (CDP-driven dev-app runs, new unit tests that fail on main and pass on the branch, and a stated list of unverified paths). It also names the model and harness used. The Scope section links the issue, so the bug-report requirement is met. Minor gap: the verification mentions screenshots, which the template requires for UI changes, and they are embedded, so this is satisfied.

Full details: Linked Issues check

Explanation

[#35787] requires that physical H and physical Period with . on a custom XKB layout record and match as different shortcuts (ctrl+h and ctrl+.). The reviewed head implements this through duplicateSymbolLetterKey in packages/shared/src/keybindingMatching.ts. It returns the letter from event.code (KeyH to h) when the layout map shows that the symbol's own key (Period) types the same symbol. matchesKeybindingShortcut uses this result before the shared event-key resolver, so mod+. no longer matches the H key. In apps/web/src/keybindings.ts, shortcutKeyFromEvent applies the same rule. In apps/web/src/components/settings/KeybindingsSettings.logic.ts, recordedLayoutShortcutKey records the letter, so H records mod+h and Period keeps mod+.. Added tests in apps/web/src/keybindings.test.ts and KeybindingsSettings.logic.test.ts cover the H/Period case and the Dvorak comma case. The issue names Chromium's Ctrl-level handling as out of scope, and the PR does not change it. Evidence is the source diff plus the author's emulated-layout run. A real Linux XKB layout was not exercised. Without a layout map (Firefox, Safari), behavior is unchanged, as the issue does not require otherwise.

Full details: Out of Scope Changes check

Explanation

The changed files are the shared matcher (keybindingMatching.ts, plus its re-export in keybindings.ts), the web shortcut helper (apps/web/src/keybindings.ts), the web recorder (KeybindingsSettings.logic.ts), and the matching tests. Every source change serves the H/Period letter-key resolution in [#35787]. The Dvorak and AZERTY comma cases, which the PR keeps as mod+,, are covered by the tests. The Mac Alt-key layout-map path is kept, and the change routes it through the same map. No unrelated feature or refactor appears in the reviewed diff. The PR description notes that html_render and desktop-preview forwarding paths are not changed. That gap is a verification limit, not out-of-scope code.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e9143bf and 03a1b0a.

Files selected for processing: 6

  • apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
  • apps/web/src/components/settings/KeybindingsSettings.logic.ts
  • apps/web/src/keybindings.test.ts
  • apps/web/src/keybindings.ts
  • packages/shared/src/keybindingMatching.ts
  • packages/shared/src/keybindings.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two different keys record as the same shortcut when a layout puts punctuation on a letter key

1 participant