Skip to content

Start a new chat with Shift+N on a layout that does not write Latin letters - #580

Open
kevin9327 wants to merge 1 commit into
CopilotKit:mainfrom
kevin9327:hotkey-non-latin-layout
Open

kevin9327 wants to merge 1 commit into
CopilotKit:mainfrom
kevin9327:hotkey-non-latin-layout

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

What this changes

Settings → Keyboard shortcuts lists New chat as Shift+N, and useHotkey matches it with matchesHotkey, which compared event.key.toLowerCase() to "n".

key is the character the layout writes. That is the right thing to compare on a layout that only moves letters around. On Dvorak, the key that writes N is the one QWERTY calls L, and that is the key a person presses when told "N". A layout that writes another script has no key that writes an N at all:

Layout Shift + the N key key code Before After
Russian Т "Т" KeyN no match New chat
Greek Ν (capital nu, U+039D) "Ν" KeyN no match New chat
Dvorak N "N" KeyL New chat New chat (unchanged)
Dvorak B "B" KeyN no match no match (unchanged)

So for anybody with such a layout selected, the one shortcut the app lists does nothing.

A new keyOf(event) reads the combo key from key exactly as before, unless key is a single character outside ASCII. Only in that case does it read the physical key from code: KeyN reads as n, and Digit2 as 2. If code names no letter or digit, the written character stands and matches nothing. Every modifier is still compared exactly, and nothing else in matchesHotkey or useHotkey changes, including the editable-target guard.

Where it runs

  • New state that outlives a request? None.
  • What happens on the second replica? Not applicable. This is keyboard handling in the browser.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act. Unchanged. The shortcut only navigates to /channel/new.
  • New refusals and new failures each write a row. None are added.
  • Nothing new is trusted from the client that the server can resolve itself.

Changelog

  • A line in CHANGELOG.md under Unreleased.

Proof

New app/tests/hotkey-layouts.test.ts. It calls matchesHotkey with the registry's own new-chat combo and keydowns shaped the way a browser reports them, with key from the layout and code from the physical key.

On main (only the test file added):

error: expect(received).toEqual(expected)

      "Russian",
-     true,
+     false,
      "Greek",
-     true,
+     false,

(fail) Shift and the N key start a new chat on a layout that writes another script

 2 pass
 1 fail

The two passing cases are pins. Dvorak still goes by the letter, in both directions. The modifiers stay exact on the physical key: no Shift, extra Ctrl/Meta, another key's Cyrillic letter, a non-letter key, and the Shift key itself all match nothing.

With the fix:

  • bun test app/tests/hotkey-layouts.test.ts: 3 pass, 0 fail. Every branch of keyOf runs: a multi-character key, an ASCII key, and a non-ASCII key on a letter key and on a non-letter key.
  • bun test app/: 853 pass, 29 fail. On main it is 850 pass with the same 29 failures, all from this Windows machine: serve.test.ts port and websocket cases, Windows path separators, and a relative-time assertion reading a Korean locale.
  • bun run typecheck (app, server, worker): exit 0.
  • bunx biome check on the changed files: clean.

This PR adds its line at the top of ## Unreleased, the same place other open PRs add theirs, so the changelog may conflict. I'm happy to rebase.

🤖 Generated with Claude Code

…etters

Settings lists New chat as Shift+N, and `matchesHotkey` compared
`KeyboardEvent.key`. `key` follows the layout, which is right on Dvorak,
where the key that writes N is not the key QWERTY calls N. A layout that
writes another script has no key that writes an N at all. Shift and the
N key write "Т" on Russian and "Ν" (Greek capital nu) on Greek, so the
shortcut never fired for anybody with one of those layouts selected.

The combo's key is now read from `key` as before, unless `key` is a
single character outside ASCII. Then it comes from the physical key in
`code` (`KeyN` reads as "n"). Latin layouts behave exactly as they did,
the modifiers are still compared exactly, and a non-Latin character on
a key with no letter of its own matches nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant