Terminal left in CSI u keyboard mode after exiting session
Description
After exiting a Claude Code session, the terminal remains in CSI u (kitty keyboard protocol) mode. This causes raw escape sequences to be printed instead of normal key behavior.
For example, pressing Ctrl+C after exiting prints 9;5u in the terminal instead of sending the interrupt signal.
Steps to reproduce
- Open a terminal (zsh on macOS)
- Run
claude - Exit the session (e.g.,
/exitorCtrl+Cto quit) - Press
Ctrl+Cin the now-returned shell prompt - Observe
9;5uprinted to the terminal
Expected behavior
The terminal should be fully restored to its previous state on exit, with the CSI u / kitty keyboard protocol disabled.
Actual behavior
The terminal remains in CSI u mode. Keypresses are encoded as CSI u sequences (e.g., Ctrl+C → \e[9;5u) and since the shell doesn't understand this encoding, fragments like 9;5u are printed as literal text.
Workaround
Run reset or printf '\e[<u' after exiting to pop the keyboard protocol mode.
Environment
- Claude Code: 2.1.84
- Node.js: v24.14.0
- OS: macOS 14.3.1 (Build 23D60)
- Terminal: Ghostty 1.3.0-HEAD+bc9be90
- Shell: zsh
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗