Fix ⌘B: dispatch/listen event-name mismatch; thinking pill → "Thinking (⇧⇥)"
Root cause (interlude, owner 2026-09-25): keyboard-shortcuts dispatches
registry actions on the lh:kbd-<action> convention, but the sidebar's
listener sat on the pre-convention name "lh:toggle-sidebar" — a name
nothing ever dispatches, so ⌘B silently did nothing while its tooltip
and cheat-sheet row kept claiming the binding. A sweep of every lh:
listener confirmed the sidebar was the lone stray (chat-renamed and
graph-revision are deliberate non-kbd events).
Fix, structural: kbdEventForAction(action) exported from
src/core/keyboard.ts — the ONE spelling — and both sides compose
through it (dispatcher's default branch, sidebar's toggle listener);
keyboard-shortcuts re-exports the helper so the contract pin can assert
no second spelling exists. The mismatch is now impossible by
construction.
Thinking pill: label trimmed to "Thinking" with its real shortcut via
the registry-composition path — "Thinking (⇧⇥)" (cycle-thinking,
rebind-live like every Hint suffix).
Pins (tests/keyboard-toggle-sidebar.test.ts): the full chain — mod+b →
actionForBinding → toggle-sidebar → kbdEventForAction →
lh:kbd-toggle-sidebar; formatBinding("shift+tab") → ⇧⇥; the
dispatcher-imports-the-same-helper contract.
Live-verified on :3001: ⌘B visually toggles on home, /chat/[id], and
/chat/new (sidebar 0↔288px, hamburger slot 0↔36); with the rebind
lh:keymap {"toggle-sidebar":"mod+j"}: ⌘J toggles and ⌘B is inert
(rebind-live); thinking pill renders "Thinking (⇧⇥)"; keymap restored,
sidebar left open.
This commit is contained in:
@@ -163,6 +163,18 @@ export function eventBinding(e: KeyboardEvent): string {
|
||||
return [...mods, e.key.toLowerCase()].join("+");
|
||||
}
|
||||
|
||||
/** The window event name a registry action dispatches/answers on —
|
||||
* the ONE spelling shared by the dispatcher (keyboard-shortcuts) and
|
||||
* every surface listener. Born from the ⌘B bug (owner interlude
|
||||
* 2026-09-25): the sidebar listened on the pre-convention name
|
||||
* "lh:toggle-sidebar" while the dispatcher sent "lh:kbd-toggle-sidebar",
|
||||
* so ⌘B silently did nothing. With both sides composing through this
|
||||
* helper the mismatch is structurally impossible.
|
||||
*/
|
||||
export function kbdEventForAction(action: KeyAction): string {
|
||||
return `lh:kbd-${action}`;
|
||||
}
|
||||
|
||||
/** True when the event lands in a typing surface (input, textarea, or a
|
||||
* contentEditable). In one, only mod/alt combos (and Tab, which types
|
||||
* nothing) may fire — bare keys belong to the field (typing, caret). */
|
||||
|
||||
Reference in New Issue
Block a user