Mouse escape sequences leak into input prompt in tmux with SGR mouse mode

Resolved 💬 3 comments Opened Mar 4, 2026 by ai-astrid Closed Mar 7, 2026

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

  1. Run Claude Code inside a tmux session with mouse mode enabled (set -g mouse on)
  2. Wait for the input prompt to appear
  3. 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.

View original on GitHub ↗

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