Bug Description
When using Claude Code in WezTerm (and likely other terminals), focus reporting escape sequences [I and [O are being injected into the input interface when clicking with the mouse or using modifier keys. These escape sequences should be filtered by Claude Code's input handler.
Environment
- Terminal: WezTerm
- Platform: macOS (Darwin 25.0.0)
- Claude Code Version: Latest (2025-10-26)
Root Cause
Terminal applications can enable focus reporting mode (ANSI mode 1004) which causes the terminal to send:
ESC[I (or [I) when the terminal gains focus
ESC[O (or [O) when the terminal loses focus
These escape sequences are leaking into Claude Code's input interface instead of being filtered out.
Steps to Reproduce
- Launch Claude Code in WezTerm
- Click in the input area with mouse
- Use modifier keys (Cmd, Shift, etc.)
- Observe
[I or [O characters appearing in the input
Expected Behavior
Claude Code should filter focus reporting escape sequences (CSI I and CSI O) from user input, similar to how other terminal applications handle these sequences.
Actual Behavior
The raw escape sequence characters appear in the input field, interfering with normal typing and command input.
Technical Details
Focus Reporting Overview:
- Enabled by:
ESC[?1004h
- Disabled by:
ESC[?1004l
- Focus gained sends:
ESC[I
- Focus lost sends:
ESC[O
Applications like Vim may enable this mode and sometimes fail to disable it on exit, leaving the terminal in focus reporting mode.
Workarounds
Temporary fix (run in terminal):
Permanent fix (add to shell RC file):
# Disable focus reporting on shell startup
printf '\e[?1004l'
Related Issues
Proposed Solution
Claude Code's input handler should filter the following escape sequences:
\x1b[I (focus in)
\x1b[O (focus out)
- Potentially other CSI sequences that shouldn't appear in user input
Impact
This affects users who:
- Use WezTerm or terminals with focus reporting enabled
- Have applications (vim, etc.) that leave focus reporting enabled after exit
- Frequently use mouse or keyboard modifiers while interacting with Claude Code
Thank you for looking into this!
Bug Description
When using Claude Code in WezTerm (and likely other terminals), focus reporting escape sequences
[Iand[Oare being injected into the input interface when clicking with the mouse or using modifier keys. These escape sequences should be filtered by Claude Code's input handler.Environment
Root Cause
Terminal applications can enable focus reporting mode (ANSI mode 1004) which causes the terminal to send:
ESC[I(or[I) when the terminal gains focusESC[O(or[O) when the terminal loses focusThese escape sequences are leaking into Claude Code's input interface instead of being filtered out.
Steps to Reproduce
[Ior[Ocharacters appearing in the inputExpected Behavior
Claude Code should filter focus reporting escape sequences (
CSI IandCSI O) from user input, similar to how other terminal applications handle these sequences.Actual Behavior
The raw escape sequence characters appear in the input field, interfering with normal typing and command input.
Technical Details
Focus Reporting Overview:
ESC[?1004hESC[?1004lESC[IESC[OApplications like Vim may enable this mode and sometimes fail to disable it on exit, leaving the terminal in focus reporting mode.
Workarounds
Temporary fix (run in terminal):
Permanent fix (add to shell RC file):
Related Issues
Proposed Solution
Claude Code's input handler should filter the following escape sequences:
\x1b[I(focus in)\x1b[O(focus out)Impact
This affects users who:
Thank you for looking into this!