Skip to content

fix(terminal): preserve touch selection while scrolling#1904

Merged
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/terminal-touch-selection-scroll-safe
Feb 26, 2026
Merged

fix(terminal): preserve touch selection while scrolling#1904
bajrangCoder merged 1 commit intoAcode-Foundation:mainfrom
bajrangCoder:fix/terminal-touch-selection-scroll-safe

Conversation

@bajrangCoder
Copy link
Member

  • switch to tap-to-clear instead of clearing on touchstart
  • keep selection active during scroll and restore handles/menu after scroll end
  • listen to xterm viewport scroll for stable touch-selection behavior

- switch to tap-to-clear instead of clearing on touchstart
- keep selection active during scroll and restore handles/menu after scroll end
- listen to xterm viewport scroll for stable touch-selection behavior
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR significantly improves the terminal touch selection UX by implementing three key enhancements:

Key Changes:

  • Tap-to-clear behavior: Replaced immediate selection clearing on touchstart with a smarter tap-to-clear mechanism that only clears when the user taps (no movement) while not scrolling
  • Scroll-aware selection: Selection now persists during scrolling with handles and context menu temporarily hidden, then restored after scroll ends (100ms delay)
  • Better scroll detection: Listens to .xterm-viewport scroll events instead of the terminal element for more stable touch-selection behavior

Implementation Quality:

  • Proper state management with new flags (isSelectionTouchActive, pendingSelectionClearTouch, isTerminalScrolling)
  • Clean timeout management with proper cleanup in destroy() and clearSelection()
  • Handles edge cases well (dragging handles, protected selection, concurrent scrolling)
  • The removed onTerminalAreaTouchStart method and its immediate-clear behavior is appropriately replaced by the new tap-to-clear logic

User Experience Impact:
Users can now scroll through terminal output without losing their selection, and accidental touches during scrolling won't clear the selection. The tap-to-clear mechanism provides intentional selection dismissal.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The implementation demonstrates solid engineering with proper state management, comprehensive cleanup, and well-handled edge cases. The changes are focused on a single component with clear intent, and all new state variables are properly initialized, managed, and cleaned up.
  • No files require special attention

Important Files Changed

Filename Overview
src/components/terminal/terminalTouchSelection.js Improves touch selection UX by switching to tap-to-clear and preserving selection during scrolling with proper state management

Last reviewed commit: bd3b9db

@bajrangCoder bajrangCoder merged commit 9318510 into Acode-Foundation:main Feb 26, 2026
5 checks passed
@bajrangCoder bajrangCoder deleted the fix/terminal-touch-selection-scroll-safe branch February 26, 2026 12:07
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