Win32-input-mode leaks after exit on Windows/ConPTY, causing garbage input
Description
After exiting Claude Code in a ConPTY-based terminal (Zed on Windows with MINGW64/bash), win32-input-mode (\e[?9001h) remains enabled in the terminal. Subsequent keystrokes appear as raw CSI sequences appended to shell input.
Steps to reproduce
- Run Claude Code in Zed's terminal on Windows (via ConPTY / node-pty)
- Work normally in a session
- Exit with Ctrl+C
- Press Up arrow to recall the previous command from history
Expected behavior
Shell shows the previous command from history (e.g. go).
Actual behavior
Shell shows the command with garbage appended:
$ go;28;13;1;0;1_;28;13;0;0;1_
The ;28;13;1;0;1_ sequences are win32-input-mode CSI sequences (terminated with _), which ConPTY generates when \e[?9001h is active. Zed's terminal may also freeze/hang when trying to process this.
Root cause
Claude Code (or the underlying ConPTY) enables win32-input-mode (\e[?9001h) during the session but does not send \e[?9001l to disable it on exit. The mode persists in the parent terminal emulator after Claude's process exits.
Workaround
Send terminal reset sequences on exit, specifically:
\e[?9001l — disable win32-input-mode
\e[?2004l — disable bracketed paste
\e[?1000l — disable mouse tracking
Environment
- OS: Windows 11 Pro
- Terminal: Zed editor terminal (ConPTY)
- Shell: bash (MINGW64 / Git for Windows)
- Claude Code version: latest CLI
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗