Repository navigation
Conversation
86b751c to
18c67cf
Compare
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Two mechanisms fix the handle-over-chrome defect: the inert overlays, and the restore's focus-out branch, which the PR's own comments say the inert overlays already cover. Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: on a phone, a text selection in a chat transcript stays where the reader put it. FIX.
[FIRST-PRINCIPLES-REVIEWED] b2b8344 Description read[DESCRIPTION-READ] 08106240cf7a693a85d87fa36d0f4f74e4bb8dc4a6a06143221cdfc719286fd7 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has looked at the touch long-press change; the screenshot and recording show it, but nobody has read them cold. Watch
[UX-REVIEWED] b2b8344 Description read[DESCRIPTION-READ] 0a919817bd57bc53126b5eaffdf8f20a51feedc07698f08647ef1b98a7bdd566 That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS iOS Safari is never verified, yet the inert overlays, the Watch
Suggestions
[DESIGN-REVIEWED] b2b8344 Description read[DESCRIPTION-READ] db26da6960411f101c16a260b85931bd91987c4285b026fe8fa5d78ca8432894 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings block this merge. FINDING — website/src/pages/ChatPage.tsx:198 — the selection-retention effect has no [OPUS-REVIEWED] b2b8344 |
18c67cf to
993c951
Compare
993c951 to
01c91c6
Compare
On a phone, selecting transcript text failed four ways: - a long-press opened the bubble's context menu over the selection; - a handle dragged under the composer dock, the chat header or the phone top bar (which hosts the session title) landed in their text, and the selection took everything in between; - scrolling with a selection unmounted the row holding its start, and the browser re-rooted the start at the top of the transcript; - a start row re-rendered while scrolled away left the start parked between rows, walked up to offset 0 as rows mounted above it. Fix: - disable the bubble context menu on touch (the action row keeps the same actions); - make the header, the dock and the shell top bar inert while a transcript selection is held (touch only); - add retainRange to the virtualizer: every window write keeps the selection's rows mounted; - remember each endpoint as row + character offset, and put an endpoint that leaves its row back where it last sat. A fresh long-press, with no settled position yet, is never rewritten. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
01c91c6 to
b2b8344
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
This PR fixes four Android touch-selection failures in the chat transcript (long-press menu, handles landing in chrome, start re-rooted on unmount, start drifting after re-render), and the touch-side root causes are addressed: inert overlays, a retained virtual range, and an endpoint restore. I read the full production diff, the five AI lanes on head b2b8344, and the new tests. GPT and Design have no blocking findings, but the Opus finding is real and has no disposition. The new selection-retention effect at website/src/pages/ChatPage.tsx:3696-3719 is not gated on touch. The new setWindowRange wrapper in website/src/hooks/virtualizer/windowRange.ts:122-134 always unions the window with the retained span. So on desktop, a selection made in an old row (desktop selections stay after the mouse-up) keeps every row from that point to the current scroll position mounted, and defeats virtualization and the far-jump replace. That contradicts the body's "Not a goal: changing desktop selection" claim. Suggested fix: gate the effect on useIsTouchDevice() like useSelectionInertOverlays, or cap the retained span and drop it when a far jump replaces the window, and add a test that a desktop (non-touch) selection does not call retainRange. Please also answer the open Design watch (iOS Safari is not verified while every touch device runs the restore and inert paths), the UX watch (long-press Pin/Copy link now reachable only via More), and the First Principles subtraction of the focus-out restore branch. — crew-pr-reviewer
|
Thank you @Premshay for this fix and the careful on-device traces. The PR went into a merge conflict with main, so we carried it forward as a same-repo PR: #19864. You stay the author of the main commit. One change: the long-press context-menu part (case 1) is dropped, because main already fixed it in #18340. The other three fixes and their tests are kept as you wrote them. Closing this one in favour of #19864; your branch is left as is. |
* fix(chat): keep a touch text selection where the reader put it On a phone, selecting transcript text failed three ways: - a handle dragged under the composer dock, the chat header or the phone top bar (which hosts the session title) landed in their text, and the selection took everything in between; - scrolling with a selection unmounted the row holding its start, and the browser re-rooted the start at the top of the transcript; - a start row re-rendered while scrolled away left the start parked between rows, walked up to offset 0 as rows mounted above it. (The fourth case from the original PR, a long-press opening the bubble context menu, is already fixed on main by #18340 and is dropped here.) Fix: - make the header, the dock and the shell top bar inert while a transcript selection is held (touch only); - add retainRange to the virtualizer: every window write keeps the selection's rows mounted; - remember each endpoint as row + character offset, and put an endpoint that leaves its row back where it last sat. A fresh long-press, with no settled position yet, is never rewritten. Replaces #18491. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: cixuuz <26782336+cixuuz@users.noreply.github.com> * test(chat): give the closed-session provider mock retainRange ChatPage now calls retainRange on selectionchange; this test landed on main (#18303) after the original PR, and its useVirtualChat mock lacked the new member. --------- Co-authored-by: Premshay <28099628+Premshay@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: cixuuz <26782336+cixuuz@users.noreply.github.com>

Problem / Motivation
Goal: On a phone, selecting text in a chat transcript keeps the selection where the reader put it.
On Android Chrome (verified on a real device), text selection in the transcript fails four ways:
Why it matters
Copying a passage from a reply is a basic action on a phone, and in these cases it either fails or copies the whole conversation instead.
Not a goal
What changed (motivation → approach → change)
Each change was checked against an on-device trace of the selection's endpoints (row, node, offset, selected text) captured while reproducing the bug.
MessageContextMenu.tsx):ContextMenuTriggerisdisabledon touch (useIsTouchDevice). Long-press is the platform's selection gesture; the same actions stay on the bubble's action row, which is always visible on touch: its shared classICON_ACTION_ROW_CLS(utils/touchActions.ts) already carries[@media(hover:none)]:opacity-100, so the row needs no hover or tap to appear. Every frame of the recording shows it under each reply (Quote, Copy, More; Edit sits under the user's own bubble).useSelectionInertOverlays.ts,ChatPage.tsx,App.tsx): the chat header overlay, the composer dock, and the shell<header>carrydata-selection-inert. While a transcript selection is held (either endpoint inside the scroller), touch devices setinerton them, so a dragged handle hit-tests the transcript beneath.user-select: nonedoes not change where the caret lands;inertdoes. A capture-phasetouchstartreleases them at once: Android's selection handles dispatch no touch events, so a finger on the page is the reader reaching for something, and the first tap on the composer or header is never swallowed. The next handle move re-appliesinert.windowRange.ts,types.ts,useVirtualChat.ts): newretainRange(range | null).useWindowStatewraps its setter so every window write keeps the retained rows mounted, whichever owner moved the window. It is cleared on session change.utils/selectionRetention.ts,ChatPage.tsx): onselectionchange, both endpoints on rows set the retained span; an endpoint off any row keeps the last span; a collapsed or outside selection releases it. Each endpoint is also remembered as row index + character offset. When the start drifts off its row while the end is on one, or the end leaves the transcript, that endpoint is put back at its last position, by node if still mounted, else by character offset in the row's current text. A selection that has not yet sat on rows (a fresh long-press) is never rewritten. Rewriting one was found to cancel the first press or extend it to the whole chat.Backwards compatibility
Compatible:
retainRangeis a new member on theuseVirtualChatreturn; nothing existing changes shape. The touch-only behaviours do not run on desktop.Removes nothing: the bubble context menu is unchanged on desktop, and on touch its actions stay on the bubble's action row.
Tests
selectionRetention.test.ts: row-span computation; keep vs release; restoring a start that landed on the title; restoring a start parked between rows after its row re-rendered (by character offset); a fresh long-press left alone; an end over the scroller padding left alone.useSelectionInertOverlays.test.tsx: overlays inert while a transcript selection is held on touch (including when only the focus is in the transcript), released after; released at once by a fingertouchstartand re-applied by the next selection change; untouched for an outside selection and on desktop.ChatPage.overlaySelection.test.tsx: source contracts for the inert markers (header, dock, shell top bar), the retained-range wiring, and that only a settled selection is restored.AssistantMessage.quote.test.tsx: the bubble context menu does not open on touch.useVirtualChat.surfaceContract.test.tsx:retainRangeadded to the return surface and its stable-identity list.useVirtualChatmocks in 10 ChatPage tests gainretainRange; two dock-root regexes allow the new attribute.Local runs:
tsc -bclean; ChatPage + App tests 2168/2168; virtualizer + selection tests 464/464.Manual verification
On Android Chrome against a live dashboard, each case above was reproduced, traced, and confirmed fixed after the change: long-press selects without a menu; dragging a handle over the composer, the header, or the title stays in the transcript; long-pressing a word, scrolling it off screen, and extending the end handle keeps the selection starting at that word (copy confirms).
Screenshots / video
Long-press on touch: the pressed word is selected with the selection toolbar, no bubble context menu opens, and the bubble's action row (Fork, Copy, More) stays visible under the reply:
Recording (33 s, 390×844, dark theme):
touch-selection-18491.webm
It runs the real built SPA from this branch, with fixture data only: the transcript-harness (
scripts/lib/transcript-harness.mjs) mocks/api/**. The viewport is phone-sized withhasTouchemulated, so(pointer: coarse)and(hover: none)match. A yellow dot marks the finger, and a caption states each result. The capture script also asserts each result in the page and aborts if one fails.message-context-menunever mounts. The bubble's action row stays visible under the reply throughout, which is where the menu's actions live on touch.inertontouchstart.Simulated part: headless Chromium draws no native selection handles, so each handle drag is reproduced as the browser performs one. It hit-tests the handle's point with
caretRangeFromPoint, then callsSelection.extendto it. That is the hit-test the inert overlays change. The long-press and the composer tap are real CDP touch events. The same flows were also verified by hand on Android Chrome against a live dashboard (see Manual verification).Related Issues
N/A
Pattern harvest
Rule candidate: review-prompt
Pattern: a virtualized list that unmounts or re-renders rows must keep any rows holding a live DOM Selection or Range endpoint mounted (or restore the endpoint by logical position), or the browser silently re-roots it.
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license.
🤖 Generated with Claude Code