hermes-agent/apps/desktop/src/app/chat/composer
kshitijk4poor 49f1b9e4b4 fix(desktop): stop Esc reopening the slash/@ menu; harden keyup guard
Follow-up to #37937. That fix guarded the composer's keyup with
`shouldSkipTriggerRefreshOnKeyUp(key, trigger !== null)`. The `trigger !== null`
check is timing-fragile for Escape: Escape's *keydown* sets `trigger = null`
and closes the menu, but in a real browser the *keyup* fires after a re-render,
so the handler closure sees `trigger === null`, the guard returns false,
`refreshTrigger` runs, re-detects the still-present `/` in the input, and
instantly reopens the menu. (jsdom batches state synchronously so a unit test
could not observe this -- only the running app does.)

Replace the value-based guard with a `triggerKeyConsumedRef` set synchronously
in keydown whenever the open popover consumes a nav/control key
(Arrow/Enter/Tab/Escape). keyup consults and clears that ref, so it is immune
to the keydown->re-render->keyup timing. Applied to both the main composer
(chat/composer/index.tsx) and the message-edit composer
(assistant-ui/thread.tsx).

Removes the now-unused `shouldSkipTriggerRefreshOnKeyUp` helper and its unit
test. The real-DOM regression test now fires keydown+keyup pairs through the
ref-based handlers and asserts Esc closes and stays closed.

Verified by running a production renderer build (Vite v8) under Electron
against a local backend: ArrowDown/ArrowUp cycle the full list and Esc
dismisses the menu without reopening.
2026-06-03 13:15:08 +05:30
..
hooks Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
attachments.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
completion-drawer.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
context-menu.tsx fix(desktop): triage batch of GUI quality-of-life fixes (#37536) 2026-06-02 16:33:22 -04:00
controls.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
drop-affordance.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
focus.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
help-hint.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
index.tsx fix(desktop): stop Esc reopening the slash/@ menu; harden keyup guard 2026-06-03 13:15:08 +05:30
inline-refs.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
queue-panel.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
rich-editor.test.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
rich-editor.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
skin-slash-popover.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
slash-nav-dom-repro.test.tsx fix(desktop): stop Esc reopening the slash/@ menu; harden keyup guard 2026-06-03 13:15:08 +05:30
text-utils.test.ts fix(desktop): stop Esc reopening the slash/@ menu; harden keyup guard 2026-06-03 13:15:08 +05:30
text-utils.ts fix(desktop): stop Esc reopening the slash/@ menu; harden keyup guard 2026-06-03 13:15:08 +05:30
trigger-popover.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
types.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
url-dialog.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
voice-activity.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00