[PR #12573] fix(keybind): handle sticky leader modifiers #14277

Open
opened 2026-02-16 18:19:05 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12573

State: open
Merged: No


What

  • Improve keybind decoding for terminals that send Ctrl+letter as ASCII control codes.
  • Make leader-chord matching resilient when users keep holding the leader modifier ("sticky" Ctrl/Meta/etc).

Why

Some terminals emit Ctrl combinations as control bytes (e.g. \x07), and users often keep Ctrl held after pressing a leader chord (e.g. ctrl+x then g). This combination can cause the second key to be missed even though the chord intent is clear.

How

  • Normalize ASCII control codes in Keybind.fromParsedKey() (1..26 => ctrl+a..z, 0x1F => ctrl+_), while intentionally skipping ambiguous codes (tab/enter/backspace/etc).
  • When a leader is active, attempt exact match first; if that fails, retry after stripping the captured leader modifiers from the incoming key event.

Tests

  • cd packages/opencode && bun test test/keybind.test.ts
  • cd packages/opencode && bun run typecheck

Fixes anomalyco/opencode#10444

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12573 **State:** open **Merged:** No --- ## What - Improve keybind decoding for terminals that send Ctrl+letter as ASCII control codes. - Make leader-chord matching resilient when users keep holding the leader modifier ("sticky" Ctrl/Meta/etc). ## Why Some terminals emit Ctrl combinations as control bytes (e.g. `\x07`), and users often keep Ctrl held after pressing a leader chord (e.g. `ctrl+x` then `g`). This combination can cause the second key to be missed even though the chord intent is clear. ## How - Normalize ASCII control codes in `Keybind.fromParsedKey()` (1..26 => `ctrl+a..z`, `0x1F` => `ctrl+_`), while intentionally skipping ambiguous codes (tab/enter/backspace/etc). - When a leader is active, attempt exact match first; if that fails, retry after stripping the captured leader modifiers from the incoming key event. ## Tests - `cd packages/opencode && bun test test/keybind.test.ts` - `cd packages/opencode && bun run typecheck` Fixes anomalyco/opencode#10444
yindo added the pull-request label 2026-02-16 18:19:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14277