claude-code - 💡(How to fix) Fix Mouse click events leak as raw SGR escape sequences in terminal [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49017Fetched 2026-04-17 08:53:10
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

When running Claude Code in a terminal (macOS), mouse click events (e.g., clicking to switch windows) produce raw SGR mouse tracking escape sequences that are printed as garbled text in the Claude Code UI.

Mouse movement alone does NOT trigger the issue — only click events do.

Root Cause

When running Claude Code in a terminal (macOS), mouse click events (e.g., clicking to switch windows) produce raw SGR mouse tracking escape sequences that are printed as garbled text in the Claude Code UI.

Mouse movement alone does NOT trigger the issue — only click events do.

Code Example

^[[0^[[<35;15;42M^[[<35;11;44M^[[<35;9;45M^[[<35;6;48M^[[<35;3;50M...
RAW_BUFFERClick to expand / collapse

Description

When running Claude Code in a terminal (macOS), mouse click events (e.g., clicking to switch windows) produce raw SGR mouse tracking escape sequences that are printed as garbled text in the Claude Code UI.

Mouse movement alone does NOT trigger the issue — only click events do.

Reproduction Steps

  1. Run claude in a terminal (iTerm2 / Terminal.app on macOS)
  2. While Claude Code is running (e.g., waiting for input, or showing "Save and close editor to continue..." after Ctrl+G), click with the mouse to switch to another window
  3. Switch back to the terminal

Observed Behavior

Raw SGR mouse tracking escape sequences appear as garbled text:

^[[0^[[<35;15;42M^[[<35;11;44M^[[<35;9;45M^[[<35;6;48M^[[<35;3;50M...

These are SGR extended mouse protocol sequences (^[[<button;x;yM) — the TUI enables mouse tracking but does not properly consume click events when the terminal loses/regains focus.

Expected Behavior

Mouse click events should be silently consumed by the TUI, not printed as raw escape sequences.

Environment

  • OS: macOS (Darwin 25.3.0, arm64)
  • Claude Code: latest channel
  • Terminal: tested in multiple terminal emulators
  • TUI mode: reproduces with both "tui": "fullscreen", CLAUDE_CODE_NO_FLICKER=1, and default renderer

Additional Context

  • Only click events produce garbled output; mouse movement is handled correctly
  • The issue is particularly noticeable when using Ctrl+G (external editor) and clicking to switch back
  • Removing all custom hooks/settings does not resolve the issue

extent analysis

TL;DR

Disable mouse tracking in the Claude Code TUI to prevent garbled text output from mouse click events.

Guidance

  • Investigate the TUI configuration options to see if there's a way to disable mouse tracking or properly handle click events when the terminal loses focus.
  • Verify that the issue is indeed related to the TUI's mouse tracking feature by checking if disabling it resolves the problem.
  • Consider using a different terminal emulator to see if the issue is specific to certain terminals.
  • Look into the Claude Code documentation to see if there are any known issues or workarounds related to mouse events and TUI mode.

Example

No code snippet is provided as the issue seems to be related to configuration or TUI settings rather than code.

Notes

The issue seems to be specific to macOS and the Claude Code TUI, and may require a configuration change or workaround to resolve.

Recommendation

Apply workaround: Disable mouse tracking in the TUI or use a different terminal emulator to mitigate the issue, as the root cause seems to be related to the TUI's handling of mouse events.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING