Push Kitty keyboard enhancement flags to the host terminal #2

Open
opened 2026-09-19 19:31:48 +09:00 by natsukium · 0 comments
Owner

Problem

felis-tui reads host keys through crossterm but never pushes Kitty keyboard enhancement flags to the host terminal (no PushKeyboardEnhancementFlags anywhere in src/). The host therefore emits legacy xterm bytes, and crossterm's legacy decoding collapses Ctrl+I / Tab, Ctrl+M / Enter, Ctrl+H / Backspace, Shift on letters, and Alt+x / ESC x before keys.rs ever sees them. An application inside the felis session that has negotiated Kitty keyboard mode (the shadow's kitty_kbd_flags) then receives a lossy re-encoding, even when the host terminal is felis itself and supports the full protocol.

This is the fidelity gap felis#299 attributed to the crossterm seam; it exists independently of which decoder runs, and closes without any felis core change.

Proposal

  • On TermGuard::enter, query supports_keyboard_enhancement() and, when true, push DISAMBIGUATE_ESCAPE_CODES | REPORT_EVENT_TYPES | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES; pop on drop, alongside the raw-mode and alternate-screen restore.
  • keys.rs: stop treating every non-Release as a press once event types are reported (repeat stays a press; release now reaches key_encode, which already suppresses it unless the session asked for releases).
  • Prefix-key matching in config.rs must keep working with the enhanced key model (Shift now arrives as a modifier on the letter, not as an uppercase Char).

Not in scope

Replacing crossterm; see felis#299 for the rejected direction and its revisit conditions.

Refs

  • felis#299 (closed: not now)
  • src/main.rs TermGuard, src/keys.rs, src/config.rs
  • crossterm event::KeyboardEnhancementFlags, PushKeyboardEnhancementFlags, supports_keyboard_enhancement
## Problem felis-tui reads host keys through crossterm but never pushes Kitty keyboard enhancement flags to the host terminal (no `PushKeyboardEnhancementFlags` anywhere in `src/`). The host therefore emits legacy xterm bytes, and crossterm's legacy decoding collapses Ctrl+I / Tab, Ctrl+M / Enter, Ctrl+H / Backspace, Shift on letters, and Alt+x / ESC x before `keys.rs` ever sees them. An application inside the felis session that has negotiated Kitty keyboard mode (the shadow's `kitty_kbd_flags`) then receives a lossy re-encoding, even when the host terminal is felis itself and supports the full protocol. This is the fidelity gap felis#299 attributed to the crossterm seam; it exists independently of which decoder runs, and closes without any felis core change. ## Proposal - On `TermGuard::enter`, query `supports_keyboard_enhancement()` and, when true, push `DISAMBIGUATE_ESCAPE_CODES | REPORT_EVENT_TYPES | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES`; pop on drop, alongside the raw-mode and alternate-screen restore. - `keys.rs`: stop treating every non-Release as a press once event types are reported (repeat stays a press; release now reaches `key_encode`, which already suppresses it unless the session asked for releases). - Prefix-key matching in `config.rs` must keep working with the enhanced key model (Shift now arrives as a modifier on the letter, not as an uppercase `Char`). ## Not in scope Replacing crossterm; see felis#299 for the rejected direction and its revisit conditions. ## Refs - felis#299 (closed: not now) - `src/main.rs` `TermGuard`, `src/keys.rs`, `src/config.rs` - crossterm `event::KeyboardEnhancementFlags`, `PushKeyboardEnhancementFlags`, `supports_keyboard_enhancement`
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/felis-tui#2
No description provided.