Repository navigation
fix(mobile): phone chat page keeps following after a nudge, per chat, and at 2,000 messages - #28807
brennanb2025 wants to merge 8 commits into
Conversation
…t page Follow-up to #28413, on the page the OTA phone app draws: - A small move up during a live turn stopped following with no "Scroll to latest" arrow. A scroll that comes to rest within 80 pt of the end now returns to it and follows, as letting go there does in the native app. - Switching chat tabs carried "not following", the page's scroll state and the page-history head into the next chat. They are now per chat. - At the 2,000-message ceiling every new message trims the oldest row; the place-hold (ours and the browser's own scroll anchoring) moved the view up for it and the page took that for the reader. Holding now happens only while not following. - The hold anchored the lowest element on screen, which could be the live status line. It now anchors the first message row on screen.
…llowing On the page (RN Web), following turned off on any scroll event that read as a move up, so layout (clamps, re-measures, trims) could detach it, and extra bookkeeping (a settle timer, per-touch ids, cancel uncertainty) tried to tell reader moves from layout moves. A touch whose element was removed mid-touch never delivered its end, which stranded the page out of following with no jump control. Following now turns off only under a reader gesture (a finger on the list per the browser's live touches list, or a wheel or scroll key, until scrolling goes quiet), and turns back on whenever the view reaches the end. Pins wait for the gesture to end, so nothing moves the view under a finger. Any detached page view shows the existing Scroll to latest control.
…inger The phone chat page holds re-pins while a finger is on the list, and only a touchend that React saw let them resume. A thumb resting on the streaming row, replaced mid-touch, ended on the removed element, so pins stayed held for good. Listen for each list touch's end on the element it started on, which the browser keeps targeting after removal, and derive "touching" from those.
|
Closing this in favour of three smaller stacked PRs that rebuild the fix from current
Why this PR was superseded. #28413 made the phone chat keep your place while you read older messages, and on the web-page version of the phone chat (over-the-air builds) it brought several bugs: a small nudge up silently stopped auto-scroll with no "Scroll to latest" arrow, switching chats kept the last chat's scroll state, very long chats stopped following on every message at 2,000 messages, and loading older messages could jump past your place. This PR fixed those over six review rounds, but final iPhone testing found a new problem: after older messages loaded at the top, the chat could freeze and stop scrolling until you left it. The review traced every one of these bugs to one cause. On that page, the list doesn't keep your place, follow new output, or load older messages by itself, so Orca did all three by hand around a single number, the list's scroll position. Orca's own scroll writes, iOS's bounce and momentum, and the "did the reader scroll away?" check all touched that number and kept misreading each other. Patching each case inside this PR kept producing the next one, so Brennan chose to rebuild it as the three focused PRs above. Each removes one part of that cause and can land or be reverted on its own. The branches of this PR stay until those three merge. |
ELI5
#28413 stopped the phone chat from pulling you back to the bottom while you read older messages. A review of that merged change found four ways it misbehaves in the chat the phone app draws as a web page (current phone builds draw it that way; the page ships inside the desktop app):
After this PR: a small nudge snaps back to the end and keeps following, as it already does in the native app. Every chat opens at its newest message. Long chats keep following. Loading older messages keeps the message you were reading where it was.
What Changed
All in
mobile/src/session/, and only the web-page path (react-native-web) changes behavior. The native app is unchanged except for the per-chat reset (2).use-mobile-native-chat-tail-follow.ts). The native app knows when the finger lifts: within 80 pt of the end it snaps back and keeps following. The page gets no touch-release events, only scroll positions. It now treats a scroll that has been still for 150 ms as let go (react-native-web sends its last scroll event 100 ms after the view stops). If the view is then within the same 80 pt of the end, it jumps back and follows. So "not following, with no arrow" can't outlast a scroll. Any move up still stops following at once, so a reader dragging up while a reply streams gets away from the bottom. The same rule fixes a related case: the view clamped onto the end after the transcript shrank (for example a reconnect that resets to the last 40 messages) now resumes following instead of sitting at the end, not following, with no arrow.use-mobile-native-chat-page-history.tsx). The chat view stays mounted across chat tabs, so "not following", the page's last scroll offset and the start of the page's loaded-history block carried from one chat to the next. The tail-follow hook now takes the chat's identity and, when it changes, jumps to the newest message before paint. The history block's starting row is stored with the chat it belongs to. Row ids like the streaming bubble's repeat across chats, so an id alone isn't enough.MobileNativeChatScrollHold.tsx). The hold now acts only while the reader is not following. While following, auto-scroll alone places the view, as the hook's own documentation already says. The browser has its own version of the hold, scroll anchoring (overflow-anchor, on in Android's WebView), and it made the same upward correction when the oldest row was dropped. So the hold also turns browser anchoring off while following and back on when not, where it still helps keep rows steady as they render above the reader.MobileNativeChatScrollHold.tsx). The hold now picks the first message row on screen from the top, skipping the "Load earlier messages" control and the footer (live status line and queued messages). Output landing below that row never moves it.Why
key? A remount would also reset things that belong to the view, not to a chat: the Tools expand toggle and pinch-zoom text size both carry across chat tabs today. Composer drafts are owned per tab by the route, so neither option affects them. The view already scopes its other per-chat state (expanded turns) by the same chat identity instead of remounting, and this follows that.Follows up #28413.
Linked Issue
Follow-up to #28413 (merged). No separate issue.
Visual Proof
Not recorded for this draft. The behavior was measured on react-native-web 0.21.3's real list (the version the phone page uses), driven headlessly in Chromium and WebKit at a 400×700 viewport. The results, each before → after, the same in both engines:
The paging-with-big-history checks from #28413's review (rows stay on screen, every row renders on the way back down) are unchanged.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New tests, each failing on the merged code: a nudge on the page snaps back and follows; switching chats opens the new chat following; the hold does nothing (and turns browser anchoring off) while following; the hold keeps the reader's row, not the footer.
pnpm exec vitest run src/sessioninmobile/: all pass. Mobile typecheck and the tests-typecheck ratchet pass.Not run on a phone or emulator yet. iOS momentum scrolling in particular hasn't been exercised.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Mobile only. No desktop, wire or SSH change: the page is still served by the desktop as before. Native app builds change only for item 2 (a new chat opens at its newest message).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)