Skip to content

docs(windowing): how virtualizers attach to scroll areas - #10806

Draft
cixzhang wants to merge 1 commit into
cixzhang/list-windowing-page-scrollfrom
cixzhang/windowing-scroll-area-contract
Draft

cixzhang wants to merge 1 commit into
cixzhang/list-windowing-page-scrollfrom
cixzhang/windowing-scroll-area-contract

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Records only. People scrolling a long list get the same windowed list whether it scrolls inside a scroll area or with the page, and a short list that fits renders every row with no windowing. The list-windowing record now sets the contract between a virtualizer and the scroll area or page it scrolls in: the area owns the scroll box and its scrollability decides whether the list windows; the virtualizer attaches through a callback scrollRef on the area's viewport, or to the page.

Stacked on #10796 (INV4, FR1–FR4, INV5), which this extends; it rebases when #10796 does.

Exact decision needed

How a virtualizer attaches to and shares work with the scroll area or page it scrolls in: who owns the scroll box, how the virtualizer attaches, what decides whether it windows, and what each side may do for scroll anchoring, scrollbar gutter, padding and sticky insets, edge state, keyboard and focus, resize observation, programmatic scrolling, nested scrollers, touch momentum and overscroll, and right-to-left text.

Existing authority searched

Decision

  • Owner (FR5): the scroll area (ScrollableArea, or a viewport that adopts useScrollableArea) or the page owns overflow, size, padding, scrollbar and gutter, keyboard access, chaining and Sticky containment. The engine writes none of them.
  • Attachment (FR6): a callback scrollRef passed to the viewport's existing ref (<ScrollableArea ref={scrollRef}> or getViewportProps({ref})), attached outside React render; or 'page'. One attachment, never discovered. An unregistered element renders every row with one development diagnostic.
  • Scrollability is the source of truth (FR7–FR9): the owner's isScrollable on the list's axis decides. Fitting renders every row and no spacer; scrolling windows. Page: the root scroller's extent exceeds its client extent by more than 1px. Unknown is not fitting: the first render is a bounded window. A scroll lock freezes the window. Crossing the threshold, mid-stream included, keeps the anchored row in place and never oscillates.
  • Observation and reads (FR10, FR11): the owner observes its viewport and content box; the engine observes only its rows, through the shared observer. One offset read per scrolled frame, the clause INV18 permits.
  • Insets and edges (FR12, FR13): the window covers the whole scrollport, under sticky headers and padding included; item alignment honors the owner's scroll-padding; edge state, fades and shadows report only the full list's true ends.
  • Anchoring and writers (FR14, FR15): while windowing, the engine turns native anchoring off on its own list root through the one owner module, never on the scroller; ScrollableArea never writes overflow-anchor. One writer moves the position; other components scroll through the engine's anchor.
  • Keyboard and focus (FR16): native Arrow/Page/Home/End; End reaches the last row; the focused row stays mounted; windowing changes never move focus.
  • Nested (FR17): a list windows against its attached scroller only; a page attachment inside a scrolling area renders every row with a diagnostic.
  • Touch (FR18): no position writes during momentum or bounce; a pending correction applies when the scroll ends; offsets past an edge count as that edge.
  • RTL (FR19): logical axes through direction and writing mode, as the owner does.
  • DEC-5 quotes the owner's words, decider cixzhang, 2026-11-09. No public scroll-ref API is added (DEC-2 holds).
  • Gaps: FR7 (ScrollableArea exposes no scrollability change an attached engine can subscribe to), FR7 (ChatLayout's scroller publishes no scrollability state), FR15 (ChatLayout's follow-end and the engine's end anchor would both write one scroller's position).

Rejected alternatives

  • A scroll-container hook beside useScrollableArea: it measures what the area already measures, and the owner rejected it for overlapping the area.
  • Turning anchoring off on the whole scroller while windowing: it takes native anchoring away from content outside the list, and on the page from the whole document.
  • Discovering the nearest scroller automatically: spec:AST-025 FR18 makes same-axis nesting deliberate, and discovery would follow incidental overflow.

Claim scope and non-goals

  • Only architecture:list-windowing changes: FR5–FR19, DEC-5, three gap lines, Verification rows, Change coupling, Owning code, two projection cells, one System model sentence, and applies_to gains the ScrollableArea directory and the hook file.
  • Out of scope: the engine's API beyond its scrollRef input, OQ1, what each consumer renders and announces, ChatLayout's own record, and any change to ScrollableArea's public API.

Evidence and implementation relationship

  • Read from current source: ScrollableArea's root is the viewport and takes ref; useScrollableArea returns ScrollableAreaState and registers it in a private registry with no change notification; ScrollableArea has no imperative scroll API; the chat stream scroll writes the position and toggles anchoring on its scroller. No code changes.

Writing rubric results

  • R1 narration: none. The new text states what the engine and the owner do, in the present tense; DEC-5 quotes the owner verbatim.
  • R2 research in the record: none. No survey or comparison appears.
  • R3 evidence naming a change: none. The new Verification rows name test layers and failure signals.
  • R4 rejected alternatives over one line or outside a decision: one, inside DEC-5, one line.
  • R5 pull request or issue references remaining: none. A search for # followed by digits, /pull/ and /issues/ finds nothing.
  • R6 ruled open questions still listing options: none. OQ1 is unchanged.
  • R7 project status (build status or work order): none in the added text; gaps are written as <FR> gap: <mismatch>. Text from the base (adoption order, "no module exists yet") is docs(windowing): restore the owner's approval lines and drop adoption order #10795's scope and is left unchanged.

Scope

  • This PR contains specification records only.
  • It records observable behavior and preserves equivalent internal implementations.
  • Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract.
  • Verification states the evidence layer and failure signal without prescribing CI job/workflow topology.
  • It records one intentional durable decision, not a rescue for a separable tagalong.
  • The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision.
  • Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them.
  • Public text and artifacts contain no internal Meta context.

Validation

  • pnpm check:knowledge: Knowledge templates and records are aligned.
  • Prettier
  • git diff --check

@vercel

vercel Bot commented Nov 9, 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 9, 2026 3:05pm UTC

Request Review

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

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 9, 2026, 3:18 PM UTC

@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's decision on the new scroll-owner contract in architecture:list-windowing (FR5–FR19, DEC-5), which no current record states yet. An engineering owner records that decision by commenting /approve-spec cf9e590cb560a021cb819d79f594307b79c370b9 on this pull request, and the author may do so as an engineering owner. These requirements also build on FR1–FR3 and DEC-2 from #10796, which are not on main yet. Two fixes are needed either way:

  • The first FR7 gap line says an engine attached to a ScrollableArea viewport has no change it can subscribe to, but subscribeScrollGeometry in packages/core/src/hooks/scrollGeometrySubscriptions.ts already notifies after every owner publication and Table's runtime uses it, so drop or restate that line and the matching sentence in the description.
  • FR6 and FR7 contradict FR8 for a scroll area that has not measured yet, because useScrollableArea registers isScrollable: false until its first valid measurement and registers the viewport only after the ref attaches, so an engine that follows FR6 or FR7 renders every row where FR8 requires a bounded first window; define the unknown state, say when an element counts as unregistered, and add an FR8 gap line.

[Automated review]

Comment on lines +222 to +224
- **FR7 gap:** ScrollableArea publishes its scrollability only inside its own
hook call and as data attributes on its viewport; an engine attached to that
viewport has no change it can subscribe to.

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.

This gap does not hold: subscribeScrollGeometry(viewport, listener) in packages/core/src/hooks/scrollGeometrySubscriptions.ts fires after every useScrollableArea publication, which first writes the scroll-owner registry, and Table's runtime already subscribes to it. Drop the line, or restate it as the path an attached engine uses (FR10: it reads the owner's state).

Comment on lines +116 to +120
- **FR8 — Unknown is not fitting.** Before the owner's first measurement, and
while it is unmeasurable (`spec:AST-025` FR8), the list renders a bounded
first window from its anchor and reserves the full list's scroll extent. It
never renders the whole list because no state exists. While a scroll lock
holds the page, the window stays as it is.

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.

FR7 makes isScrollable the only source of truth, but the owner has no unknown value: useScrollableArea registers {isScrollable: false, atStart: true, atEnd: true} and keeps it while the viewport is unmeasurable, and it registers the viewport only in the layout effect after the ref attaches (which FR6 reads as unregistered). An engine that follows FR6 or FR7 therefore renders every row exactly where this clause forbids it. Define the unknown state in FR7, say when FR6 judges an element unregistered, and add an FR8 gap: line.

Comment on lines +137 to +138
once per content-box change, never per scroll. These are the reads
`architecture:react-component-runtime` INV18 permits on the scroll path.

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: INV18 names its scroll-path reads one by one, and this windowing read is not among them. Consider saying that FR11 requires these reads, which INV18 allows as "a read a current clause requires there", or add the read to INV18's list as was done for the reorder drag's read.

Comment on lines +31 to +34
| System behavior | One shared internal windowing module owns long-list windowing in Core. Table virtualization is its first consumer, then Selector, then Chat. The module is not public API (INV1, INV2). |
| End-user impact | None yet: the module does not exist, and Selector renders every option. Once it ships, people opening a long list wait less, and every windowed list behaves the same way. |
| Builder impact | A Core component that windows a long list calls the one module and attaches it to its scroll area's viewport ref or to the page (FR6). No public windowing hook exists while OQ1 is open. |
| Compatibility/readiness | Additive and internal. Spec only: no module exists yet (Current-state impact). Table's approved virtualization hook keeps its public shape. |

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: these re-padded rows still state build status and order ("first consumer, then Selector, then Chat", "None yet: the module does not exist", "Spec only: no module exists yet"). Please drop that status when this rebases on #10795, keeping what the record requires.

| Builder impact | A Core component that windows a long list calls the one module and attaches it to its scroll area's viewport ref or to the page (FR6). No public windowing hook exists while OQ1 is open. |
| Compatibility/readiness | Additive and internal. Spec only: no module exists yet (Current-state impact). Table's approved virtualization hook keeps its public shape. |
| Review checks | Reject a second windowing implementation in Core, a public export of the module, or a change to Table's public virtualization shape made to adopt it. |
| Governing rules | DEC-1–DEC-5; `spec:AST-025` FR1, FR3, FR5, FR8–FR9, FR12–FR15, FR18, FR20–FR21. |

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 projection leaves out spec:AST-025 IR2 and FR19, which the body cites in the Scroll owners paragraph.

This branch was successfully deployed

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

Labels

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