Skip to content

feat(core): useFingerScroll tells its caller when a finger's scroll ends - #10172

Merged
cixzhang merged 4 commits into
mainfrom
feat/finger-scroll-end
Nov 6, 2026
Merged

cixzhang merged 4 commits into
mainfrom
feat/finger-scroll-end

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

User impact

No change anyone sees today. This lets Lab's ChatVirtualizer use Core's finger-scroll watch instead of its own touch listeners and settle clock, so a phone user scrolling a long chat transcript gets the same "is this the finger's scroll?" answer as every other touch component.

What changes

  • End signal: useFingerScroll(scroller, {onEnd}), an internal hook, takes an optional onEnd. It runs once each time a finger's scroll on the scroller ends, after the reader already says false:
    • the scroller's scrollend after the lift;
    • the lift, when the scroll ended under a resting finger;
    • the 150 ms quiet fallback, where the browser fires no scrollend;
    • the primary pointer turning fine.
  • Additive: unmounting or a changed scroller never calls onEnd, and the reader is unchanged.
  • One listener per watcher: each watcher of a scroller gets its own call. The latest onEnd is read through a ref written at commit.
  • Internal export: @astryxdesign/core/internal/touch re-exports useFingerScroll for Lab's ChatVirtualizer. Internal entries are outside the public API (architecture:public-component-api INV24), and the hook stays out of the package entry and the gestures barrel.

Authority

  • Shape: Motion & Gestures approved it (internal re-export plus additive onEnd, firing exactly when the reader turns false, never on unmount).
  • Record: architecture:react-component-runtime gains one line naming the export and the end signal.

Verification

  • useFingerScroll.test.tsx adds 6 onEnd cases: scrollend after the lift (reader already false, one call), lift after a scrollend under a resting finger, the quiet fallback (with jsdom's onscrollend removed for that test), the pointer turning fine, two watchers getting one call each per scroll, and no call on unmount mid-scroll.
  • touch.test.ts checks the new re-export. touch-support-bundle.test.mjs lists it as a Lab-only name.
  • Gestures, internal touch, TabBar and NavigationBar suites pass (847). Strict lint, the core type check, check-knowledge and check:changesets pass.

Scope

  • One change: the end signal and its internal re-export.
  • Changeset: [chore] internal.
  • Public text contains no internal Meta context.

`useFingerScroll(scroller, {onEnd})` calls `onEnd` once each time a
finger's scroll on the scroller ends — its scrollend after the lift, the
lift after a scrollend under a resting finger, the quiet fallback, or the
pointer turning fine — after the reader already says false. Unmounting
never calls it. The internal touch entry re-exports the hook for Lab's
ChatVirtualizer, which will drop its own touch listeners for it.
@vercel

vercel Bot commented Nov 5, 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 6, 2026 4:56am UTC

Request Review

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

astracat-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 6, 2026, 5:01 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 91098f1

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
lab/NavigationScreen 74.9 kB (0) · 1.1 kB CSS (0) —
lab/NavigationStack 74.9 kB (0) · 1.1 kB CSS (0) —

Package size: @astryxdesign/core 6.68 MB packed (+1.4 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 19 rows, core 21 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec bd5fcfd

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 5, 2026

@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: CI has not run on this head yet, because draft pull requests skip it; it runs once the pull request is marked ready for review.

The onEnd end signal and the internal re-export match the architecture:react-component-runtime INV13 sentence approved for this head, and the new tests fail without the change and pass with it.

  • Non-blocking: the endFingerScroll comment in fingerScroll.ts packs two topics into one 29-word sentence; see the inline suggestion.

[Automated review]

Comment on lines +51 to +55
/**
* A scroller's finger scroll is over: it stops counting as the finger's, and
* then its end listeners hear of it, so a listener that reads
* isFingerScroll already reads false.
*/

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 is one 29-word sentence with two topics. A shorter version that keeps the ordering invariant:

/**
 * Ends a scroller's finger scroll. The scroller leaves the finger set before
 * its end listeners run, so a listener that reads isFingerScroll reads false.
 */

@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 01:19
cixzhang added a commit to yyq1025/astryx that referenced this pull request Nov 6, 2026
…t off the log, Core's shared touch and anchoring

- Keyboard users reach and scroll the list's own scroller, a `group` named
  by its new `label` prop (default "Messages"), through Core's
  useScrollableArea; a row holding focus stays mounted while the window
  moves away from it.
- Rows the window mounts over history, or history loaded above, mark the
  content block `aria-busy` for that commit and the next frame, so the
  transcript's log does not read them out as new; tail appends stay news.
- The touch write-gate follows Core's useFingerScroll (and its onEnd) in
  place of the list's own touch listeners and settle clock.
- Scroll anchoring goes off through Core's scroll-anchoring writer instead
  of a copied rule and a hand-written private attribute.
- `apiRef` is `handleRef`, as in Core components; static styles move to
  StyleX; the docs limit the spacer-height wording to touch gestures.
- A draft component record holds the ownership lines and the verification
  map, with the screen-reader evidence gap for aria-busy.

Depends on the Core changes in meta#10172 and meta#10173.
…hic layout effect

Core hooks write commit-time refs with useIsomorphicLayoutEffect, which
stays quiet under server rendering.
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec fc42cd8

@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: the heavy suites (build, test, docsite-test) are deferred on this push and run before merge; typecheck, lint and the CLI smoke test pass.

The onEnd end signal and the internal useFingerScroll re-export match the architecture:react-component-runtime INV13 sentence approved for this head, and the new onEnd tests fail without the change and pass with it. Writing the latest onEnd through useIsomorphicLayoutEffect matches how Core's other gesture hooks keep their latest callback.

  • Non-blocking: the earlier comment-style suggestion on endFingerScroll in fingerScroll.ts still applies.

[Automated review]

…s not have

The changeset, the internal touch entry, the gestures README and the
tests say Lab components that watch a finger's scroll, instead of naming
ChatVirtualizer, which is still in an open pull request. Text only.
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 6, 2026
@cixzhang
cixzhang marked this pull request as draft November 6, 2026 02:22
@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 02:22
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 07b5ac2

@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: CI has not run on this head yet; every CI, lint and smoke-test job was skipped on this push, and the full suites still need to run before merge.

The onEnd end signal and the internal useFingerScroll re-export match the architecture:react-component-runtime INV13 sentence approved for this head, and the new onEnd tests fail without the change and pass with it. The changeset, README and entry comment now describe the re-export's readers without naming a Lab component that is not on main yet.

  • Non-blocking: the earlier comment-style suggestion on endFingerScroll in fingerScroll.ts still applies.

[Automated review]

vjeux added a commit to vjeux/astryx that referenced this pull request Nov 6, 2026
Both are open: meta#10191 moves NavigationStack's large title into the scroll area's content, and meta#10172 lets useFingerScroll tell its caller when a finger's scroll ends. They share no file.
@cixzhang
cixzhang marked this pull request as draft November 6, 2026 04:04
@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 04:04
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 91098f1

@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: the heavy suites (build, test, docsite-test) are deferred on this push and still need to run before merge.

The onEnd end signal and the internal useFingerScroll re-export match the architecture:react-component-runtime INV13 sentence approved for this head, and the six new onEnd tests pass on it. Merging main left the change itself as it was.

  • Non-blocking: the earlier comment-style suggestion on endFingerScroll in fingerScroll.ts still applies.

[Automated review]

@cixzhang
cixzhang marked this pull request as draft November 6, 2026 05:19
@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 05:19
@cixzhang
cixzhang merged commit f5cf9a5 into main Nov 6, 2026
114 of 118 checks passed
cixzhang added a commit to vjeux/astryx that referenced this pull request Nov 6, 2026
@github-actions
github-actions Bot deleted the feat/finger-scroll-end branch November 6, 2026 06:04
cixzhang added a commit that referenced this pull request Nov 6, 2026
#8396)

* feat(core): useFingerScroll tells its caller when a finger's scroll ends

`useFingerScroll(scroller, {onEnd})` calls `onEnd` once each time a
finger's scroll on the scroller ends — its scrollend after the lift, the
lift after a scrollend under a resting finger, the quiet fallback, or the
pointer turning fine — after the reader already says false. Unmounting
never calls it. The internal touch entry re-exports the hook for Lab's
ChatVirtualizer, which will drop its own touch listeners for it.

* fix(lab): NavigationStack re-measures a screen when its title resizes

The large title sat outside the scroll area's content root, so a change
of its height alone, such as a longer title, re-measured nothing. A
screen that then overflowed stayed clipped: it did not scroll, offered
no keyboard stop and contained no overscroll until another change
re-measured it. The title is now first in the content root, whose size
the scroll area watches.

The headers of navigationTransition.ts and the browser spec keep their
fields only. The transition's layer notes move to the JSDoc of the type
and function they describe.

* fix(core): useFingerScroll keeps the latest onEnd through the isomorphic layout effect

Core hooks write commit-time refs with useIsomorphicLayoutEffect, which
stays quiet under server rendering.

* docs(core): the finger-scroll re-export names no reader that main does not have

The changeset, the internal touch entry, the gestures README and the
tests say Lab components that watch a finger's scroll, instead of naming
ChatVirtualizer, which is still in an open pull request. Text only.

* Merge #10172 into #10191 as this change's base

Both are open: #10191 moves NavigationStack's large title into the scroll area's content, and #10172 lets useFingerScroll tell its caller when a finger's scroll ends. They share no file.

* feat(lab): under a finger, NavigationStack's bar takes the iOS 26 look

Under a finger, NavigationStack's bars paint no background and no
hairline, as iOS 26's do. Each screen carries a scroll edge effect: a
veil of the body colour that fades in once its content has moved 10px
under the bar, on UIKit's measured springs. A push, a pop and a back
swipe carry each screen's veil with its card, and the bar a card covers
is cut at that card's leading edge. A mouse keeps opaque bars.

The veil and the UIKit bar constants live in Lab. The veil reads Core's
finger-scroll hook, with its end call, and Core's internal touch entry
also names the gesture host and the coarse-pointer check: export-only
additions, with no change to Core's behavior.

* Merge main into the NavigationStack clear bars branch (#10172 and #10191 landed)

* test(lab): NavigationStack's cut specs read the push at held times

Under load, WebKit can report one moving layer's animated translate a
frame late. The old mid-flight read then put the cut 2 to 3 px off the
card's edge while the layers moved as one. The two cut specs now freeze
the scene while the push runs, move every animation of the push to the
same scene times, and read the rendered boxes there.

* Merge branch 'main' into uikit/c16-stack-bar

Co-authored-by: Cindy Zhang <[email protected]>
cixzhang added a commit that referenced this pull request Nov 9, 2026
* feat(lab): experimental ChatVirtualizer with a virtualized transcript story

Adds a windowing participant for ChatMessageList children: ChatLayout
keeps the scroller, ChatMessageList keeps its shell semantics, and the
lab ChatVirtualizer renders only the rows near the viewport between two
document-flow spacers. It owns follow-at-end (displacement-based
disengage, position-based re-engage, declarative jumps) and
read-position stability (identity anchoring while scrolled up), with
per-type running size estimates behind hysteresis.

The story pairs a virtualized and an unvirtualized arm over the same
corpus and controls: streaming a reply with 3000 messages mounted
measures ~8fps unvirtualized vs the machine's full frame rate
virtualized with ~17 rows in the DOM (the status pill shows both live).

Related: #4102, #2282, #3942.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(lab): expose endThreshold as a story control

The re-engage threshold maps directly to the follow-semantics
discussion in the PR: at 1px (TanStack Virtual's default) stopping
visually at the bottom often leaves follow silently disengaged while a
stream grows below; the control makes that reproducible in 30 seconds.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(lab): streamSpeed story control (relaxed/default/fast)

Fast chunk cadence is the stress case for follow ownership —
disengage mid-stream, scroll back, re-engage — so make it a control
instead of a fixed 25ms.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(lab): static source for the ChatVirtualization docs panel

'Show code' defaults to the dynamic snippet, which serializes the
rendered element tree — at messageCount=3000 that walk freezes the
docs panel. docs.source.type='code' renders the story source instead
(4KB, instant).

Co-Authored-By: Claude Fable 5 <[email protected]>

* storybook: split the two arms into two stories, add startAtTop

The virtualized/unvirtualized comparison becomes a story switch instead of
a control that turns the subject off: "Thousands of Messages" keeps the
virtualizer controls, "Unvirtualized Baseline" carries only the shared
corpus/stream controls. startAtTop demos the anchorToKey half of the
imperative API (log-reading mode: open at the first row, stream grows
below without moving the viewport).

* ci: retrigger preview deploy after the gh-pages reset

* feat(lab): hold scrollTop during touch gestures, absorb corrections in the spacer

The follow and anchoring machinery was measured against wheel gestures and
programmatic scrolls. Touch produces scroll events with no wheel event
anywhere, and that input class had three defects living in it, found by
hand-testing the preview on a phone.

Slow drags off the bottom deadlocked: re-engage is a position test, disengage
a displacement test, and per-event restores erased the displacement faster
than a slow drag could accumulate it — 599 of 600 frames reverted, 8px of
4800 travelled, identical in Blink and WebKit. Where momentum belongs to the
scroll view (iOS WebKit, Android) a programmatic write also cancels the
fling, so a flick stopped after about two messages. And with writes withheld,
rows mounting above the viewport landed their (real − estimate) delta in the
geometry and the content crawled under the finger.

So while a touch gesture owns the viewport — finger down, plus the settle
window after lift-off — the machinery writes no scrollTop at all. The
correction it would have written goes into the top spacer instead, and
paintOrigin() converts between painted space and model space so the two can
never be mixed. Rows in normal document flow are what make that possible: the
spacer is a second knob, where a transform-positioned virtualizer has only
scrollTop, which is exactly the thing a gesture forbids. Nothing is deferred
into a ledger, so nothing stale can replay — the flush is one ordinary sync
from the re-stated mode.

That restatement is unconditional, because it also hands the adjustment back:
anchorAt reads through paintOrigin, so the carried adjustment folds into the
stored viewportOffset and zeroing it leaves a single balancing write in the
same task. Whether the gesture moved decides only the semantics — a real
scroll re-judges follow against the bottom edge, a plain tap keeps the mode it
had, and "moved" counts only non-echo scrolls so a browser clamp cannot
masquerade as intent.

No platform sniffing: where momentum survives a write there are touch events
to gate on, and where it does not (a macOS trackpad, whose momentum arrives as
wheel events) this path never runs. Settling is scroll silence plus an
elastic-overscroll guard, polled; only the last finger off the glass starts
it.

Measured on this story, 40000px of touch travel: 0 pushbacks, 0 drift events,
1px flush shift, 0px on a tap. Four tests pin the state machine (both the gate
and the multi-touch guard fail the suite when reverted). The story's wrapper
moves to dvh, which mobile Safari needs to stop the page rubber-banding under
the list.

* fix(lab): read the gesture reference frame from paint, and converge on a head change

Two defects found by hand-testing the preview on a phone.

Releasing the finger moved the page. paintOrigin() — and so anchorAt, targetFor
and computeWindow — assume painted == model + gestureAdj. At the very top there
is nothing above to absorb a negative adjustment into, so the spacer stops at 0
while gestureAdj keeps its full value, and the flush then restates the frame
from a map the screen no longer shares. anchorFromPaint reads viewportOffset off
a rendered row's rect instead; anchorAt already computes that same quantity
(offsets[idx] - y IS the painted top), so this only stops assuming the map holds.
A drag ending at the top moved 182px on release before and 0px after, while
mid-history the scroll still travels (435px, 1218px) with the picture at 0-1px.

Loading older history hijacked the anchor. The live-anchor refresh fired in the
middle of an unfinished correction and froze the intermediate position, after
which the list held the wrong row faithfully — 7 runs in 12, permanently. A page
of history is a correction the size of the page, paid over several passes as
those rows measure in; converging is already the state for "a correction is in
flight, do not re-derive", it was simply never set for a data change. 7/12 -> 0/12,
and every gesture path already clears converging so it cannot wedge.

Adds the contract halves jsdom can hold: a prepend re-indexes rows without
renumbering their keys, and a gesture that ends with nothing rendered falls back
rather than throwing.

* feat(lab): load-older-history control in the story, and an estimate contract

The story could demo streaming and follow but had no way to prepend, so the one
question a reviewer is most likely to ask — what happens to my reading position
when older messages load — could not be answered by pressing anything. Adds a
'Load 300 older' button that inserts a page with ids of its own, never a
renumbering of the messages already on screen.

Measured through it, at scrollTop 0 with the page inserted above: the anchored
row holds to within 40-60px, reproducibly. That is a real residual and smaller
than a row, not the row-sized slip this used to be; it is larger than the 0px
the same case measures on a lighter corpus, because these rows measure in later
than the compensation pass that reads them.

Also documents the estimatedItemSize bias, which is the one setting that can
make a drag look broken: too small and content grows as it measures, extending
the scroll range below you and leaving your position valid; too large and it
shrinks, and the browser clamps scrollTop into a range that just got smaller,
which nothing can undo.

* fix(lab): take the repricing decision once per pass, not per row

The size-average repricing decision lived inside effectiveAvg, which runs once
per row inside recompute's O(N) loop, and one of its gates is a clock reading.
A loop long enough to straddle the instant that gate opens repriced the tail of
the list and not the head: the pass published a geometry that was internally
inconsistent, restored scrollTop against it, and consumed geoChanged — so the
next pass, the one holding the consistent geometry and the correct target, found
the flag clear and never wrote. The landing was left short, permanently.

The odds scale with loop length and the gate re-crosses its threshold after
every gesture, so this is a size-amplified race rather than a large-list-only
bug. Measured upstream of this port on the same engine at 100k rows: a declared
jump landed up to 698,000px short in 25-50% of runs, 5/20 -> 0/17 after the fix,
with the smaller corpora unchanged at 0px on every axis.

repriceBuckets now takes the decision before the rebuild, from a single clock
reading, and effectiveAvg becomes a pure read — a pass always prices every row
from one set of numbers. priceFreeze additionally holds prices still while a
declared target is in flight and gives the release a frame of its own, so the
correction the averages owe is derived from a settled geometry instead of being
appended to the pass that just landed.

* fix(lab): the RO fallback measured a different box than the sync path

Both writers feed one size cache, and in 'ro' mode both actually run: a
row's first measurement comes from the sync pass's offsetHeight backstop,
every later one from the observer. contentRect is the CONTENT box, so on
a browser without borderBoxSize a padded row was cached short by its
padding and border, for as long as the fallback stayed the writer.

Fall back to offsetHeight on the observed element instead — the same box,
read off the same node as the sync path, so the two agree by construction
rather than by browser support.

* docs(lab): document ChatVirtualizer

The only component in the Chat directory without a doc, so the props that
carry a real contract — bias the estimate low, spacing lives inside the
row, pass the scroll container as an element — were readable only from the
source.

The scrollElement entry states why it takes an element rather than a ref:
a parent's ref attaches after its children's layout effects, so a ref
still reads null on the commit that first needs the scroller, and a ref
write is invisible to React, while an element held in state makes the
container's arrival a render and a real dependency.

No keywords field: family fields are inherited from the parent Chat doc,
and setting keywords here would replace that list rather than extend it.

* fix(lab): a head-change convergence let go of the anchor too early

Reaching the restore target does not end a head-change convergence. The
rows that arrived above are still measuring in, so the prices and the
offsets keep moving for several more passes — which is why the prices were
already held one pass longer, on a release of their own. The anchor half
was dropped on the spot instead, and in that gap the live-anchor refresh
re-derives from a scrollTop still mid-settle and freezes the intermediate
position as the new reference frame. Permanently: nothing later disagrees
with a stored anchor.

Both halves now lift on the same later pass, the one that sees the settled
numbers.

Measured on the virtualized story, reading at the top and pressing "Load
300 older": every visible row moved together by 33-53px and stayed there,
across every run. After: 0.1px, over five runs at the top and two in
mid-history, with follow-at-end and post-prepend scrolling unaffected.

No unit test: the defect lives in the window where the DOM has laid out
new rows at their real heights while the geometry still carries their
estimates, and jsdom has no layout to disagree with. The story is the
reproduction.

* Merge remote-tracking branch 'upstream/main' into chat-virtualizer-story

* fix(lab): ChatVirtualizer judges the reader by position, owns its scroller

Four carry-overs from the review of #5678, where the same ownership
questions were settled for useChatStreamScroll:

- A wheel no longer disengages follow by itself. One this scroller never
  consumes — over a nested scroller with room above, over one with
  `overscroll-behavior: contain`, an overscroll at the bottom — moves
  nothing here, and unpinning on it stranded the reader off the tail.
- The reader's displacement is measured from the position the list last
  WROTE, not from the last scroll event seen. A wheel between two writes
  coalesces with the next write into one event carrying the net, and
  against the previous event that net could read as "moved down".
- A non-echo scroll that lands exactly on the bottom is not displacement:
  with native anchoring off, that is the browser clamping onto a smaller
  bottom after a shrink no commit announced.
- Native anchoring is switched off through `data-astryx-chat-virtualized`
  and one injected rule (the highlightRanges pattern), never the inline
  style: in attach mode the scroller is the caller's, and their own
  `overflow-anchor` is neither read, written nor restored.

The story now runs the virtualizer in own-container mode inside a shell
of its own — ChatMessageList for the log semantics, the composer in a
dock — instead of attaching to ChatLayout's scroller. ChatLayout runs its
own follow on that scroller with no way to hand it off, and a position
with two writers is a position nobody owns. Attach mode stays for hosts
whose scroller has no follow of its own; the baseline story keeps
ChatLayout as the control.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(lab): ChatVirtualizer floors its extent, resets geometry on detach

React commits a window shift children-first: rows are removed before
any spacer or parent style changes, and useInsertionEffect runs only
after the whole subtree has mutated. A row whose unmount reads layout
saw the extent without the removed rows, the browser clamped scrollTop
and the live-anchor refresh adopted it (2381-2617px short, Chromium
and Firefox). Spacers and rows now sit in one content block whose
min-height is the modelled extent, written only by the correction
pass, so the previous extent holds through the commit. The insertion
effect is gone. Attach mode renders that block instead of a fragment.

Own-container mode now resets the attach-mode origin/below geometry;
switching back from scrollElement kept the host's offsets and aimed
every follow target past the end of the list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Merge remote-tracking branch 'upstream/main' into chat-virtualizer-story

* chore(registry): lock the ChatVirtualizer shadcn route

The route lock landed on main after this branch last synced, so the
new lab component was missing from it. Regenerated with
UPDATE_SHADCN_ROUTE_LOCK=1; the only change is the new entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(lab): file ChatVirtualizer under Chat, title its story by name

The docsite now requires every lab Chat* doc to carry group and
category 'Chat', and the PR accessibility scope maps stories to
components by title, which 'Lab/ChatVirtualization' did not match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(lab): ChatVirtualizer attach mode names a follow-free host

The scrollElement JSDoc pointed callers at ChatLayout's scroller, the
one host that cannot work today: ChatLayout runs its own follow on
that element with no way to turn it off, so attaching there puts two
writers on one position. The example is now a scroller with no follow
of its own, and the doc says ChatLayout cannot host attach mode until
it exposes a seam to disable that follow. Comments that named
ChatLayout as the host follow suit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Merge main into chat-virtualizer-story

Resolves the generated route lists (the union of both sides' entries, in generator format) and refreshes any generated goldens; no other change.

* fix(lab): ChatVirtualizer review round — keyboard access, history kept off the log, Core's shared touch and anchoring

- Keyboard users reach and scroll the list's own scroller, a `group` named
  by its new `label` prop (default "Messages"), through Core's
  useScrollableArea; a row holding focus stays mounted while the window
  moves away from it.
- Rows the window mounts over history, or history loaded above, mark the
  content block `aria-busy` for that commit and the next frame, so the
  transcript's log does not read them out as new; tail appends stay news.
- The touch write-gate follows Core's useFingerScroll (and its onEnd) in
  place of the list's own touch listeners and settle clock.
- Scroll anchoring goes off through Core's scroll-anchoring writer instead
  of a copied rule and a hand-written private attribute.
- `apiRef` is `handleRef`, as in Core components; static styles move to
  StyleX; the docs limit the spacer-height wording to touch gestures.
- A draft component record holds the ownership lines and the verification
  map, with the screen-reader evidence gap for aria-busy.

Depends on the Core changes in #10172 and #10173.

* chore(storybook): the ChatVirtualizer comparison story moves to its own pull request

The Storybook comparison of virtualized and unvirtualized transcripts
lands in a follow-up pull request, so this one stays under the 2,000-line
review limit.

* fix(lab): ChatVirtualizer keeps a focused row pinned through a blur with no next target; keyExtractor is getRowKey

A blur with no next target can come while the row still holds focus, so
the pin drops only once focus has really left the list. The row identity
prop is `getRowKey`, as in Core's table row hooks.

* fix(lab): ChatVirtualizer observes sizes through Core's shared resize observer

Rows and the scroller register with observeResize from
@astryxdesign/core/utils instead of a ResizeObserver of their own; one
sync still runs per batch, after the last entry, and the registration's
own boxless call is skipped so it forces no layout.

* Merge branch 'main' into chat-virtualizer-story

* chore(cli): list ChatVirtualizer among the official Lab components

Regenerated with `pnpm bundle:cli-official-packages`.

* fix(ChatVirtualizer): measureMode is not a public prop

The measurement pipeline is an implementation detail (AST-002 DEC-1), so
the prop and ChatVirtualizerMeasureMode are gone; the list always uses
the ResizeObserver pipeline it shipped as the default. It never shipped,
so nothing migrates.

* fix(ChatVirtualizer): a message that arrives while the reader is in history mounts, unmarked

Away from the tail, the window never reaches a new message, so it did not
mount and the log had nothing to deliver; when the reader returned it
mounted inside an aria-busy block. Now such a row mounts on arrival after
a gap spacer below the window, as the focused-row pin does, and stays
mounted (streamed updates included) until the window reaches it (AR2).

* perf(ChatVirtualizer): read layout once per scroll event and twice per pass

The scroll handler reads the scroller's position and size in one batch
and writes nothing, so it forces no layout. Each correction pass writes
its spacers, reads in one batch, writes its spacers and scrollTop, and
reads scrollTop back once to claim any browser move, so it forces at most
two layouts; the size it needs after its writes comes from the batch. The
record gains FR4, the clause react-component-runtime INV18 asks for, and
a layout-trace test checks the bound.

* fix(ChatVirtualizer): arrivals in state; a replaced thread adds none; no pass for an idle commit

Tail arrivals are now state, updated during render when the data or the
window changes, not a ref mutated in render (react-component-runtime
INV4). Only a tail append adds to them: a replaced array (another thread)
shares no row with the previous data, so switching threads while the
reader is in history no longer mounts the whole thread for a commit.
Arrivals leave once the window reaches them. The correction pass now
skips a commit that changes nothing it reads (a parent re-render with the
same rows); FR4 lists every trigger the pass has. Tests cover the thread
switch and the skipped pass.

* fix(ChatVirtualizer): an appended batch mounts at most a window of rows

Arrivals are added only while the window does not reach the previous
last row, so a batch appended while following is left to the window, and
at most one window of the newest rows mounts as arrivals while the reader
is in history (this also covers a thread switch that shares a row key).
The correction pass also runs when a sizing prop changes, and FR4 names
that trigger. Tests append 2,000 rows while following and while in
history. The file header says which commits run the pass.

* fix(ChatVirtualizer): arrivals stay one window across batches in history

The cap on mounted arrivals now applies to the whole set after every
change, not only to the newest batch, so a second batch or a run of single
arrivals while the reader stays in history keeps one window of the newest
rows mounted. The test appends a second 2,000-row batch and three single
rows in history.

* fix(ChatVirtualizer): a loaded or replacing thread is history for the log

Rows count as news only for a tail append, when the walk stops at a row
the previous data held. A thread loaded into an empty list, or one that
replaces the rows, mounts as history, so the block is busy for that commit
and the log does not read old messages out as new. Test and the AR2
verification row cover both.

* fix(ChatVirtualizer): the first message of an empty transcript is news

One row arriving into an empty list counts as news, so the opening message
of a new conversation mounts unmarked and the log delivers it; a larger load
into an empty list stays history. Adds a test and the AR2 verification
state, a CLI Changeset for the discover package list, stable-function
notes on estimatedItemSize and getItemType, and trims the file header and
a history comment.

Co-authored-by: Cindy Zhang <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 91098f1e Deployed Nov 6, 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) 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