Skip to content

Add kitty keyboard protocol support to Unix _pyrepl#145759

Open
jechol wants to merge 1 commit intopython:mainfrom
jechol:pyrepl-kitty-keyboard
Open

Add kitty keyboard protocol support to Unix _pyrepl#145759
jechol wants to merge 1 commit intopython:mainfrom
jechol:pyrepl-kitty-keyboard

Conversation

@jechol
Copy link

@jechol jechol commented Mar 10, 2026

Summary

VS Code 1.109 rolled out kitty keyboard protocol support in the integrated terminal via terminal.integrated.enableKittyKeyboardProtocol. Once enabled, the program running in the terminal needs to request and understand the protocol itself. _pyrepl currently does not, which breaks the Unix/macOS Python REPL when keys start arriving as kitty keyboard sequences instead of legacy terminal input.

This PR fixes that by teaching Unix _pyrepl to participate in the protocol and translate kitty key reports back into the existing _pyrepl event model.

  • enable kitty keyboard protocol when Unix _pyrepl prepares the terminal and restore the previous keyboard mode on exit
  • parse kitty CSI u, CSI ~, and CSI 1;... key reports in unix_eventqueue and translate them into existing _pyrepl key events
  • add regression tests for kitty key parsing and update REPL output sanitizing for the new terminal control sequences

Tests

  • ./python.exe -m test -j1 test_pyrepl.test_eventqueue test_pyrepl.test_unix_console
  • ./python.exe -m test -j1 test_pyrepl.test_pyrepl

@bedevere-app
Copy link

bedevere-app bot commented Mar 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link

python-cla-bot bot commented Mar 10, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant