feat(boxen): C M5 #813 -- input_decoder Kitty keyboard protocol enable + CSI-u decode#820
Merged
Conversation
…e + CSI-u decode Implements milestone M5 of the Phase C input decoder per planning/phase_c/INPUT_DECODER_PLAN.md section 7. - input_decoder_kitty_enable writes "\x1b[=1u" (progressive enhancement: disambiguate escape codes) to tty_fd when tty_fd >= 0; idempotent so duplicate enables do not pile up writes. Test-seam path (tty_fd == -1) still records the bit only. - decode_csi gains a 'u' case that decodes the two-part CSI-u form (\e[KEYCODE u and \e[KEYCODE;MODIFIER u) to boxen_event_t. Functional keycodes (9 Tab, 13 Enter, 27 Escape, 127 Backspace) route to the matching BOXEN_KEY_*; printable keycodes pass through as ev.key.ch with C0/C1/surrogate/out-of-range rejection so the CSI-u surface doesn't smuggle control bytes that the standard CSI path already filters. - Six new behavioral tests (un-skips the M5 SKIP stubs and adds a burst round-trip): A, A+Alt, Enter+Ctrl, Escape+Alt, lowercase a, and a three-event inject combining bare + modified forms. Probe-and-read for the terminal's kitty acknowledgement is deferred to M6 where the read(2) loop lives; terminals that do not support kitty silently ignore the enable and the decoder operates as if kitty_enable had never been called -- standard CSI parsing from M2 still handles their input. Unit tests: 955/955 (was 953 pre-M5 -- the six new tests plus a +1 from un-skipping the stubs net the difference). Plan reference: section 3.9 (protocol), section 4.3 (state machine extension), section 7 (M5 scope), section 6.2 (M5 coverage row). Closes #813
…erage Addresses P2 polish items from the /gate review of PR #820: - Six negative-path tests assert BOXEN_ERR_TIMEOUT + a +1 bump on the parse_errors counter for each CSI-u rejection branch: \e[u -- no keycode \e[0u -- zero keycode (printable-range underflow) \e[7u -- C0 control 0x07 (BEL) outside the functional table \e[55296u -- surrogate codepoint U+D800 \e[128u -- C1 control U+0080 - Boundary-pin: \e[160u (U+00A0 NBSP) must accept, paired with the \e[128u rejection to fence both sides of the C1 control range so a regression that moved the fence by one would fail at least one test. - Functional-key modifier coverage: \e[9;3u (Tab+Alt) and \e[127;2u (Backspace+Shift); previously only Enter+Ctrl and Escape+Alt were tested. - Idempotency contract: test_kitty_enable_idempotent calls input_decoder_kitty_enable twice and asserts the bit stays set without observable side effect; the test-seam path (tty_fd == -1) suppresses the would-be duplicate write so we pin the in-memory invariant. Unit tests: 964/964 (was 955 after the M5 implementation commit; +9 net new tests). Integration: 21-failure baseline unchanged; failures unrelated to input_decoder. Plan reference: section 6.5 (TDD discipline -- behavioral asserts for every protocol entry in scope).
Owner
Author
Gate Review: phase-c-m5-kitty-protocol (PR #820)Verdict: PASS WITH NOTES (addressed in gate-fix commit)Tests
Reviewers
P0 -- BlockingNone. P1 -- ImportantNone. P2 -- Polish (addressed in this PR)
Bar-raiser observations (no action required)
Security observations (no action required)
Concurrency observations (no action required)
Stats
|
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.
Summary
Implements milestone M5 of the Phase C input decoder per
planning/phase_c/INPUT_DECODER_PLAN.mdsection 7. M5 adds Kittykeyboard protocol support for terminals that advertise it; terminals
that do not (Terminal.app, iTerm2) silently ignore the enable and the
M2 CSI parser continues to handle their input.
input_decoder_kitty_enable()writes\x1b[=1u(progressiveenhancement: disambiguate escape codes) to
tty_fdwhentty_fd >= 0.Idempotent so duplicate enables do not pile up writes. Test-seam path
(
tty_fd == -1) still records the bit only.decode_csi()gains acase 'u':that decodes the two-part CSI-uform (
\e[KEYCODE uand\e[KEYCODE;MODIFIER u) toboxen_event_t.Functional keycodes (9 Tab, 13 Enter, 27 Escape, 127 Backspace) route
to the matching
BOXEN_KEY_*; printable keycodes pass through asev.key.chwith C0/C1/surrogate/out-of-range rejection so the CSI-usurface does not smuggle control bytes that the standard CSI path
already filters.
burst round-trip): A, A+Alt, Enter+Ctrl, Escape+Alt, lowercase a,
and a three-event inject combining bare + modified forms.
Probe-and-read for the terminal's kitty acknowledgement is deferred
to M6 where the real
read(2)loop lives. M5 ships only the decoder'sability to handle CSI-u when it arrives, per the milestone scope in
plan section 7.
Out of Scope (Deferred)
tb2_poll_eventwithinput_decoder_polland runs the kitty probe-and-read.
/mousetoggle slash command.KEYCODE;MOD;EVENT u) -- post-launch.Kitty terminals already emit these via standard CSI in the
no-progressive-enhancement mode; M5 supports the subset needed
for the M5 acceptance tests.
Test Plan
+1 net from the burst round-trip test)
input_decoder_tests: 129/129 passing, 0 SKIP stubs remaining/gatereviewPlan reference: section 3.9 (protocol), section 4.3 (state machine
extension), section 7 (M5 scope), section 6.2 (M5 coverage row).
Closes #813