Skip to content

fix(ChatVirtualizer): a rotation keeps the row at the top of the view in place - #11219

Merged
cixzhang merged 4 commits into
mainfrom
lane1/chatvirtualizer-rotation-anchor
Nov 12, 2026
Merged

cixzhang merged 4 commits into
mainfrom
lane1/chatvirtualizer-rotation-anchor

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A reader on a phone, reading back through a long chat on a page that scrolls (ChatVirtualizer attached to document.scrollingElement), rotates from landscape to portrait. The view jumps about 4–5 messages ahead, so they lose their place. A device farm run on real iPhone and Pixel phones saw this at both #10879's merged head and the head Cindy passed (9:20 → 9:24/9:25 on a Pixel, 9:16/9:17 → 9:20 on an iPhone). After this change the row at the top of the view stays in place in both directions, and a list following the newest message keeps following it.

Problem and solution fit

  • Why it jumps: when a phone rotates, the browser moves the page's scrollTop itself to keep the reader's place, scaled to the new content height. The list's row heights are not measured yet at that moment.
  • Why that harms the task: the list treated that scroll event as the reader's own, re-anchored on the row under the scaled position in its old geometry (several rows further on), and the next correction pass then held that wrong row.
  • Why it matters: the list's ownership boundary is to keep the reader's row identity across size changes. Here a browser move overrode it.
  • The narrow fix: on the page scroller, a viewport change arms one restore: at the window's resize event, and once more when the viewport's correction pass reads a new height. A scroll with no finger counts as the browser's when it lands at a height that pass has not read yet, or as the first scroll while a restore is armed (within 500 ms of the resize). It uses the armed restore, and the list restores the held row from the measured heights on the next frame. The scroll event of the list's own write never spends it. Every other scroll is the reader's. Safari can write its scroll position before the resize event or after the pass, so neither ordering may decide it. A key or a pointer press (listened for in the capture phase) or a wheel disarms the restore at once, so the reader's own scroll right after a rotation is followed. A list's own scroller is unaffected: its observer entry carries its size.

Expected behavior and authority

  • component:ChatVirtualizer ownership boundary: the list owns the restored row identity.
  • FR1: browser scroll anchoring is off, so the list itself keeps the row.
  • FR4: the correction pass runs when the scroller's size changes.
  • FR2: a finger scroll still owns the position.
  • The record adds one FR4 sentence: "Rotating the device keeps the row that was at the top of the view in place, in both directions." This matches a step on Cindy's fix(ChatVirtualizer): attach mode works on the page's own scroller #10879 device card that the farm run fell short of.

Smallest restoration

  • ChatVirtualizer.tsx +84/−1 vs main, page scroller only:

    • a passive window resize listener that records the time and arms one restore;
    • the pass records the height it read, and arms one more restore when that height changed;
    • the scroll handler treats a finger-free scroll that is not the list's own echo as the browser's, either at a height the pass has not read or as the first while armed, and spends the restore on one pass on the next frame;
    • capture-phase key and pointer listeners and the wheel disarm it.

    The resize handler reads nothing, and the scroll handler adds no read.

  • No change to the scroll-anchoring writer, the finger-scroll watch, the viewport probe, or the held engine choice.

Evidence

  • Reproduction before the change: in the new ChatVirtualizerRotation.test.tsx (a jsdom layout model where the content starts at the page top, spacers are as tall as the list sets them, rows have one height that changes on rotation, and newly observed rows report their size after the next frame), the top row moves 25 rows on a rotation to portrait with a browser-scaled scrollTop, and 21 rows on the way back to landscape, and follow-at-end is lost through a rotation to landscape.
  • Result after the change: all 11 rotation tests pass. The held row's top edge stays at the top of the view (within 2 px), and follow-at-end holds.
  • Safari orderings (added after the first farm run): a late scroll write after the pass settles, and a scroll before the resize event. Both are red on the first head (3421daf) and pass here. A wheel right after a rotation is followed.
  • Farm, first head 3421daf: Pixel 8 fixed (same top message on every rotation; main about 3 per round trip). iPhone 14 still about 2 messages per round trip (main about 6). This head targets that iPhone residual; the iPhone-only re-run follows.
  • Reader input and pass budget (added after review): a key scroll right after a rotation is followed; a run of eight scripted scroll events after a rotation gets at most one list write; a scroll on the list's own scroller in the frame its height changes is followed. All three are red on the previous head (9679a83) and pass here.
  • The list's own echo (added after review): the rotation model now fires the next-frame scroll event a browser fires for the list's own write. With it, the late Safari write test fails on the previous head (f94f508) and passes here. The key test presses PageDown on a control that stops the key's propagation.
  • Safari reload on rotation: device-state, reproduces on main. Rotation steps are judged only on takes without a reload.
  • Representative unchanged path: a rotation where the browser keeps scrollTop passes before and after. A rotation while a finger scrolls writes nothing until the finger lifts (FR2), before and after. Lab Chat tests pass: 95.
  • Regression test: the three tests above fail on the previous head and pass here.
  • Real phones, this head (iPhone 14 and Pixel 8, takes without a reload): three history round trips keep the same message at the top (0 drift, 3/3); main drifts. A small scroll right after a rotation follows on both phones; main does not. After rotating at the end, the newest message stays in view on both phones (3/3 each; main on Pixel 0/3). A finger scroll after rotation follows (3/3), as on main.

Size

  • Lines vs main: 3 files, +616 / −16 (ChatVirtualizer.tsx +84/−1, ChatVirtualizerRotation.test.tsx +515, ChatVirtualizer.spec.md +17/−15: the FR4 sentence, its pass-trigger list and the verification map, mostly table re-padding).
  • App size: Lab is not a published package, so the package-size report lists no change for any published package (CI pr-analysis, 0 bytes on every package).

Scope

Components: ChatVirtualizer

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm vitest run --project ui packages/lab/src/Chat (95 pass), including the 11 rotation tests, red-first against main and against the earlier heads. Real-phone rotation is checked on the farm, on takes without a reload.

Safari reload on rotation: device-state, reproduces on main.

Writing rubric results

  • The FR4 sentence states present behavior in one clause and its reason in the next.
  • It is observable, testable, and pinned by the new verification row (audit:ChatVirtualizer/behavior).
  • The record has no history or pull request references.

… in place

A phone that rotates moves the page's scrollTop itself to keep the reader's
place, against row heights the list has not measured yet. The list read that
scroll as the reader's own and re-anchored on the row under the scaled
position, so the view advanced several rows. A window resize on the page
scroller now marks the viewport as changing, reading nothing, until the next
correction pass. A scroll event during that time is not the reader's unless a
finger scrolls, and the pass restores the held row from the measured
heights. Follow-at-end also survives a rotation.

New tests play the browser in a jsdom layout model: rotations to portrait,
with and without the scaled scroll position, back to landscape, at the end,
and under a scrolling finger. Three fail on the previous head. The record
adds the rotation sentence to FR4 and a verification row.
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 12, 2026 12:15am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 12, 2026, 12:37 AM UTC

cixzhang added a commit that referenced this pull request Nov 11, 2026
The preview page on top of the rotation fix, with an Add message button so
a phone check can see the list stay at the newest message as one arrives.
Preview only; not for merge.
@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · db6dcab

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/ChatVirtualizer 56.0 kB (+259 B) · 223 B CSS (0) — — · ✓ · ✗
lab/ChatEmojiPicker 110.3 kB (0) · 773 B CSS (0) — — · ✓ · ✓
lab/ChatReactionBar 111.4 kB (0) · 1.1 kB CSS (0) — — · ✓ · ✓
3 more components
Component Size LoC Visual · A11y · RTL
lab/ChatTypingIndicator 25.9 kB (0) · 612 B CSS (0) — — · ✓ · ✓
lab/ChatUnreadDivider 3.7 kB (0) · 348 B CSS (0) — — · ✓ · ✓
lab/Chat — — — · ✓ · —

Package size: no published package changed; no new dependencies.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3421daf

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking problems turned up in the code. Approval waits on an engineering owner deciding the record change below.

Owner decision needed: this pull request adds a new requirement to FR4 of the draft component:ChatVirtualizer record ("Rotating the device keeps the row that was at the top of the view in place, in both directions: a scroll position the browser sets itself while the viewport changes size is not the reader's scroll, and the next pass restores that row.") and a matching verification row for ChatVirtualizerRotation.test.tsx. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, or says what the requirement should state instead. The author may do this as an engineering owner.

Non-blocking suggestion:

  • The correction pass clears the new viewportResizing mark (ChatVirtualizer.tsx:948), but its live-anchor refresh (:788) never reads it. The fix therefore relies on the browser's rotation scroll event arriving before the ResizeObserver pass. With the opposite order, the same test harness still moves the top row 25 rows. Adding !viewportResizing.current && to that condition keeps the row in both orders and the Chat tests still pass. A pass-first case beside rotate() would pin it, and the real-phone run will show which order phones use.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The new FR4 rotation requirement and its verification row carry an engineering owner's approval at this head, the new rotation tests fail before the change and pass with it, and CI is green on this head.

Non-blocking suggestions:

  • A reader's own wheel, keyboard or scrollbar scroll that lands in the same frame as a window resize is now undone (ChatVirtualizer.tsx:1236); clearing viewportResizing in onWheel would keep at least the wheel case.
  • The correction pass's live-anchor refresh (ChatVirtualizer.tsx:788) does not read viewportResizing, so a reader whose last scroll was not a finger's still loses their row if the resize observer batch arrives before the rotation's scroll event; adding !viewportResizing.current && to that condition, with a pass-first test beside rotate(), would close it.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 12:23
…ze event or after the pass are not the reader's

On an iPhone the view still moved about one message per rotation. Safari can
write its scroll position before the window's resize event, or after the
correction pass that follows it, and the list read either write as the
reader's own. A scroll that no finger makes now counts as the browser's when
it lands within 500 ms of a window resize, or when the scroller's height
differs from the one the last pass read. The list then restores the held row
on the next frame. A wheel ends that time at once, so the reader's own wheel
scroll right after a rotation is followed. The resize handler still reads
nothing, and the scroll handler adds no read.

Tests model both Safari orderings and hold the row's top edge at the top of
the view; both fail on the previous head. A wheel test pins that the reader's
own scroll is not reverted. The verification row names the new states.
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 16:06
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 16:06
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 9679a83

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner deciding the record change below, and three code fixes are needed whatever that decision is.

Owner decision needed: this pull request adds a requirement to FR4 of the draft component:ChatVirtualizer record ("Rotating the device keeps the row that was at the top of the view in place, in both directions: …") and rewrites its verification row for ChatVirtualizerRotation.test.tsx; the earlier /approve-spec named the previous commit, so it no longer counts. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.

Blocking:

  • A reader's own scroll with no finger and no wheel (keyboard, scrollbar, a smooth or scripted scroll) within 500 ms of any window resize on the page scroller is undone (ChatVirtualizer.tsx:1245-1247): in Chromium, PageUp 100 ms after a width-only resize stays on message 621 instead of reaching 608, so end that window on reader input such as keydown and pointerdown, as onWheel does, and add a keyboard case beside the wheel test.
  • Each finger-free scroll in that window runs a full correction pass on the next frame (ChatVirtualizer.tsx:1256-1260), so a continuing scroll is laid out and written back every frame, against the runtime rule that a scroll path reads no layout; arm one restore per viewport change instead and name that trigger in FR4's pass list.
  • Desktop behavior change needs an owner decision: the height check (ChatVirtualizer.tsx:1248-1249) runs on every scroller under every pointer, so a mouse-wheel or trackpad scroll on a list's own scroller that lands in the frame its height changes is undone; limit it to the page scroller, gate it to touch input, or cite the decision.

Also worth a look: the earlier note on the pass-first order (ChatVirtualizer.tsx:788-803) still applies, two new comments could be shorter (inline), and the description still describes the previous commit's mechanism and test counts.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the record change is approved, and three code fixes remain.

The FR4 rotation sentence and its verification row in the draft component:ChatVirtualizer record carry an engineering owner's approval at this head, so the record change is settled.

Blocking:

  • A reader's own scroll with no finger and no wheel (PageUp, Space, arrow keys, a scrollbar drag, a scripted scroll) within 500 ms of any window resize on the page scroller is put back (ChatVirtualizer.tsx:1245-1247), so end that window on reader input such as keydown and pointerdown, as onWheel does, and add a keyboard case beside the wheel test.
  • Each finger-free scroll in that window arms a full measuring pass for the next frame (ChatVirtualizer.tsx:1256-1260), so a continuing scroll is laid out and written back every frame against the runtime rule that a scroll path reads layout once per change, not per frame; restore with one scroll write from the stored geometry instead, and name that restore in FR4's pass list.
  • Desktop behavior change needs an owner decision: the rule runs under every pointer and its height check on every scroller (ChatVirtualizer.tsx:1248-1249), so on desktop a mouse-wheel or trackpad step in the frame a scroller's height changes, and a scrollbar drag right after a window resize, are put back; gate the rule to touch input, or cite the owner decision that covers it.

Also worth a look: the live-anchor refresh (ChatVirtualizer.tsx:788-803) can still re-anchor on the browser's scaled position when its scroll event arrives after the observer's pass, and two new comments could be shorter.

Claims and files checked
  • Claim: a rotation on the page scroller keeps the top row in place in both directions — verified for the browser's own rotation scroll (rotation tests green in CI; Chromium phone emulation holds the same message); no real-phone result for this head.
  • Claim: a finger-free scroll counts as the browser's within 500 ms of a window resize on the page scroller or at a changed scroller height — verified (ChatVirtualizer.tsx:1245-1249); the height half also runs on a list's own scroller.
  • Claim: a wheel ends that time at once — verified (ChatVirtualizer.tsx:1379); the height check still applies to a wheel.
  • Claim: the resize handler reads nothing and the scroll handler adds no read — verified for the handlers (ChatVirtualizer.tsx:1399-1401, :1245-1249); the pass they arm reads layout (second blocking finding).
  • Claim: the scroll-anchoring writer, finger-scroll watch, viewport probe and engine choice are unchanged — verified.
  • Claim: the record adds one FR4 sentence and a verification row — verified (ChatVirtualizer.spec.md:93, :128, :16).
  • Claim: before the change the top row jumps 25 and 21 rows and follow-at-end is lost in the test model — consistent with the base scroll handler; not rerun.
  • Claim: all 8 rotation tests and the Lab Chat tests pass — verified through the green UI test shards for this head.
  • Claim: a rotation where the browser keeps the scroll position, and one during a finger scroll, behave the same before and after — consistent with the code.
  • Claim: the Safari-order tests fail on the previous head — not checked.
  • Claim: 3 files, +484/−16, no published package size change — verified (Lab is private).
  • Claim: no new interaction model under the bug-fix label — false for the reader's own scrolls within 500 ms of a resize (blocking findings).
  • Claim: no internal context in public text — verified.
  • File docs/specs/components/Chat/ChatVirtualizer.spec.md — clear; FR4's pass list should name the new restore (second blocking finding).
  • File packages/lab/src/Chat/ChatVirtualizer.tsx — three blocking findings, plus two comment-style notes and the pass-first note.
  • File packages/lab/src/Chat/ChatVirtualizerRotation.test.tsx — no keyboard or scripted-scroll case in the resize window; otherwise clear.

Automated review (maintainer link)

… and the reader's scroll is followed

The previous head treated every scroll with no finger for 500 ms after a
window resize as the browser's, and scheduled a correction pass for each.
A reader's PageDown or scrollbar drag in that time was undone, a scripted
smooth scroll was written back every frame, and the height check also ran
on a list's own scroller.

Now a viewport change on the page scroller arms one restore: at the resize
event, and again when the viewport's pass reads a new height. A scroll at a
height that pass has not read, or the first one while a restore is armed,
is the browser's and uses it; every other scroll is the reader's. A key,
a pointer press or a wheel disarms it at once. A list's own scroller is
untouched, since its observer entry carries its size. FR4 names the new
pass trigger.

Tests: a key scroll right after a rotation is followed, a run of eight
scripted scroll events gets at most one list write, and a scroll on the
list's own scroller as its height changes is followed. All three fail on
the previous head.
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 23:18
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 23:18
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec f94f508

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the rotation restore holds the reader's row for the browser's own scroll before the pass and follows the reader's key, pointer and wheel input, and two fixes remain.

Blocking:

  • The list's own scroll echo spends the restore meant for a browser write after the pass (ChatVirtualizer.tsx:1255-1274), so in Chromium a finger-free 125 px scroll about 360 ms after a rotation moves the held message off the top, and the rotation test misses it because its scrollTop setter fires no scroll event for the list's writes (ChatVirtualizerRotation.test.tsx:104-109); excluding that echo from isViewportMove and firing the event in the test fixes both.
  • The description says ChatVirtualizer.tsx changes by +47/−1 and by +77/−1 and that the resize listener only records the time, but the file changes by +76/−1 and the listener also arms the restore.

Non-blocking: the keydown and pointerdown listeners could listen in the capture phase, so a key whose handler stops propagation still ends the restore, and the comment at ChatVirtualizer.tsx:1252-1254 reads better as two short sentences. CI's test check is red only because a node-test shard that does not run Lab code hit its 15-minute limit; a re-run should clear it.

Claims and files checked
  • Rotation on a phone used to jump several messages on real phones: author-reported device result; consistent with the code, since Chromium itself moves the page's scroll position by about 1,100 px on a rotation and the base treats that as the reader's scroll.
  • After the change the top row stays in place in both directions: verified in Chromium for the browser's scroll before the pass, both directions; false for a browser scroll after the pass (first blocking finding).
  • Follow-at-end survives a rotation: verified by the rotation test, which passes in CI.
  • A viewport change arms one restore at the resize event and again when the pass reads a new height: verified (ChatVirtualizer.tsx:781-789, :1423-1426).
  • A finger-free scroll counts as the browser's at an unread height, or as the first scroll while armed within 500 ms: verified (:1255-1261); the first such scroll after the pass is usually the list's own echo (first blocking finding).
  • A key, pointer press or wheel ends the restore at once: verified (:1390-1408); a PageDown right after a rotation is followed in Chromium.
  • A list's own scroller is unaffected: verified (the rule is gated to the page scroller, :1420); the own-scroller test passes in CI.
  • The file changes by +47/−1 and the resize listener only records the time: false (+76/−1; the listener also arms the restore).
  • The resize handler reads nothing and the scroll handler adds no read: verified.
  • No change to the scroll-anchoring writer, the finger-scroll watch, the viewport probe or the engine choice: verified from the diff.
  • The new rotation tests fail before the change (top row moves 25 and 21 rows, follow-at-end lost): not run here; consistent with the base scroll handler by reading.
  • All 11 rotation tests pass, the held row's top edge stays within 2 px: verified (CI unit tests; the test's 2 px check).
  • The Safari-order tests fail on the first head and pass here: pass verified in CI; the first-head run was not repeated.
  • The key, scroll-run and own-scroller tests fail on the previous head and pass here: pass verified in CI; the previous head lacks the key disarm, runs a pass per scroll and checks the height on every scroller, so they fail there by reading.
  • Device results on the first head, and the Safari reload rate on rotation: author-reported device results.
  • Heap, DOM node count and mounted rows match main in headless Chrome: not checked here.
  • Unchanged paths (a rotation where the browser keeps the position; a rotation while a finger scrolls) pass before and after: pass at this head verified in CI; the base run was not repeated.
  • The Lab Chat tests pass (95): not counted here; the three ChatVirtualizer test files (49 tests) pass in CI.
  • Three files, +591/−16, the test file +498: verified; the component's +77/−1 is false (+76/−1).
  • No published package changes size and no public API, default or interaction model is added: verified (Lab is private; props and handle unchanged).
  • The record sentence states present behavior, is pinned by its verification row and carries no history: verified (record FR4 and its verification row).
  • docs/specs/components/Chat/ChatVirtualizer.spec.md: clear; the FR4 trigger, sentence and verification row carry an engineering owner's approval at this head.
  • packages/lab/src/Chat/ChatVirtualizer.tsx: first blocking finding; non-blocking listener phase and comment notes.
  • packages/lab/src/Chat/ChatVirtualizerRotation.test.tsx: first blocking finding (its scroll model fires no event for the list's writes); otherwise consistent with the record's verification row.

Automated review (maintainer link)

…rowser's restore

The scroll event a browser fires for the list's own restore write was the
first finger-free scroll while a restore was armed, so it spent the restore.
A browser scroll write that landed after the pass then counted as the
reader's and moved the held row off the top. The list's own echo now never
counts as a viewport move.

The key and pointer listeners that disarm the restore listen in the capture
phase, so a key whose handler stops its propagation still disarms it. They
are added only on the page scroller, where a restore can be armed.

Tests: the rotation model's scrollTop setter fires the next-frame scroll
event a browser fires for the list's own write. With it, the late Safari
write test fails on the previous head and passes here. The key test presses
PageDown on a control that stops the key's propagation.
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 00:08
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec db6dcab

@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 00:09

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: a few CI jobs have not finished on this head yet.

The rotation restore now keeps the late browser scroll it exists for: the list's own scroll echo no longer spends it, and the key and pointer listeners that end it run in the capture phase on the page scroller only. The FR4 changes carry an engineering owner's approval at this head, the rotation tests pass in CI, and on this head's Storybook in Chromium a finger-free scroll 250 ms after a rotation is put back while a key press or wheel right after a rotation is followed. Two non-blocking notes are inline: the pass-first anchor refresh, and one comment sentence over the 25-word limit.

Claims and files checked
  • Phones lost their place on rotation in a page-scrolling chat, and keep it after the change: the before is the author's device report; the after holds in this head's rotation tests and in Chromium (within 1 px over a round trip).
  • The browser moves the page's scroll position on rotation and the list took that as the reader's scroll: verified by reading the base scroll handler, which re-anchors on any scroll that is not its own write.
  • A window resize and a pass that reads a new height each arm one restore: verified, ChatVirtualizer.tsx:781-789 and :1431-1435.
  • A finger-free scroll at an unread height, or the first one while armed within 500 ms, is the browser's and is restored on the next frame: verified, :1255-1276.
  • The scroll event of the list's own write never spends the restore: verified, :1255-1260, and in Chromium.
  • A key or pointer press (capture phase) or a wheel ends the restore: verified, :1391-1399, :1416-1427, and in Chromium with a control that stops the key's propagation.
  • A list on its own scroller is unaffected: verified, the page-scroller gate at :1258 and the listeners added only with the viewport probe.
  • The record adds the FR4 rotation sentence, its pass trigger and a verification row: verified, ChatVirtualizer.spec.md:93, :128 (the description quotes the sentence's first clause).
  • ChatVirtualizer.tsx +84/−1, and 3 files +616/−16 in total: verified against the diff.
  • The resize handler reads nothing and the scroll handler adds no layout read: verified.
  • No change to the scroll-anchoring writer, the finger-scroll watch or the viewport probe: verified.
  • All 11 rotation tests pass, with the held row within 2 px: verified in CI and in the test's own check.
  • The new tests fail on the base and on the earlier heads: not rerun here (the local install failed); the late-write and stopped-key cases fail on the previous head by reading.
  • Device farm results, the Safari reload rates and the headless Chrome memory check: the author's report, stated in text.
  • 95 Lab Chat tests pass: not rerun here; CI runs the three ChatVirtualizer test files green (31, 7, 11).
  • No published package changes size, and no public API changes: verified, Lab is private and CI's analysis lists no row.
  • The record carries no history or pull request references: verified.
  • The rotation step matches an earlier pull request's device checklist: context outside this repository, not checked.
  • docs/specs/components/Chat/ChatVirtualizer.spec.md: clear.
  • packages/lab/src/Chat/ChatVirtualizer.tsx: clear; two non-blocking notes.
  • packages/lab/src/Chat/ChatVirtualizerRotation.test.tsx: clear.

Automated review (maintainer link)

vp.clientHeight !== passViewportHeight.current
) {
// A browser scroll write can still follow this viewport pass.
isRestoreArmed.current = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this pass arms the restore, but the live-anchor refresh below (:795-810) still re-derives the anchor from the live scrollTop while userScrolledRef is true. If the browser moves the page during the resize frame's layout and its scroll event dispatches after this pass, the pass anchors on the scaled position before onScroll sees it. Chromium dispatched its move at the resize, so this was not observed. Clearing userScrolledRef in onViewportResize (it still reads nothing) keeps the stored row in that order.

Comment on lines +1252 to +1253
// The browser writes its scroll for a viewport change before that
// change's pass, at a height the pass has not read, or once soon after it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (comment style): this sentence has 26 words, over the 25-word limit for a description. Suggested:

// The browser's scroll for a viewport change lands before that change's
// pass, at a height the pass has not read, or once soon after.

@cixzhang
cixzhang merged commit 3fed77b into main Nov 12, 2026
123 checks passed
@github-actions
github-actions Bot deleted the lane1/chatvirtualizer-rotation-anchor branch November 12, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — db6dcabd Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant