claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] When terminal sends Focus In/Out events (DECSET 1004), [ I / [ O appear in input. Expected: handled/ignored.

Open pro-vi opened this issue 1 month ago • 7 comments

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?

Image

When I blur the terminal pane (WezTerm), [O shows up in the input; when I focus the terminal pane (WezTerm), [I shows up in the input. These two reporting are activated when there are multiple terminal panes in the same tab on WezTerm.

What Should Happen?

These two events should be handled gracefully by Claude Code. It could also be explored as user behavioral metrics.

Error Messages/Logs


Steps to Reproduce

  1. Open WezTerm
  2. Run claude
  3. Split the tab window using Shift + Ctrl + Alt + %
  4. Use Shift + Ctrl + Arrow Keys to jump between the two windows, or simply click around with mouse
  5. See focus event characters pop up in Claude Code input box

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.36

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

No response

pro-vi avatar Nov 10 '25 23:11 pro-vi

in my case, this starts happening only after editing a prompt in an external editor (with ctrl+g), before the first use it doesn't happen, but it will persist across the terminal session

Avishayy avatar Nov 11 '25 13:11 Avishayy

Running into this in Ghostty too. Quite annoying.

tino avatar Nov 11 '25 20:11 tino

Also reproducible using Windows Terminal (in my case via ssh to a Linux box)

abatkin avatar Nov 13 '25 16:11 abatkin

I also have the same problem. my stack: macos+ghostty+tmux. I confirm that the problem is triggered by the usage of an external editor with ctrl+g. I use neovim as editor.

raw1z avatar Nov 14 '25 05:11 raw1z

I also have this issue - started happening a couple of weeks ago if I am not mistaken. Using alacritty with Tmux, and it happens regardless of ctrl+g editing in nvim. It happens every time I switch/focus/blur from the tab that I keep Claude in - midly infuriating actually.

axeltlarsson avatar Nov 18 '25 15:11 axeltlarsson

I'm seeing this same issue when using Claude Code inside tmux. When I switch to the Claude Code window the text [0[I] appears in the input. I'm using Kitty terminal with tmux and have set -g focus-events on in my tmux config (needed for various terminal applications that rely on focus events). Disabling focus events (set -g focus-events off) fixes it, but then other terminal applications lose important functionality. It would be great if Claude Code could handle these focus event sequences properly like other TUI apps do.

0xMH avatar Dec 02 '25 11:12 0xMH

I wrote a short golang wrapper for claude that strips these focus events from inputs to claude (https://github.com/samuelstevens/claude-unfocused) that I alias to claude and it resolves my issues. It would of course be better for claude code to fix this.

samuelstevens avatar Dec 11 '25 17:12 samuelstevens

As of 2.0.67 this seems to be fixed. Will close out after some continued observation.

pro-vi avatar Dec 14 '25 06:12 pro-vi