fix(terminal): inject Kitty CSI u sequences for Shift/Alt/Ctrl+Enter in xterm.js#1149
Open
fix(terminal): inject Kitty CSI u sequences for Shift/Alt/Ctrl+Enter in xterm.js#1149
Conversation
…in xterm.js xterm.js 6.0.0 does not support the Kitty keyboard protocol and encodes all Enter variants as bare \r. Use attachCustomKeyEventHandler to intercept modified Enter keys and manually write the correct CSI u escape sequences (Shift+Enter, Alt+Enter, Ctrl+Enter) in all three terminal instances (useXtermPty, MayorTerminalPane, AgentTerminalPane).
…I u logic The identical 16-line handler was copy-pasted across three terminal setup sites. Extract it into a shared function in useXtermPty.ts and call it from all three locations.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · 243,467 tokens |
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
xterm.js 6.0.0 does not support the Kitty keyboard protocol and encodes all Enter variants as bare
\r. This addsattachCustomKeyEventHandlerto all three xtermTerminalinstances (useXtermPty.ts,MayorTerminalPane, andAgentTerminalPaneinTerminalBar.tsx) to intercept modified Enter keys and inject the correct Kitty CSI u escape sequences:\x1b[13;2u\x1b[13;3u\x1b[13;5uPlain Enter is unaffected (falls through to xterm's default
\rhandling). Returningfalsefrom the handler prevents xterm's default processing after the sequence is manually written viaterm.input(). Thekeydownguard avoids double-firing onkeyup.Originally authored in https://github.com/jrf0110/kilocode-cloud/pull/16.
Verification
Visual Changes
N/A
Reviewer Notes
The handler is identical across all three terminal instances. A future improvement could extract it into a shared utility, but keeping it inline matches the existing pattern in the codebase where each terminal instance sets up its own addons independently.