Skip to content

Stop the timeline fighting Android text selection handles - #8006

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-android-text-selection-scrolling-thr_mwr63qrvc3
Nov 22, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-android-text-selection-scrolling-thr_mwr63qrvc3

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On Android Chrome, dragging a text selection handle sends the page no touch or pointer events. Chrome only fires selectionchange and scrolls the timeline itself to keep the handle in view. Three things went wrong as a result:

  • The timeline snapped back. At the bottom of a thread, ScrollPositionKeeper treated Chrome's reveal scroll as unexplained and wrote the scroll position back to the bottom. In one recorded drag, Chrome scrolled to 6065 and the keeper wrote 6075 back. The content moved under the finger, so the selection landed on the wrong text.
  • The menu blocked the handle. The "Add to chat" menu sits just under the end handle and covers the next line. Chrome resolves the handle's position by hit-testing, so dragging onto that line hit the menu and the selection did not extend.
  • The menu didn't follow the selection. The React Compiler memoized <Popover.Anchor virtualRef={ref}>, because the ref object never changed. Radix's anchor effect never re-ran, and the menu stayed where the selection started.

What changed

  • scroll-position-keeper.ts: while a non-collapsed selection is inside the timeline, the keeper follows scrolls that have no input instead of restoring the old position.

  • New lib/touch-selection-passthrough.ts, installed from main.tsx: sets data-touch-text-selection on the root when all of these hold:

    • the last pointer was touch or pen;
    • no pointer is down;
    • 400 ms have passed since the last release;
    • the selection is non-collapsed.

    Any pointerdown removes the attribute synchronously, before Chrome's GestureTap hit test, so a tap on the menu still lands. The module does nothing on iOS WebKit.

  • app.css: :root[data-touch-text-selection] [data-touch-selection-passthrough] { pointer-events: none; }. The rule is unlayered so it beats Tailwind's layered pointer-events-auto.

  • TimelineSelectionMenu.tsx:

    • marks the popover content with data-touch-selection-passthrough;
    • builds the virtual anchor ref with useMemo keyed on the anchor, so the popover moves when the selection does.

    The timeline, diff, secondary panel and terminal all share this menu.

Not fixed: dragging a handle up past the timeline onto the title bar makes Chrome extend the selection to the first loaded text, and the view jumps to the top. Chrome takes that position from the header's layout box rather than from hit-testing, so making the header pointer-events: none does not help. A fix would need the scroller to extend under the header, or a JS guard.

How you verified

  • Android emulator, Chrome, real thread data. The branch build was served in front of a running server and observed over CDP:

    • before the fix, reveal scrolls were written back by the keeper; after it, there are no write-backs;
    • dragging the handle through the menu extends the selection onto the covered line;
    • one tap on "Add to chat" still calls the action;
    • the menu moves under the new selection end (menuTop 430 = last rect bottom 400 + 24 + 6).
  • New tests:

    • scroll-position-keeper.test.ts: two tests, one following a scroll with no input while text in the timeline is selected, and one keeping the end when the selection is outside the timeline.
    • TimelineSelectionMenu.test.tsx: the menu moves when the selection extends.
    • touch-selection-passthrough.test.ts: four tests covering the settle, a pointerdown restoring hit-testing, a collapsed selection, and mouse selections.

    The keeper test and the menu test fail with the pre-fix files and pass with the fix.

  • pnpm exec turbo run typecheck lint test --filter=@bb/app passes (702 files, 7346 tests).

AGENT GENERATED

🤖 Generated with Claude Code

Dragging a selection handle in Android Chrome sends the page no touch or
pointer events. Chrome extends the selection by hit-testing under the
handle and scrolls the timeline to reveal the new end. Three things broke
that:

- The scroll keeper saw those reveal scrolls as unexplained and, at the
  bottom of a thread, wrote them back to the end. It now follows a scroll
  without input while text inside the timeline is selected.
- bb's selection menu sits just below the end handle and covered the
  next line, so dragging the handle onto that line could not extend the
  selection. While a touch selection is up and no finger is down, the
  root carries data-touch-text-selection and the menu ignores
  hit-testing. The next pointerdown restores hit-testing before the tap
  is resolved, so a tap on the menu still lands.
- The menu never followed the selection while handles moved: React
  Compiler cached the Popover anchor element because its virtualRef was
  a stable ref object. The ref object now changes with the anchor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 719d4e6 into main Nov 22, 2026
32 checks passed
@ymichael
ymichael deleted the bb/fix-android-text-selection-scrolling-thr_mwr63qrvc3 branch November 22, 2026 04:01
k0d3r1s added a commit to valksor/vbb that referenced this pull request Nov 24, 2026
Brings upstream get-bb#8006 (Android timeline text selection) and get-bb#7994
(per-session agent writable folders).

Conflict resolution keeps the fork's protocol numbering at 286 with
upstream's 277 incompatible, adopts the per-thread
resolveThreadWorkspaceWriteRoots flow alongside the fork's MCP session
binding in the daemon thread handlers, updates fork test fixtures for
the new required additionalWorkspaceFolders and folders contract
fields, and keeps both sides' bridge test fixtures.
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