Win32-input-mode leaks after exit on Windows/ConPTY, causing garbage input

Resolved 💬 2 comments Opened Mar 25, 2026 by ShlackBaum Closed Apr 23, 2026

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

  1. Run Claude Code in Zed's terminal on Windows (via ConPTY / node-pty)
  2. Work normally in a session
  3. Exit with Ctrl+C
  4. 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

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗