Skip to content

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
brennanb2025/mobile-page-keep-reading-placefrom
brennanb2025/mobile-page-follow-at-cap
Closed

brennanb2025 wants to merge 6 commits into
brennanb2025/mobile-page-keep-reading-placefrom
brennanb2025/mobile-page-follow-at-cap

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​105 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47

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:

  • New MobileNativeChatPageScroll: the page list's scroller, passed to the list as renderScrollComponent on 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. While endAnchored is true the wrapper has overflow-anchor: none, which takes its whole subtree out of the browser's anchor selection, so the end marker is what the browser anchors on.
  • The follow owner (useMobileNativeChatTailFollow) supplies that scroller with endAnchored taken from its existing following state at render. No new flag, effect, timer or scroll write; the owner gains no new trigger. It now returns listProps (ref plus renderScrollComponent) that the view spreads on the list, which keeps MobileNativeChatView.tsx at its line limit.
  • Native lists get no renderScrollComponent and 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.
  • React Native's ViewStyle type doesn't name overflowAnchor, so the one style that sets it is typed locally as ViewStyle & { 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:

  • Pin to the end on every commit or every scroll event: adds a second writer that fights the browser (the browser scrolls up, we scroll back down), can paint a frame off the end, and adds a guard to the owner for something the browser should simply not do.
  • Turn scroll anchoring off for the whole scroller all the time: also removes it while parked, where QA on fix(mobile): keep what the reader was reading when older messages load on the phone page #29170 measured the reading-place hold drifting about 4 px per "Load earlier" tap without it.
  • Exclude each row individually: restyles every rendered row on each follow toggle; one wrapper does the same with a single style change.

Differences from the common pattern, labelled:

  • Intended: no 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.
  • Intended: no anchoring toggle during short content-position holds; that serves a disclosure feature we don't have, and this PR does not change the parked state at all.
  • Intended, retained: the toggle follows the owner's following state, 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.
  • Temporary: the wrapper reaches the list through 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 (renderScrollComponent is 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Superseded by #29271, which carries this change together with the rest of the phone chat scroll work in one PR against main.

@brennanb2025
brennanb2025 deleted the brennanb2025/mobile-page-follow-at-cap branch October 19, 2026 20:54
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