Skip to content

The agent that grows with you

fix(cli): stop pushing Kitty keyboard protocol that breaks Ctrl+C

kshitij165c889e5b42
diff --git a/cli.py b/cli.py
index 95bfcca6156..1d09a4742a7 100644
--- a/cli.py
+++ b/cli.py
@@ -3885,7 +3885,7 @@ _TERMINAL_INPUT_MODE_RESET_SEQ = (
"\x1b[0m" # reset text attributes
"\x1b[?25h" # ensure cursor visible
)
-_EXTENDED_ENTER_KEYS_SEQ = "\x1b[>1u\x1b[>4;2m"
+_EXTENDED_ENTER_KEYS_SEQ = "\x1b[>4;2m"
_BACKSLASH_LINE_CONTINUATION_RE = re.compile(r"\\[ \t]*$")
@@ -3920,10 +3920,14 @@ def _terminal_supports_extended_enter_keys(env: Optional[Mapping[str, str]] = No
def _enable_extended_enter_keys(output=None, env: Optional[Mapping[str, str]] = None) -> bool:
"""Ask allowlisted terminals to report Shift+Enter distinctly.
- Writes both the Kitty keyboard protocol push (CSI >1u) and xterm
- modifyOtherKeys level 2 (CSI >4;2m), mirroring the Ink TUI. The exit reset
- sequence already pops/resets both modes, so this is safe across normal
- exits, Ctrl+C, and SIGTERM cleanup.
+ Writes xterm modifyOtherKeys level 2 (CSI >4;2m), mirroring the Ink TUI.
+ We do NOT push the Kitty keyboard protocol (CSI >1u) here because
+ prompt_toolkit 3.x cannot parse Kitty CSI-u sequences for control
+ characters — Ctrl+C arrives as ``\\x1b[99;5u`` instead of ``\\x03``,
+ which neither prompt_toolkit's key bindings nor the kernel's INTR
+ mechanism can match, leaving Ctrl+C completely dead (#56684).
+ The exit reset sequence already pops/resets both modes, so this is
+ safe across normal exits, Ctrl+C, and SIGTERM cleanup.
"""
if not _terminal_supports_extended_enter_keys(env):
return False