WebSocket reconnect corrupts readline input buffer in iTerm2

Resolved 💬 2 comments Opened Jun 7, 2026 by buck-openart Closed Jul 14, 2026

Description:

When Claude Code reconnects after a brief WebSocket drop, the TUI repaint sends ANSI escape sequences that corrupt the readline input buffer. This destroys in-progress input in two ways depending on timing:

  • If paused mid-type: garbage characters are appended to the input line (Ctrl+W can clear them)
  • If actively typing when the reconnect fires: the repaint truncates what was typed, with no way to recover the lost text

Steps to reproduce:

  1. Type a prompt but don't submit
  2. Wait for a WebSocket drop/reconnect (visible as a white flash in the upper-right corner of the terminal)
  3. Observe input line is corrupted — garbage characters appended or text truncated

Environment:

  • macOS 25.5.0
  • iTerm2 3.6.11

Expected: Reconnect restores terminal state cleanly without touching the input buffer

Actual: ANSI escape sequences from the TUI repaint leak into stdin, corrupting in-progress input

View original on GitHub ↗

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