fix(ui): recognize encoded arrows so C-a Up/Down/Left/Right works again#56
Merged
Conversation
v0.5.16 began mirroring the focused app's keyboard protocols onto the real terminal. When the app reports event types (kitty flag 2, set by Claude Code and most modern TUIs), the terminal then encodes even an unmodified arrow press as the functional form ESC [ 1;1:1 A rather than the legacy ESC [ A. The UI input parser only recognized the bare form, so after the C-a prefix the encoded arrow was flushed to the session instead of driving sidebar browse (C-a Up/Down) or resize (C-a Left/Right). The parser now accepts the functional cursor-key grammar (ESC [ 1 ; mods [: event] A/B/C/D). An unmodified press or repeat becomes an arrow event (browse/resize); a modified arrow (Ctrl+Left word motion) or a release event is the application's input and is forwarded verbatim. Arrow events now carry their original bytes, so arrows forwarded to the focused app keep the exact encoding the terminal produced instead of a downgraded legacy arrow. Tests: 3 parser unit tests (functional press/repeat navigate, original-byte forwarding, modified/release passthrough) and a PTY integration test driving C-a + report-events Down to browse without leaking into the session.
Merged
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
After v0.5.16, pressing C-a then an arrow key no longer browses the sidebar (C-a Up/Down) or resizes it (C-a Left/Right) when a kitty-protocol app is focused.
Root cause
v0.5.16 mirrors the focused app's keyboard protocols onto the real terminal. When the app enables report event types (kitty flag 2, which Claude Code and most modern TUIs set), the terminal then encodes even an unmodified arrow press in the functional form
ESC [ 1;1:1 Ainstead of the legacyESC [ A(confirmed against ghostty's ownencodeSpecial: any sequence with an event type emits\x1b[1;{mods}:{event}{ABCD}).The UI input parser only recognized the bare
ESC [ Aform, so after the C-a prefix the encoded arrow diverged from the hold grammar and was flushed to the session — no browse/resize. Before v0.5.16 the terminal stayed in legacy mode, so arrows wereESC [ Aand it worked.Fix
ESC [ 1 ; mods [: event] A/B/C/D(its hold grammar acceptsA–Dafter a digit body).Testing
C-a+ report-eventsDownarms sidebar browse without leaking into the session.zig build test-all(116 unit + 67 integration) passes, integration re-run 3x for flakes;zig fmt --checkclean.Notes
ESC O A, application-cursor-keys mode) are intentionally not handled:boo uinever puts the real terminal into DECCKM, so that encoding cannot occur there.boo atforwards arrows to the app verbatim and is unaffected.This PR was generated by Coder Agents on behalf of @kylecarbs.