fix(rtk): use matchesKey for tab navigation in zellij settings modal#18
Open
EstebanForge wants to merge 1 commit into
Open
fix(rtk): use matchesKey for tab navigation in zellij settings modal#18EstebanForge wants to merge 1 commit into
EstebanForge wants to merge 1 commit into
Conversation
Tab switching compared raw input bytes against \x1b[D and \x1b[C. When pi-tui enables the kitty keyboard protocol (flags 1, 2, 4), bare arrows arrive re-encoded as \x1b[1;1D and \x1b[1;1C, so the strict compare never matched. Tabs were unswitchable in Ghostty, kitty, and WezTerm under pi-tui 0.80.x. I replaced the byte compares with matchesKey(data, "left") and matchesKey(data, "right"). matchesKey normalizes legacy, kitty, and modifyOtherKeys encodings, so bare arrows keep working and the kitty-encoded forms now switch tabs too. I added regression tests that drive handleInput with legacy and kitty-encoded arrow sequences and assert the active tab through the rendered tab bar, plus a guard that modified arrows (Ctrl, Alt) fall through to the settings list instead of switching tabs.
|
This fix works on my machine running ghostty 1.3.1 and cosmic-term 0.1.0 |
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.
What
Fixes tab navigation in the RTK Optimizer config modal under kitty-keyboard-protocol terminals. Left/right arrows now switch tabs again in Ghostty, kitty, and WezTerm when running against pi-tui 0.80.x.
Why
ZellijSettingsModal.handleInputswitched tabs with a strict byte compare against\x1b[Dand\x1b[C. pi-tui 0.80.x enables the kitty keyboard protocol with flags 1, 2, and 4 (disambiguate, report event types, report alternate keys). Under that protocol, bare arrow keys arrive re-encoded as\x1b[1;1Dand\x1b[1;1C. The strict compare never matched, so the modal tabs were unreachable on any kitty-protocol terminal.This is not keyboard-layout specific. It reproduces on any layout the moment the terminal speaks kitty protocol. I verified it on a Spanish LA layout in Ghostty; a US-layout Ghostty user hits the same wall.
How
I replaced the byte compares with
matchesKey(data, "left")andmatchesKey(data, "right")from@earendil-works/pi-tui.matchesKeynormalizes legacy (\x1b[D,\x1bOD), kitty disambiguated (\x1b[1;1D), and xterm modifyOtherKeys encodings, so bare arrows keep working and the kitty-encoded forms now switch tabs. Modified arrows (Shift, Ctrl, Alt) do not match and fall through to the settings list, same as before.Testing
npm testpasses (all 7 test files, exit 0).src/config-modal.test.ts:\x1b[D,\x1b[C) switch tabs, with wrap-around in both directions.\x1b[1;1D,\x1b[1;1C) switch tabs. This is the exact regression.Ctrl+Right,Alt+Left) do not switch tabs and forward to the active settings list.