Skip to content

fix(web): a layout symbol on a letter key records as that letter - #36532

Closed
farseenmanekhan1232 wants to merge 2 commits into
pingdotgg:mainfrom
farseenmanekhan1232:fix/35787-punctuation-letter-collision
Closed

farseenmanekhan1232 wants to merge 2 commits into
pingdotgg:mainfrom
farseenmanekhan1232:fix/35787-punctuation-letter-collision

Conversation

@farseenmanekhan1232

Copy link
Copy Markdown

Problem

A keyboard layout can type . on the physical H key while the dedicated Period key also types .. Chromium reports both as key="." (differing only in code: KeyH vs Period), and both chords recorded as the same shortcut: a mod+. binding fired on both keys, and mod+h could not be bound at all.

Change

A non-letter layout symbol on a Key[A-Z] code now resolves as that letter:

  • letterKeyForLayoutSymbol in packages/shared/src/keybindingMatching.ts returns the code's letter when the layout key is a single non-letter, non-number character and no Alt is held; an unshifted + keeps the zoom-key behavior.
  • shortcutKeyFromEvent and resolveEventKeys use it, so the letter key records and matches as its own letter while the dedicated punctuation key keeps the symbol. Alt-modified symbols (macOS Option glyphs) keep the layout symbol, and non-Latin layouts still match by physical code.
  • The desktop preview guest's inlined matcher in packages/shared/src/htmlRender.ts follows the same rule.
  • Recording (recordedLayoutShortcutKey in KeybindingsSettings.logic.ts) records the letter, so Settings no longer shows two identical mod+. bindings for two different keys.

Scope

Fixes #35787. No contracts, server, or mobile changes; the shared helper is re-exported for the settings logic only.

Verification

  • Unit: two new cases fail on the base commit 2e0bd97e8 and pass here — recording fails with expected 'mod+.' to be 'mod+h', and matching with expected 'thread.next' to equal 'thread.previous' (the mod+. binding fired on the letter key). 86/86 across keybindings.test.ts, KeybindingsSettings.logic.test.ts, keybindingsFocus.test.ts, and htmlRender.test.ts; vp run check:changed clean.
  • Scenario: vp run scenarios:prove scripts/scenarios/keybinding-layout-symbol-records-letter.e2e.ts --base 2e0bd97e8 reports Proven: the scenario fails on base 2e0bd97e86 and passes on head. The scenario signs into the real app, opens Settings → Keybindings, and dispatches the two keydowns the issue captured.

Base 2e0bd97e86 — the H-key chord records mod+. (the bug):

base capture: mod+. recorded from the KeyH chord

Head — the same chord records mod+h:

head capture: mod+h recorded from the KeyH chord

Head — the dedicated Period key still records mod+.:

head capture: mod+. recorded from the Period chord

A layout can type "." on KeyH while the dedicated Period key also types ".",
and both chords recorded as the same shortcut: a mod+. binding fired on both
keys and mod+h could not be bound at all (pingdotgg#35787).

A non-letter layout symbol on a Key[A-Z] code now resolves as that letter, so
the letter key records and matches apart from the punctuation key that owns the
symbol. Alt-modified symbols and an unshifted "+" keep the layout symbol, and
the desktop preview guest's inlined matcher follows the same rule.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 14, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 09231d1

Macroscope's review found this PR approvable — Shortcut recording and matching now distinguish symbols typed on letter keys from dedicated punctuation keys, consistently across the app and embedded previews. The change is limited to keyboard-layout interpretation and leaves configured defaults and existing event guards unchanged.

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

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Shortcut matching and recording now distinguish punctuation produced by a physical letter key from the same punctuation produced by its dedicated key. The shared matcher, bootstrap keydown handling, and settings recorder use the physical letter in applicable cases. Unit and browser tests cover the distinction.

Changes: Layout-aware shortcut handling

Layer / File(s) Summary
Resolve layout symbols to physical letter keys
packages/shared/src/keybindingMatching.ts, packages/shared/src/keybindings.ts, apps/web/src/keybindings.ts, packages/shared/src/htmlRender.ts, apps/web/src/keybindings.test.ts
The shared matcher resolves eligible punctuation on a physical letter key to that letter. The helper is exported through shared and web keybinding modules. Bootstrap keydown matching uses lowercase letters or a matching letter code for eligible symbols. A regression test distinguishes KeyH from Period.
Record layout symbols in settings
apps/web/src/components/settings/KeybindingsSettings.logic.ts, apps/web/src/components/settings/KeybindingsSettings.logic.test.ts, scripts/scenarios/keybinding-layout-symbol-records-letter.e2e.ts
The settings recorder uses the physical letter for eligible layout symbols. Unit and browser tests verify that KeyH records as mod+h while Period records as mod+..

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to ffb55

Shortcuts now distinguish punctuation typed on a letter key from the dedicated punctuation key. No remaining merge risk was identified, and the change is covered by unit and browser tests.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(web): a layout symbol on a letter key records as that letter" matches the main change. The PR makes a non-letter layout symbol reported on a Key[A-Z] physical key resolve to that letter…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and reproduction context. The Change section explains the helper, mat…
Linked Issues check Passed Issue #35787 requires that a physical Key[A-Z] key whose layout symbol is punctuation (Chromium reports key="." with code=KeyH) records and matches as its own letter. The dedicated Period key must kee…
Out of Scope Changes check Passed Changed files relate to the #35787 objective. keybindingMatching.ts holds the helper and its use in matching and recording. htmlRender.ts applies the same rule to the inlined matcher, which must agree…
Full details: Title check

Explanation

The title "fix(web): a layout symbol on a letter key records as that letter" matches the main change. The PR makes a non-letter layout symbol reported on a Key[A-Z] physical key resolve to that letter, both when recording and when matching shortcuts. The title is specific, follows the conventional commit form, and names the web scope. It does not cover the shared matcher or htmlRender changes, which is acceptable.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and reproduction context. The Change section explains the helper, matcher, recording, and the htmlRender mirror. The Scope section links issue #35787 and states that no contracts, server, or mobile changes are included. The Verification section gives specific test counts, the base and head commits, the scenario proof command, and before/after screenshots. It also notes the Alt-modified and non-Latin cases. The template's optional agent-model line is absent, but that is minor.

Full details: Linked Issues check

Explanation

Issue #35787 requires that a physical Key[A-Z] key whose layout symbol is punctuation (Chromium reports key="." with code=KeyH) records and matches as its own letter. The dedicated Period key must keep its symbol. At head, letterKeyForLayoutSymbol in packages/shared/src/keybindingMatching.ts returns the lowercase letter for a single non-alphanumeric key on a KeyA-KeyZ code when Alt is not held. shortcutKeyFromEvent and resolveEventKeys use it. The Period code still resolves to ".". The htmlRender.ts inlined matcher follows the same rule. In KeybindingsSettings.logic.ts, recordedLayoutShortcutKey returns the physical key when letterKeyForLayoutSymbol(event) resolves, so the H-key chord records mod+h. Unit tests cover recording (mod+h versus mod+.) and matching (thread.previous versus thread.next). Letter-valued layout keys (Colemak, AZERTY) take the existing path. The unshifted "+" zoom-key behavior is preserved (#14833). I did not re-run the author's reported tests (86/86) or the scenario proof; the verdict rests on source evidence and the test cases described in the diff summary.

Full details: Out of Scope Changes check

Explanation

Changed files relate to the #35787 objective. keybindingMatching.ts holds the helper and its use in matching and recording. htmlRender.ts applies the same rule to the inlined matcher, which must agree with the shared logic. keybindings.ts and packages/shared/src/keybindings.ts re-export the helper. KeybindingsSettings.logic.ts adds the letter-symbol branch to recordedLayoutShortcutKey; the US shifted-glyph branch there predates this change. Tests and the e2e scenario verify the new behavior. No contracts, server, or mobile files change. Residual edge case: on Linux, AltGraph symbols on letter keys (for example @ on KeyQ) may resolve to the letter when Ctrl is held and Alt is not. This follows the same rule and no concrete regression appears in the reviewed evidence.

Finishing Touches

Generate unit tests (beta)

  • 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 09231d1 and ffb55c5.

Files selected for processing: 1

  • packages/shared/src/htmlRender.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.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 14, 2026
@maria-rcks

maria-rcks commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

merged current main into the existing head without rebasing. resolved the html bootstrap conflict by keeping main's label-focus handler and the contributor's layout-symbol matcher. the diff against main stays at 8 files, 134 additions and 5 deletions.

verified ffb55c5535 with blacksmith vp run check:changed github/main: format, lint, both knip checks, typechecks for 35 packages, 80 focused tests and the affected react compiler checks passed. two independent read-only reviews found no actionable issues.

in the real chrome client, settings records ctrl + . on KeyH as mod+h, then the same symbol on Period as mod+.. keyboard events reproduce the reported layout properties. native desktop guest input and a physical custom xkb layout were not exercised.

settings records the letter key separately from the punctuation key

@maria-rcks

maria-rcks commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

verified unchanged head ffb55c5535c7859a48bb477bf6ec094efb2b10f2 on linux with the repo's playwright and /usr/bin/google-chrome. reproduced the bug first on github/main at 77f87ea4c191de3533567ee90ed67998b5ca4a5d, in a separate worktree. installed dependencies and ran one dev server at a time with isolated empty state.

created a real git project through the app and completed a codex gpt-6.1-sol turn on each revision. both turns read the repository's README and returned its exact first line.

used trusted chrome cdp key events matching the reported layout: ctrl held, key=".", with code="KeyH" or code="Period".

  • main: both keys record mod+.. with terminal bound to mod+h and sidebar to mod+., the h-key event wrongly hides the sidebar.
  • head: h records mod+h; period records mod+.. saved both through settings and checked persistence after reload. h toggles only the terminal; period toggles only the sidebar. opening and closing both works.
  • nearby behavior: the original ctrl+j terminal shortcut works before customization, and plain . on KeyH types into the composer without toggling panels.

blacksmith-check: vp run check:changed github/main passed format, lint, both knip checks, 35 package typechecks, 80 tests, and affected react compiler checks. github checks are green. no source changes were needed.

before, main records the h-key chord as mod+.:

main records the h-key chord as mod plus period

after, the same chord records mod+h:

head records the h-key chord as mod plus h

the dedicated period key keeps mod+.:

head keeps the dedicated period chord as mod plus period

recording: h opens/closes the terminal, period hides/shows the sidebar, then plain symbol input types text:

independent shortcut execution and plain symbol typing in the real app

Not verified

physical custom xkb/wayland input, native electron preview guest forwarding, macos option input, windows, ios/android, and remote/relay/tunnel connections. this vm verification used chrome's trusted event injection with the issue's exact key properties; it did not exercise a physical custom keyboard layout.

@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Closing: this PR still conflicts with main and has had no activity for 7 days since the rebase request.

To continue, rebase the branch and open a new PR that links this one. See the conflict window.

@github-actions github-actions Bot closed this Nov 30, 2026
@github-actions github-actions Bot removed the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 30, 2026
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). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in 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

3 participants