Skip to content

fix: terminal scroll — mobile touch + desktop auto-scroll - #44

Merged
aterrylu merged 1 commit into
mainfrom
terry/terminal-scroll-fix
Mar 23, 2026
Merged

fix: terminal scroll — mobile touch + desktop auto-scroll#44
aterrylu merged 1 commit into
mainfrom
terry/terminal-scroll-fix

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

  • Mobile touch scrolling: xterm.js v6 doesn't handle touch natively — canvas overlays viewport. Added touch event handlers that translate swipe gestures into terminal.scrollLines() calls.
  • Desktop auto-scroll: Replaced per-message atBottom check (3-row threshold) with userScrolledUp state tracking. Auto-scroll stops when you scroll up, resumes when you scroll back to bottom.
  • Page scroll prevention: overflow: hidden + overscroll-behavior: none on body prevents mobile page-level scrolling.

Test plan

  • Mobile: swipe up/down in terminal scrolls through buffer
  • Mobile: no page-level scroll or bounce
  • Desktop: scroll up during streaming output — stays where you scrolled
  • Desktop: scroll back to bottom — auto-scroll resumes
  • Desktop: auto-scroll works on fresh connection/reconnect
  • All 67 existing tests pass

🤖 Generated with Claude Code

Mobile touch scrolling:
- xterm.js v6 doesn't handle touch natively (canvas overlays viewport)
- Added touch event handlers that translate gestures into scrollLines()
- touch-action: none on container lets xterm handle all touch events
- body overflow:hidden + overscroll-behavior:none prevents page scroll

Desktop auto-scroll:
- Track userScrolledUp via onScroll instead of per-message atBottom check
- Once user scrolls up, auto-scroll stops until they scroll back to bottom
- programmaticScroll flag prevents scrollToBottom() from flipping the flag
- Reset userScrolledUp on WebSocket reconnect

Hardening from review:
- disposed guard on onScroll and onTouchMove handlers
- lineHeight uses fontSize * lineHeight multiplier with <= 0 guard
- scrollSensitivity: 3 for better touch responsiveness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu merged commit 523943f into main Mar 23, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/terminal-scroll-fix branch March 23, 2026 07: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