Repository navigation
[feat] canvas: keep one shortcut list for hints, help and keys - #501
Zhangbo-cn wants to merge 1 commit 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: |
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.