Mouse escape sequences leak into input prompt in tmux with SGR mouse mode
Description
When running Claude Code inside tmux with set -g mouse on (SGR extended mouse mode), scrolling or clicking while the input prompt is focused causes raw mouse escape sequences to be captured as text input.
These are SGR mouse protocol sequences (\e[<button;x;yM) that the CLI input handler is not filtering/consuming.
Environment
- Claude Code version: 2.1.63
- OS: macOS (Darwin)
- Terminal: tmux with
set -g mouse on - Shell: bash
Steps to Reproduce
- Run Claude Code inside a tmux session with mouse mode enabled (
set -g mouse on) - Wait for the input prompt to appear
- Scroll up/down with the mouse wheel or click in the pane
Expected Behavior
Mouse events should be silently consumed or ignored by the input handler. Scrolling in tmux should work normally without injecting text.
Actual Behavior
Raw SGR mouse escape sequences appear as text in the input prompt. These get submitted as messages if the user presses Enter.
Workaround
Use Ctrl-b [ to enter tmux copy mode for scrolling (keyboard-based), then q to exit. Avoid scrolling with mouse wheel while the input prompt is focused.
Notes
This was not observed in earlier versions of Claude Code. Likely a regression in how raw terminal input is handled — the CLI may need to enable/disable mouse reporting or filter incoming CSI sequences matching the SGR mouse pattern.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗