Skip to content

fix(terminal): inject Kitty CSI u sequences for Shift/Alt/Ctrl+Enter in xterm.js#1149

Open
jrf0110 wants to merge 2 commits intomainfrom
fix/terminal-kitty-csi-sequences
Open

fix(terminal): inject Kitty CSI u sequences for Shift/Alt/Ctrl+Enter in xterm.js#1149
jrf0110 wants to merge 2 commits intomainfrom
fix/terminal-kitty-csi-sequences

Conversation

@jrf0110
Copy link
Contributor

@jrf0110 jrf0110 commented Mar 16, 2026

Summary

xterm.js 6.0.0 does not support the Kitty keyboard protocol and encodes all Enter variants as bare \r. This adds attachCustomKeyEventHandler to all three xterm Terminal instances (useXtermPty.ts, MayorTerminalPane, and AgentTerminalPane in TerminalBar.tsx) to intercept modified Enter keys and inject the correct Kitty CSI u escape sequences:

  • Shift+Enter → \x1b[13;2u
  • Alt+Enter → \x1b[13;3u
  • Ctrl+Enter → \x1b[13;5u

Plain Enter is unaffected (falls through to xterm's default \r handling). Returning false from the handler prevents xterm's default processing after the sequence is manually written via term.input(). The keydown guard avoids double-firing on keyup.

Originally authored in https://github.com/jrf0110/kilocode-cloud/pull/16.

Verification

  • Prettier formatting passes on both changed files
  • Escape sequences verified against Kitty keyboard protocol spec
  • All three terminal instances receive identical handlers

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.

jrf0110 added 2 commits March 16, 2026 16:37
…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.
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 17, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • src/components/gastown/TerminalBar.tsx
  • src/components/gastown/useXtermPty.ts

Reviewed by gpt-5.4-20260305 · 243,467 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant