Skip to content

[Bug] Claude Code captures mouse events in tmux, making scrollback completely unusable #38810

Description

@stilletto

Preflight Checklist

  • I have searched existing issues and confirmed this is not a duplicate
  • I am on the latest version of Claude Code
  • I can reproduce this issue consistently

Bug Description

When running Claude Code inside tmux, the TUI scrollbar disappears and scrolling breaks completely.

Without tmux (normal terminal):

  • Claude Code TUI shows a scrollbar on the right side of the conversation output
  • Mouse wheel scrolls the conversation history (previous messages, tool results, etc.)
  • Works perfectly

Inside tmux:

  • The scrollbar disappears entirely
  • Mouse wheel scrolls the input box history (like pressing arrow up/down), cycling through previous commands instead of scrolling conversation output
  • There is no way to scroll the conversation output — only the very bottom is visible
  • tmux set -g mouse on/off doesn't help in either mode

This also affects other similar TUI tools (e.g. OpenAI Codex CLI has the same issue in tmux).

Steps to Reproduce

  1. Start tmux: tmux new-session -s test
  2. Run Claude Code: claude
  3. Ask Claude something that produces long output
  4. Try to scroll up with mouse wheel
  5. Expected: conversation history scrolls up with scrollbar visible (as it works outside tmux)
  6. Actual: input box cycles through command history (like arrow up/down), no scrollbar, conversation output not scrollable

Root Cause

The TUI appears to detect different terminal capabilities when running inside tmux ($TMUX is set), falling back to a degraded mode where:

  • The scrollbar component is not rendered
  • Mouse wheel events are routed to input history navigation instead of conversation viewport scrolling

This is likely related to how the Ink framework handles alternate screen buffer and mouse tracking inside tmux. tmux intercepts certain escape sequences for mouse event handling, which breaks the TUI's ability to receive and process scroll events for its own viewport.

Proposed Solution

  1. Detect tmux environment and ensure the scrollbar still renders and mouse wheel routes to conversation viewport
  2. Or add a config option / CLI flag (e.g. --no-mouse or disableMouseCapture in settings) to disable mouse capture, letting tmux handle scrollback natively
  3. Or provide a keyboard shortcut for scrolling conversation output (e.g. Page Up/Down) that works regardless of terminal environment

Environment

  • OS: Linux (WSL2 - Ubuntu)
  • Terminal: Windows Terminal → WSL2 → tmux 3.x
  • Claude Code: latest version

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions