Repository navigation
fix(mobile): a reader following the end of a long phone-page chat keeps up at the 2,000-message cap - #29198
Closed
brennanb2025 wants to merge 6 commits into
Conversation
…ser's scroll anchor At the 2,000-message cap a trim plus an append of the same height changes no size, so the follow owner hears nothing, and Chromium's scroll anchoring keeps a visible message still, scrolling the reader one message off the end each time. While the reader follows, the page's scroller now takes the transcript out of anchoring and leaves a 1 px end marker as the anchor. Parked readers and native lists are unchanged.
MobileNativeChatView.test.ts is at the 800-line limit for test files.
…the style augmentation names why it is an interface
… one scroll-event helper replaces the copied event literals
This was referenced Oct 15, 2026
Closed
Closed
Contributor
Author
|
Superseded by #29271, which carries this change together with the rest of the phone chat scroll work in one PR against main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On the phone's web chat page, if you sit at the bottom of a very long chat (2,000 messages, the most the page keeps) while the agent is writing, you slowly fall behind: every new message leaves the view one message further from the end, the "Scroll to latest" arrow appears, and new output lands out of sight until you tap it. After this change you stay at the end, the same as in a shorter chat.
What Changed
What a user saw (before): in a chat at the 2,000-message cap, a reader following the end on an Android phone (in-app web view) or in Chromium fell 40-64 px further behind with every new message (QA, Windows Chromium at 390×844: 64, then 128, then 192 px behind after three messages). After the first slip the page stopped following entirely. This shipped in #28413 and is on main and in 1.4.226. The phone app's native lists are not affected.
Why it happened: at the cap, each new message removes the oldest one and appends one of about the same height, so the page's total height does not change and the code that keeps the reader at the end hears nothing (correctly: nothing it watches changed). Meanwhile the browser's built-in scroll anchoring had picked a visible message to hold still. The removed row was above it, so the browser scrolled up by that row's height to keep the message in place. The page reads an upward scroll as the reader leaving (the web list reports no drag events, so it has to infer intent from offsets), so following turned off, and each later message slipped again.
What is different now: while the reader follows the end, the page tells the browser not to anchor on any message and gives it a 1 px marker at the very end to anchor on instead. A trim plus append then leaves the view exactly at the end, and if the heights differ the browser moves the view with the end rather than with a message. Once the reader scrolls up to read (parked), messages are eligible anchors again, exactly as today, so the reading-place hold from #29170 behaves as before.
Mechanism:
MobileNativeChatPageScroll: the page list's scroller, passed to the list asrenderScrollComponenton the web only. It renders the transcript inside one wrapper (which takes the list's content style, so every row's measured position is unchanged) followed by a 1 px end marker. WhileendAnchoredis true the wrapper hasoverflow-anchor: none, which takes its whole subtree out of the browser's anchor selection, so the end marker is what the browser anchors on.useMobileNativeChatTailFollow) supplies that scroller withendAnchoredtaken from its existingfollowingstate at render. No new flag, effect, timer or scroll write; the owner gains no new trigger. It now returnslistProps(refplusrenderScrollComponent) that the view spreads on the list, which keepsMobileNativeChatView.tsxat its line limit.renderScrollComponentand are untouched. On iOS WebKit, which has no scroll anchoring, the style is inert and the marker is an empty 1 px row, so behavior there is unchanged.ViewStyletype doesn't nameoverflowAnchor, so the one style that sets it is typed locally asViewStyle & { overflowAnchor: 'none' }(no global type change, no cast); React Native Web passes unknown style keys through to CSS unchanged.Why
Following the common pattern for a chat that sticks to the bottom: while stuck to the end, the content wrapper alone is excluded from scroll anchoring and a 1 px sibling after it is the anchor, toggled by the stick-to-bottom state rather than per-frame geometry.
Alternatives considered:
Differences from the common pattern, labelled:
CSS.supports('overflow-anchor')capability check. Where anchoring isn't implemented (WebKit today) the declaration does nothing and the marker is harmless, so a check would add code without changing anything a user sees.followingstate, which on the page is inferred from scroll offsets rather than explicit gestures (the web list reports none). This PR removes the browser-made upward scroll that the inference misread while following; it does not change the inference.renderScrollComponent, the list's hook for supplying its own scroller. A later change replaces the page's list with one that renders this wrapper and end marker directly, and that hook goes away then.Linked Issue
Stacked on #29170 (base branch). The regression shipped in #28413. No separate issue.
Visual Proof
Pending: real-browser QA on this head (Windows Chromium 390×844 with anchoring on and off, following through three same-height and three mixed-height trims at the cap; parked controls; iOS WebKit) will be attached here.
Testing
One contract test in
MobileNativeChatView.test.ts: a following reader at the cap has the oldest message trimmed and a new one appended with no size change; the owner makes no scroll write, no "Scroll to latest" appears, and the page's scroller holds the transcript in a wrapper excluded from anchoring with the 1 px marker last. Scrolling up makes the wrapper eligible again; "Scroll to latest" excludes it again. It fails on the base (renderScrollComponentis missing) and fails if the wrapper is always or never excluded.To fit the contract in that file under its line limit without copying its mocks, one small helper now builds the scroll events the existing tests used to spell out by hand (no test changes what it asserts); the PR's test change is net negative.
Honest limit: the test renderer has no layout or scroll anchoring, so this pins that the browser is told the right thing at the right time; the visible result comes from the real-browser QA above.
Named test files (including the reading-place flow from fix(mobile): keep what the reader was reading when older messages load on the phone page #29170) run on Windows; CI is the lint and typecheck gate.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Security: none. Cross-platform: phone web page only; Chromium-based web views get the fix, iOS WebKit is unchanged (no scroll anchoring there), native lists are untouched. Remote/SSH and mixed versions: presentation only, no RPC, stream frame, saved field or host change. Performance: one style toggle on one wrapper when following changes; no new observers or writes.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)