claude-code
claude-code copied to clipboard
[BUG] ESC Key Causes Complete Terminal Freeze in Claude Code
Summary
Pressing the ESC key during any Claude Code session causes the entire terminal to become unresponsive, requiring forced termination and resulting in complete loss of work.
Severity: CRITICAL 🔴
Environment Details (from /doctor diagnostic)
- Claude CLI Version: 1.0.63 (npm-local)
- Node.js: v22.17.1
-
Path:
/home/user/.nvm/versions/node/v22.17.1/bin/node -
Installation:
/home/user/.claude/local/node_modules/.bin/claude - Config Method: local
- Auto-updates: enabled
- Platform: Linux WSL2 (6.6.87.2-microsoft-standard-WSL2)
- Terminal: xterm-256color
- System: Intel Core i9-14900K, 63.8GB RAM
Steps to Reproduce
- Start Claude Code:
claude - Begin any normal workflow (editing files, running commands)
- Press ESC key at any point
- Terminal immediately becomes frozen:
- No keyboard input accepted
- No cursor movement
- No response to Ctrl+C, Ctrl+D, Ctrl+Z
- Only solution: Force close terminal window
Expected Behavior
- ESC should exit current mode gracefully OR
- ESC should be ignored if not in a specific mode OR
- Provide option to remap/disable ESC key
Actual Behavior
- Complete terminal freeze
- Loss of all unsaved work
- No recovery possible
Impact
- Data Loss: All session progress lost
- Productivity: Complete restart required
- User Trust: Critical usability issue
Diagnostic Findings
- No Debug Logging: Claude Code has no built-in logging mechanism
-
No Crash Logs: No error logs generated in:
-
~/.claude/ - System logs (journalctl)
- WSL logs
-
- Process State: Multiple Claude processes remain running but unresponsive
- Terminal Mode: Likely issue with terminal raw mode handling
Attempted Workarounds (All Failed)
- Setting
CLAUDE_DEBUG=1 - Setting
CLAUDE_LOG_LEVEL=debug - Looking for verbose/debug flags
- Checking for log files
Root Cause Analysis
Likely terminal mode handling issue where:
- Claude enters raw/alternative terminal mode
- ESC key triggers undefined state transition
- Terminal mode not properly restored
- Input handling loop becomes stuck
Recommendations
- Immediate: Add ESC key handling to prevent freeze
- Short-term: Implement debug logging for terminal issues
- Long-term: Add configurable key bindings
- Critical: Add graceful recovery mechanism
Additional Context
- Issue persists across multiple sessions
- Affects WSL2 environment specifically
- No workaround currently exists
- Forces users to avoid ESC key entirely
Priority: P0 - CRITICAL
This is a data loss bug that makes Claude Code unusable for users who habitually use ESC key (vim users, terminal power users).