[BUG] Terminal focus events (^[[I) display as raw text on Windows
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code starts in Windows Terminal, the ANSI escape sequence ^[[I (focus gained event) is displayed as raw text in front of the header instead of being consumed.
What appears:
^[[I
▐▛███▜▌ Claude Code v2.1.7
▝▜█████▛▘ Opus 4.5 · Claude Max
▘▘ ▝▝ ~\source\repos\...
Expected behavior:
The focus event escape sequence should be consumed/filtered, not displayed as visible text.
Root cause:
Windows Terminal sends focus reporting events (ESC[I for focus gained, ESC[O for focus lost) when the terminal window gains/loses focus. These are DECSET 1004 focus events. The TUI is not consuming these escape sequences from stdin.
Related issue:
This is similar to #17787 (macOS cursor position responses leaking) - both involve ANSI escape sequences not being properly consumed by the TUI.
What Should Happen?
The Claude Code TUI should consume/filter terminal focus events (DECSET 1004 sequences) so they don't appear as visible text. The header should display cleanly without any ^[[I or ^[[O escape sequences showing.
Error Messages/Logs
Steps to Reproduce
- Open Windows Terminal (or another terminal with focus reporting enabled)
- Run
claudeto start Claude Code - Click away from the terminal window, then click back to give it focus
- Observe that
^[[Iappears in front of the header when the terminal gains focus
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.7
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗