szn

Bug 489 — kitty CSI u parser drops the event-type field

489. Releases misread as presses; :-form releases rejected outright

Severity: MEDIUM (input correctness, only when outer terminal sends kitty sequences) Status: ✅ FIXED Files: src/key.zig:143-180

Problem

The 'u' branch documents the kitty variants:

//   events:        CSI [>] code;modifiers;event u  (event=1 press, 2 repeat, 3 release)

but only reads two fields:

const codepoint_str = it.first();
const k_mod: Modifier = if (it.next()) |mod_str| ... // modifiers
// third field (event type) never read

Consequences when an outer terminal sends event types (kitty progressive-enhancement flags negotiated, or terminals configured to always disambiguate):

Note the client never requests kitty flags from the outer terminal, so this only bites when the outer terminal emits these sequences uninvited — but the parser explicitly claims to handle the events variant, so the gap is real.

Proposed Fix

Read the third field; drop event type 3 (release), pass through 1 (press), and make an explicit decision on 2 (repeat — likely pass through, matching xterm autorepeat behavior). Handle both ; and : separators per the kitty spec. Regression tests: CSI 97;1:3u must not produce a press.

Resolution

In src/key.zig, the Kitty CSI u parser parses event types from both :-delimited modifier subparameters (modifiers:event-type) and third ;-delimited fields (code;modifiers;event). Release events (event_type == 3) return error.IgnoredEvent (which tty_key.zig cleanly drops as non-events), repeat events (event_type == 2) pass through as presses, and colon-delimited alternate keycodes (code:alternate) are supported by taking the base codepoint.

Tests: parse kitty event types and colon sub-parameters — bug #489 validates that presses pass through, repeats pass through, and releases (1:3u and 1;3u) return error.IgnoredEvent.