Skip to content

fix(terminal): make scroll wheel work again in alternate screen#42

Open
egertaia wants to merge 1 commit into
amirlehmam:masterfrom
egertaia:fix/scroll-in-terminal
Open

fix(terminal): make scroll wheel work again in alternate screen#42
egertaia wants to merge 1 commit into
amirlehmam:masterfrom
egertaia:fix/scroll-in-terminal

Conversation

@egertaia

@egertaia egertaia commented Jun 18, 2026

Copy link
Copy Markdown

Fixes #41

Summary

  • Fixes scroll wheel regression in alternate-screen apps (Claude Code, vim, less, htop) introduced in v0.8.4+
  • When on the alternate buffer, takes ownership of wheel events and forwards them to the PTY directly instead of relying on xterm's _handleWheel / _handlePassiveWheel which are unreliable after the WebGL context swap
  • Sends SGR mouse-wheel sequences (\x1b[<64;col;rowM / \x1b[<65;col;rowM) when the app has enabled mouse tracking, falls back to arrow keys otherwise

Root cause

xterm's built-in wheel forwarding fails in two cases:

  1. The wheel listener is only registered when the app has explicitly requested wheel mouse events via DECSET
  2. _consumeWheelEvent returns 0 when render-service cell dimensions are temporarily unavailable (can happen after the WebGL renderer swap in v0.8.4+), causing the event to be silently dropped

Test plan

  • Scroll in a normal terminal — scrollback works as before
  • Scroll inside Claude Code / vim / less — content scrolls correctly
  • Scroll in a TUI without mouse tracking enabled — arrow keys sent, content moves

🤖 Generated with Claude Code

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.

Mouse wheel scroll broken inside Claude Code (alternate screen buffer) — v0.8.7

1 participant