fix(cli): map NumLock/CapsLock modifier-bit variants under kitty protocol - #90291
Closed
grahfmusic wants to merge 1 commit into
Closed
fix(cli): map NumLock/CapsLock modifier-bit variants under kitty protocol#90291grahfmusic wants to merge 1 commit into
grahfmusic wants to merge 1 commit into
Conversation
…ocol With the kitty keyboard protocol push active (CSI >1u disambiguate), kitty encodes lock-key state into the CSI modifier field of function keys: a plain Down with NumLock on arrives as ESC[1;129B (NumLock), ESC[1;65B (CapsLock), or ESC[1;193B (both) instead of the legacy ESC[B. Stock prompt_toolkit maps none of these, so the parser fires Escape and inserts the remainder as literal text in the input line. 03bf85d restored the kitty push and completed the extended-key alias table but left these lock-bit variants unmapped, so kitty + NumLock still leaks [1;129A/B for arrow/nav keys. Map modifier 129/65/193 (plain) and 130/66/194 (+shift) for arrows, Home/End, Insert/Delete/PageUp/PageDown, and CSI-u Enter/Tab/Backspace/ Space to their plain keys.
kshitijk4poor
added a commit
to kshitijk4poor/hermes-agent
that referenced
this pull request
Aug 20, 2026
…s, and PUA functional keys Follow-up to the salvaged NousResearch#89676 + NousResearch#90291 lock-bit fixes: extract a shared _lock_variants() helper and cover the sites both PRs missed - install_shift_enter_alias / install_ctrl_enter_alias / install_cmd_backspace_alias CSI-u spellings, legacy CSI-letter and CSI-tilde navigation twins derived from the existing table for ALL modifiers 1-16 (not just plain/shift), plain F1-F4 SS3 fallback, unmodified CSI-u keys (Tab/Enter/Space/Backspace), and kitty PUA functional keys (keypad, F13-F24, Ignore range) under lock bits. 8 new tests.
kshitijk4poor
added a commit
that referenced
this pull request
Aug 20, 2026
…s, and PUA functional keys Follow-up to the salvaged #89676 + #90291 lock-bit fixes: extract a shared _lock_variants() helper and cover the sites both PRs missed - install_shift_enter_alias / install_ctrl_enter_alias / install_cmd_backspace_alias CSI-u spellings, legacy CSI-letter and CSI-tilde navigation twins derived from the existing table for ALL modifiers 1-16 (not just plain/shift), plain F1-F4 SS3 fallback, unmodified CSI-u keys (Tab/Enter/Space/Backspace), and kitty PUA functional keys (keypad, F13-F24, Ignore range) under lock bits. 8 new tests.
12 tasks
Collaborator
|
Merged via #90561 with your commit cherry-picked onto current main — your authorship is preserved in the git history ( Thanks for catching the slice nobody else did! |
This was referenced Aug 20, 2026
lisajlau
pushed a commit
to lisajlau/hermes-agent
that referenced
this pull request
Aug 20, 2026
…s, and PUA functional keys Follow-up to the salvaged NousResearch#89676 + NousResearch#90291 lock-bit fixes: extract a shared _lock_variants() helper and cover the sites both PRs missed - install_shift_enter_alias / install_ctrl_enter_alias / install_cmd_backspace_alias CSI-u spellings, legacy CSI-letter and CSI-tilde navigation twins derived from the existing table for ALL modifiers 1-16 (not just plain/shift), plain F1-F4 SS3 fallback, unmodified CSI-u keys (Tab/Enter/Space/Backspace), and kitty PUA functional keys (keypad, F13-F24, Ignore range) under lock bits. 8 new tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the kitty keyboard protocol push active (
CSI >1udisambiguate, restored in #87511 / 03bf85d), kitty encodes lock-key state into the CSI modifier field of function keys. A plain Down with NumLock on arrives as:ESC[1;129B— NumLock (bit 128)ESC[1;65B— CapsLock (bit 64)ESC[1;193B— both…instead of the legacy
ESC[B. Stock prompt_toolkit maps none of these, so the VT100 parser firesEscapeand inserts the remainder ([1;129B) as literal text in the input line. Letters are unaffected (kitty sends those as plain text), which is why only arrow/nav keys break — and why it looks like "escape codes" appear when pressing Up/Down.Root cause
03bf85d ("restore Kitty keyboard protocol push and complete the extended-key alias table") restored the disambiguate push and mapped the modifier families 2/3/4/5/6/7/8, but left the lock-bit modifiers (129/65/193) unmapped. Those are exactly what the disambiguate flag makes kitty emit for a plain keypress whenever NumLock/CapsLock is engaged — the most common desktop state.
Fix
Extend
install_modify_other_keys_aliases()with the lock-bit modifier family:Covered keys: arrows, Home/End, Insert/Delete/PageUp/PageDown, and the CSI-u forms of Enter/Tab/Backspace/Space (which under disambiguate also carry the lock bit).
Verification
\x1b[1;129B→Keys.Down,\x1b[1;129A→Keys.Up,\x1b[1;65B/\x1b[1;193B→Keys.Down,\x1b[1;130B→Keys.ShiftDown, etc. — 893 aliases install cleanly.encode_key_for_tty: plain Down with Hermes' pushed flags →ESC[B; same key with NumLock →ESC[1;129B.Refs #87511, #86866.