[Bug] Terminal state not restored on exit, causing broken keyboard input
Status Fixed / completed
Reported on v2.1.84
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 5 comments · opened Mar 26, 2026 · closed Apr 7, 2026
Bug Description
Claude is not restoring terminal state on exit. When I press ctrl-modified keys I just get something like 4;5u on the terminal. Claude suggested workaround to printf '\e[>0u', which worked.
Environment Info
- Platform: darwin
- Terminal: WezTerm
- Version: 2.1.84
- Feedback ID: b4e01cc0-228c-4f57-b611-38515a9881f2
Errors
[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/dimfeld/.local/share/claude/versions/2.1.84 (expected in multi-process scenarios)\n at Jm_ (/$bunfs/root/src/entrypoints/cli.js:2740:2168)\n at tlT (/$bunfs/root/src/entrypoints/cli.js:2740:1326)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-26T02:02:22.334Z"}]
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Same issue on Ghostty. This workaround in
~/.zshrcfixes it:Resets the kitty keyboard protocol before each prompt. No-op when already in normal mode.
Same issue on Alacritty
This happens when Claude Code exits without resetting the Kitty keyboard protocol, leaving your terminal in a state where key sequences like
4;5uappear instead of Ctrl+key bindings.Fix with a PostStop hook (automatic reset on every exit):
This sends the Kitty protocol disable sequence (
CSI < u) every time Claude Code exits, whether cleanly or not.For immediate recovery (if your terminal is already broken):
Shell-level fix (belt-and-suspenders):
For zsh (
~/.zshrc):For bash (
~/.bashrc):This resets the protocol before every prompt, so even if Claude Code crashes, your next prompt will be clean.
Affected terminals: WezTerm, Ghostty, Alacritty, Kitty — any terminal that supports the Kitty keyboard protocol. iTerm2 and macOS Terminal are unaffected since they don't implement it.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.