Terminal left in Kitty keyboard protocol mode after exit, leaked escape sequence notification
Resolved 💬 3 comments Opened Mar 28, 2026 by CodeReclaimers Closed Apr 1, 2026
Bug description
When Claude Code exits (normal exit, not just crashes), two related terminal issues occur in Kitty terminal:
- Leaked escape sequence as desktop notification: Kitty displays a notification containing
4;0;— a fragment of what appears to be an OSC or Kitty keyboard protocol escape sequence that wasn't properly consumed during terminal cleanup.
- Terminal left in Kitty keyboard protocol mode: After exiting Claude Code, keystrokes in the shell produce numeric CSI escape codes instead of normal characters. This suggests the Kitty progressive keyboard enhancement mode (enabled via
\e[>Xu) is not being properly popped (\e[<u) on exit.
Resetting the terminal with reset or opening a new tab fixes the issue, but it's a recurring annoyance.
Environment
- Terminal: Kitty
- OS: Linux (Ubuntu)
- Shell: bash
Expected behavior
On exit, Claude Code should reliably restore the terminal to its prior state by popping all keyboard protocol flags and completing all escape sequences cleanly.
Screenshots
The screenshot shows a Kitty desktop notification popup with the text 4;0; appearing immediately after Claude Code exits.
<img width="704" height="145" alt="Image" src="https://github.com/user-attachments/assets/463f7934-c348-4603-a253-2734873e0a9e" />
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗