Skip to content

feat(terminal): touch scroll, copy mode toggle, and desktop mouse fix#5

Open
dguerizec wants to merge 2 commits intotwidi:mainfrom
dguerizec:feature/terminal-scroll
Open

feat(terminal): touch scroll, copy mode toggle, and desktop mouse fix#5
dguerizec wants to merge 2 commits intotwidi:mainfrom
dguerizec:feature/terminal-scroll

Conversation

@dguerizec
Copy link
Contributor

Summary

  • Mobile toolbar with Copy mode toggle: swipe scrolls by default, toggle to select text
  • Context-aware scroll: arrow keys for alternate screen (less/vim), SGR wheel for tmux scrollback, viewport scroll for raw shell
  • Backend polls tmux #{alternate_on} every 2s and pushes pane state to frontend
  • Enables tmux mouse mode and configures smart WheelUpPane/WheelDownPane bindings
  • Desktop: capture-phase mouse interception blocks SGR reports to tmux, restoring native text selection, middle-click paste (X11), and right-click context menu
  • Removes ClipboardAddon so Ctrl+V reaches the shell (bash quoted-insert)

Split from #4 as requested — scroll & mouse interaction only, no navigator/presets/window management.

Test plan

  • Mobile: swipe scrolls terminal in shell mode (natural direction)
  • Mobile: enter less → swipe sends arrow keys (content scrolls)
  • Mobile: toggle Copy mode → swipe selects text → auto-copies and exits copy mode
  • Desktop (tmux): left-click drag selects text, auto-copies to clipboard
  • Desktop (tmux): double-click selects word, triple-click selects line
  • Desktop (tmux): middle-click pastes from X11 primary selection
  • Desktop (tmux): right-click shows browser context menu
  • Desktop (tmux): mouse wheel scrolls tmux scrollback
  • Desktop (tmux): Ctrl+V reaches the shell (quoted-insert)
  • Desktop (no tmux): all mouse behavior unchanged

🤖 Generated with Claude Code

Mobile toolbar gets a Copy toggle button (off by default):
- Off (scroll mode): swipe scrolls the terminal with natural direction
- On (copy mode): swipe selects text, auto-resets after copy

Scroll adapts to context via tmux pane state detection:
- Shell prompt: SGR mouse wheel → tmux copy-mode scrollback
- Alternate screen (less, vim): arrow keys → app handles scroll
- Raw shell (no tmux): xterm.js viewport scrollLines()

Backend polls tmux #{alternate_on} every 2s, sends state to frontend
so scroll method switches automatically. Also enables tmux mouse mode
for proper wheel event handling and configures smart WheelUpPane /
WheelDownPane bindings.
…aste

In tmux mode, SGR mouse tracking causes xterm.js to send all mouse events
as escape sequences to tmux instead of handling them locally. This breaks
text selection and paste on desktop.

A capture-phase mousedown listener on the terminal container blocks all
mouse buttons from reaching xterm.js. Left-button gets preventDefault for
custom drag selection via terminal.select(). Middle/right-click only get
stopPropagation so browser default actions (X11 paste, context menu) flow
through to xterm.js's native paste handler.

Also removes ClipboardAddon so Ctrl+V reaches the shell (quoted-insert)
instead of being intercepted for clipboard paste.
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