mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-19 10:02:16 +00:00
fix(tui): require explicit alt bit for escape-based alt chords
Hermes-ink reports bare Escape as meta=true+escape=true on some terminals, so a configured alt+escape binding was firing on bare Esc. Require an explicit key.alt bit when the configured named key is escape so plain Esc stays plain Esc; kitty-style alt+escape still fires.
This commit is contained in:
parent
ad579015b2
commit
ff4e478fcc
2 changed files with 16 additions and 1 deletions
|
|
@ -270,6 +270,16 @@ describe('parseVoiceRecordKey (#18994)', () => {
|
|||
expect(isVoiceToggleKey({ ctrl: false, meta: false, super: true }, 'b', superB)).toBe(true)
|
||||
})
|
||||
|
||||
it('alt+escape does not fire on bare Esc meta-shape', async () => {
|
||||
const { isVoiceToggleKey, parseVoiceRecordKey } = await importPlatform('darwin')
|
||||
const altEscape = parseVoiceRecordKey('alt+escape')
|
||||
|
||||
// Some terminals surface bare Esc as meta=true + escape=true.
|
||||
expect(isVoiceToggleKey({ ctrl: false, escape: true, meta: true, super: false }, '', altEscape)).toBe(false)
|
||||
// Explicit alt bit (kitty-style) still fires the configured chord.
|
||||
expect(isVoiceToggleKey({ alt: true, ctrl: false, escape: true, meta: false, super: false }, '', altEscape)).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects matches when Shift is held (different chord than configured)', async () => {
|
||||
const { isVoiceToggleKey, parseVoiceRecordKey } = await importPlatform('linux')
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,12 @@ export const isVoiceToggleKey = (
|
|||
// protocols. Guard against ctrl/super bits so a chord like
|
||||
// Ctrl+Alt+<key> or Cmd+Alt+<key> doesn't spuriously fire the
|
||||
// alt binding.
|
||||
return (key.alt === true || key.meta) && !key.ctrl && key.super !== true
|
||||
//
|
||||
// Bare Escape on hermes-ink can arrive as ``key.meta=true`` on some
|
||||
// terminals, so a configured ``alt+escape`` must not match that shape;
|
||||
// require an explicit alt bit for escape chords (Copilot round-7
|
||||
// follow-up on #19835).
|
||||
return (key.alt === true || (key.meta && key.escape !== true)) && !key.ctrl && key.super !== true
|
||||
case 'ctrl':
|
||||
// Require the Ctrl bit AND a clear Alt/Super so a chord like
|
||||
// Ctrl+Alt+<key> / Ctrl+Cmd+<key> doesn't spuriously match
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue