Skip to content

fix(terminal): restore tmux mouse mode so scroll wheel scrolls history#318

Merged
eyelock merged 2 commits into
developfrom
fix/tmux-attach-scroll-break
May 12, 2026
Merged

fix(terminal): restore tmux mouse mode so scroll wheel scrolls history#318
eyelock merged 2 commits into
developfrom
fix/tmux-attach-scroll-break

Conversation

@eyelock
Copy link
Copy Markdown
Owner

@eyelock eyelock commented May 12, 2026

Summary

In tmux attach mode, scroll wheel events were being delivered to mouse-aware apps (e.g. Claude Code) as arrow-key keystrokes rather than scrolling tmux's scrollback. Re-enable tmux mouse on so scrolling works as expected.

Root cause

PR #112 disabled set-option mouse on to fix native text selection. With tmux mouse off, tmux swallows the inner app's mouse-mode-enable escapes — SwiftTerm sees an alt screen with mouseMode == .off and converts wheel events to arrow keys (both in our TerminalContainerView.handleScrollEvent and in SwiftTerm's own scrollWheel). Mouse-aware apps then interpret those arrows as keystrokes.

PR #147 later introduced the allowMouseReporting toggle in TermQTerminalView, which disables SwiftTerm's mouse reporting during drag-select. That makes mouse on safe again — selection still works.

Changes

  • TerminalSessionManager.startTmuxAttachProcess: flip set-option mouse offmouse on.
  • Add bind-key -T copy-mode[-vi] WheelDownPane bindings that auto-cancel copy-mode once scroll_position reaches the bottom, so the wheel doesn't leave the user parked in copy-mode with a [n/n] indicator on screen.

Testing

  • make check passes (quality gate clean — build, lint, format, 1882 tests)
  • Manual: scroll wheel inside Claude Code (tmux attach) scrolls tmux scrollback and auto-returns to live shell at the bottom
  • Manual: click-drag still produces a native text selection
  • Direct mode and TMUX Control mode unaffected

🤖 Generated with Claude Code

David Collie and others added 2 commits May 13, 2026 00:27
In tmux attach mode, `set-option mouse off` caused tmux to swallow the
inner app's mouse-mode-enable escapes. SwiftTerm then saw an alt screen
with mouseMode == .off and converted scroll wheel events to arrow keys,
which mouse-aware apps like Claude Code interpret as keystrokes.

Re-enable `mouse on`. Native text selection still works thanks to the
allowMouseReporting toggle added in #147, which disables SwiftTerm's
mouse reporting on drag. Add WheelDownPane copy-mode bindings that
auto-cancel when scroll_position reaches the bottom so the wheel
doesn't leave the user parked in copy-mode.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eyelock eyelock merged commit c380435 into develop May 12, 2026
7 checks passed
@eyelock eyelock deleted the fix/tmux-attach-scroll-break branch May 12, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant