Repository navigation
[feat] canvas: keep one shortcut list for hints, help and keys - #501
Zhangbo-cn wants to merge 7 commits into
Conversation
7f7407e to
20bfd31
Compare
|
First CI run went red on Cause was mine, not flaky: the new Re-verified after the fix: |
f8350ca to
eba5454
Compare
Each panel owned its own copy of the shortcuts: the workspace help dialog listed them by hand, tooltips hardcoded strings like "⌘ ⇧ G", aria-keyshortcuts repeated them again, and four separate keydown listeners decided what the keys did. The copies had already drifted -- the help dialog advertised Ctrl+, for the model settings while the handler listened for a different key, so the shortcut did nothing while the tooltip promised it worked.
src/canvas/shortcuts.ts is now the one table: a combo, its macOS and Windows spellings, and the event names it matches. Tooltips, the help dialog, aria-keyshortcuts and the app-wide handler all read from it, and a unit test fails if a registered combo has no platform spelling or if a handler matches a key the table does not list. One window listener replaces the four: it ignores keys typed into a field or pressed while a dialog is open, so Escape and typing behave as before.
The comma mapping is spelled out rather than derived: the registry names the key "comma" while KeyboardEvent.key is ",". Deriving it is what produced the tooltip that promised a shortcut nobody had wired.
docs/architecture/desktop{,.zh-CN}.md records why the page owns these keys: the packaged Windows build has no menu accelerators, so Ctrl+N, Ctrl+K and Ctrl+J reach the renderer directly, and giving the menu accelerators as well would fire each of them twice.
eba5454 to
a765e2c
Compare
|
Rebased onto Two conflicts, both in
Worth stating because the plain-text resolution would have been wrong: dropping Ran: |
|
PASS a765e2c
Ran: |
Co-Authored-By: Claude Code <noreply@anthropic.com>
The assistant composer is focused when the app opens, and the hook treated any focused input or contenteditable as a reason to ignore Ctrl+N, Ctrl+K, Ctrl+, and Ctrl+J. Those combos all carry a modifier and have no typed meaning, so only an open dialog and IME composition keep their keys now. The browser test covers Ctrl+N and Ctrl+J from the focused composer, and shows that typed text still reaches the project search field. Co-Authored-By: Claude Code <noreply@anthropic.com>
The app-wide shortcut handler replaced the desktop sidebar's own keydown listener but routed Ctrl+K to the project picker everywhere, so the packaged app lost its sidebar search and the desktop smoke failed. Keep the picker in the browser and open the sidebar search when the desktop shell is present. Co-Authored-By: Claude Code <noreply@anthropic.com>
The browser lane now mounts the workspace with the desktop-shell globals and asserts the key opens the sidebar search instead of the project picker. At 839412f that assertion fails, which is the failure the packaged smoke reported on both desktop lanes. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
What
Shortcuts were declared five times: the workspace help dialog listed them by hand, tooltips hardcoded strings like
⌘ ⇧ G,aria-keyshortcutsrepeated them again, and four separatekeydownlisteners decided what the keys did. The copies had already drifted. The help dialog advertisedCtrl+,for model settings while the handler listened for a different key, so the shortcut did nothing while the tooltip promised it worked — reported as "it showsCtrl+,but the key does not fire".src/canvas/shortcuts.tsis now the single table: a combo, its macOS and Windows spellings, and theKeyboardEvent.keynames it matches. Tooltips, the help dialog,aria-keyshortcutsand the app-wide handler all derive from it. Onewindowlistener replaces the four; it ignores keys typed into a field or pressed while a dialog is open, soEscapeand text input behave as before.The
comma → ","mapping is explicit rather than derived. Deriving the key name from the combo name is what produced a tooltip promising a shortcut nobody had wired.docs/architecture/desktop{,.zh-CN}.mdnow records why the page owns these keys: the packaged Windows build has no menu accelerators, soCtrl+N,Ctrl+KandCtrl+Jreach the renderer directly, and adding menu accelerators (or an IPC forward) as well would fire each shortcut twice. That was measured on real Windows, not assumed — an earlier version of this branch did callsetApplicationMenuwith accelerators and double-triggered.Verification
tests/browser/shortcuts.mjs(new, gate lane, isolated fixture):Ctrl+K,Ctrl+,,Ctrl+N,Ctrl+J,Esc, and the negative cases — a key typed into the assistant search box, and a key pressed while a dialog is open. Also asserts the tooltip text, the help dialog row andaria-keyshortcutsagree with the key that actually fires.tests/shortcutHints.test.ts(new): every registered combo has both platform spellings, and every handler key maps to an entry in the table.tsc --noEmitclean,npm test981 pass / 0 fail,check:i18n3343 keys 0 problems,check:browser-manifest94 entries,check:browser-locale0 problems.apps/desktopis untouched: the probe showed the Electron build needs no menu handling, so none was added.