Repository navigation
refactor(core): one shared list-windowing engine, with Table as its first consumer - #10810
Conversation
…irst consumer Moves utils/listWindow.ts to packages/core/src/virtualization/ and lifts the generic parts of Table's window controller into it: useListWindow (geometry subscription, first-visible-key anchoring across data and pitch changes, the pending-anchor scroll, the one retained focus island and focus return) and the canvas measurement helpers. Table keeps its admission, logical-position column widths and mounted-row diagnostics, and calls the shared hook. The geometry snapshot's bodyOffset is named startOffset. Lab reaches the module only through Core's private @astryxdesign/core/internal/virtualization entry. No behavior or public API change. Co-authored-by: Humberto Virtudes <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| TableBody | 3.5 kB (0) · 3.3 kB CSS (0) | — | ✓ · ✓ · ✗ |
| TableFooter | 3.5 kB (0) · 3.3 kB CSS (0) | — | ✓ · ✓ · ✗ |
| TableHeader | 3.5 kB (0) · 3.3 kB CSS (0) | — | ✓ · ✓ · ✗ |
8 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| TableRow | 7.0 kB (0) · 4.0 kB CSS (0) | — | ✓ · ✓ · ✗ |
| lab/Comments | 353.1 kB (+229 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 346.2 kB (+181 B) · 2.4 kB CSS (0) | — | — · — · — |
| Markdown | 188.9 kB (+153 B) · 20.7 kB CSS (0) | — | — · — · — |
| Table | 126.1 kB (+137 B) · 18.4 kB CSS (0) | — | ✓ · ✓ · — |
| TableCell | 110.5 kB (0) · 17.9 kB CSS (0) | — | ✓ · ✓ · ✓ |
| TableHeaderCell | 110.1 kB (0) · 17.7 kB CSS (0) | — | ✓ · ✓ · ✓ |
| TableSelectionToolbar | 70.9 kB (0) · 13.2 kB CSS (0) | — | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 7.25 MB packed (+4.2 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 29 rows, core 36 rows; run pnpm api:report.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about this pull request's spec edits; the code change itself has no blocking finding.
- This pull request rewrites ORD3 and the ownership lines of the current
module:Table/useTableRowsVirtualizationrecord so thatarchitecture:list-windowingowns the first-visible-key anchor math, the focus-island retention and the measurement helpers, but the currentarchitecture:list-windowingrecord does not state those yet, so an engineering owner needs to approve or reject these edits by commenting/approve-spec 6750aba67655ef78b19211b9fefeb174f3c36bd5(the author may do so as an engineering owner).
The shared useListWindow hook matches Table's previous window controller, and Table's behavior and public API are unchanged. architecture:list-windowing still says no windowing module exists and does not list packages/core/src/virtualization/, so landing #10809 with or before this keeps that record accurate. The Owns list also drops "anchor policy" while FR8 and DEC-4 keep that policy in the Table record.
[Automated review]
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about this pull request's record edits; the code change has no blocking finding.
- The edits to
module:Table/useTableRowsVirtualization(the new ORD3 sentence, the Owns and Does-not-own lines, and the Range and Focus island owners) assign the first-visible-key anchor math, focus-island retention and the measurement helpers toarchitecture:list-windowing, which does not state those today, so an engineering owner approves them by commenting/approve-spec be02658701485b7e26848f42ac63af304c2120c5(the author may do so as an engineering owner), or the edits are reworded to what that record states, for example keeping FR8's anchor policy under this record's Owns.
The shared useListWindow hook carries Table's previous window controller unchanged, so Table's behavior and public API stay the same, and the Table and virtualization suites pass at this head. architecture:list-windowing still says no windowing module exists and its applies_to does not cover packages/core/src/virtualization/, so the records update should fix both with or before this change.
[Automated review]
Main renamed the hook's viewportHeight to initialViewportHeight (#10894). The Table adapter keeps the shared engine and maps the first-frame height into the engine's pitch; the module record keeps main's Geometry row and this branch's list-windowing owners.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about this pull request's record edits; the code change has no blocking finding.
- The edits to
module:Table/useTableRowsVirtualization(the new ORD3 sentence, the Owns and Does-not-own lines, and the Range and Focus island owners) assign the first-visible-key anchor math, focus-island retention and the measurement helpers toarchitecture:list-windowing, which does not state those today, so an engineering owner approves them by commenting/approve-spec c518793e0e01a84670f6015ba0fcfa18b838a1b0(the author may do so as an engineering owner), or the edits are reworded to what that record states, for example keeping FR8's anchor policy under this record's Owns.
The shared useListWindow hook carries Table's previous window controller unchanged, now fed from initialViewportHeight, so Table's behavior and public API stay the same; the Table and virtualization suites pass at this head. architecture:list-windowing still says no windowing module exists and does not route packages/core/src/virtualization/, so the records update should fix both with or before this change. A smaller suggestion: naming the engine's first-window field initialViewportHeight would make the comment in useTableWindow.ts unnecessary.
[Automated review]
| }: UseTableWindowOptions<T>): TableWindowResult { | ||
| const [violation, setViolation] = useState<Violation | undefined>(); | ||
| const config = getTableVirtualizationConfig(capability); | ||
| // The engine plans its first window from the declared first-frame height. |
There was a problem hiding this comment.
Non-blocking (comment style): this comment is needed only because the engine names the first-window height viewportHeight in ListWindowPitch, the same word as the measured height in ListWindowGeometry. Naming the engine field initialViewportHeight, as Table's public input is now named, lets the mapping explain itself, and the comment can go.
|
/approve-spec c518793 |
There was a problem hiding this comment.
Changes requested: one repository test fails at this head. The record edits are now approved, and the refactor itself keeps Table's behavior and public API unchanged.
- Miss:
scripts/shared-identity.test.mjsfails because the canvas cachetextContextmoved topackages/core/src/virtualization/measure.tswhilescripts/shared-identity.baseline.jsonstill lists it aspackages/core/src/Table/plugins/virtualization/useTableWindow.ts:textContext; rename that key topackages/core/src/virtualization/measure.ts:textContextand keep itsallowedmemo-cache reason.
The test passes on the base, and the Table and virtualization suites pass at this head. architecture:list-windowing still says no windowing module exists and does not route packages/core/src/virtualization/, so the records update should fix that. A smaller suggestion stands: naming the engine's first-window field initialViewportHeight would make the comment in useTableWindow.ts unnecessary.
[Automated review]
…e the shared module The canvas cache textContext moved with the text measurement into packages/core/src/virtualization/measure.ts, so the shared-identity baseline key follows it with its memo-cache reason. architecture:list-windowing now routes packages/core/src/virtualization/ and its private entry, names them as the module, and says Table uses it while Selector and Chat render every item. No source change.
|
/approve-spec 9ffe3e6 |
There was a problem hiding this comment.
Approved. The refactor keeps Table's behavior and public API unchanged, both record edits carry an engineering owner's approval for this head, and the full CI run at this head passes.
Non-blocking:
docs/architecture/list-windowing.md:32and:82describe which lists adopt the module next; a record states what the system is, so consider dropping "until they adopt it; then every windowed list behaves the same way".- The comment at
useTableWindow.ts:268explains only a field name; namingListWindowPitch.viewportHeightinitialViewportHeightmakes it unnecessary.
[Automated review]
| | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | Governing contract | None. Each consumer's record owns what a person sees and hears in its long list; this record owns only which module computes the window. | | ||
| | System behavior | One shared internal windowing module owns long-list windowing in Core. The module is not public API (INV1, INV2). | | ||
| | End-user impact | A long Table windows through the module. Selector renders every option and Chat renders every message until they adopt it; then every windowed list behaves the same way. | |
There was a problem hiding this comment.
Non-blocking: "until they adopt it; then every windowed list behaves the same way" states who adopts the module next, which is temporary project status. A record states what the system is; consider dropping that clause and keeping what INV1 requires. The same applies to "Selector renders every option when it opens, and Chat renders every message" in Current-state impact (line 82), which names no claim it is a gap against.
|
/approve-spec f0434f2 |
There was a problem hiding this comment.
Approved pending CI: the deferred build and test lanes have not run on this head yet.
Table's row windowing now runs on the shared useListWindow hook with its behavior and public API unchanged. The built API surfaces match the base, both record edits carry an engineering owner's approval for this head, and Table's real-browser virtualization tests, which this merge brings in from main, pass on the shared hook.
Two optional follow-ups stay open on their earlier threads: drop the adoption sequencing in docs/architecture/list-windowing.md (lines 32 and 82), and name the engine's first-window height initialViewportHeight so the comment at useTableWindow.ts:268 can go.
[Automated review]
(A) merged as #10810. Main's Table files equal (A)'s, so this branch's plugin split is kept; tableRuntime keeps its optional geometry driver.
Maintainer impact
Table's row virtualization now runs on one shared list-windowing engine in Core, so Selector and Lab's ChatVirtualizer can reuse it instead of growing their own. This is an internal refactor: Table's behavior and public API do not change.
What moves
packages/core/src/utils/listWindow.ts(and its tests) →packages/core/src/virtualization/listWindow.ts. Unchanged: fixed-pitch range, gap segments and first-visible-key reconciliation.packages/core/src/virtualization/useListWindow.ts: the generic parts of Table's window controller, lifted fromuseTableWindow.tswithout behavior change:packages/core/src/virtualization/measure.ts: the canvas text metrics and pixel parsing helpers.Table/plugins/virtualization/useTableWindow.tskeeps only Table's parts: capability-to-pitch admission, the rejection state and its warning, logical-position (row-number) column widths, and the mounted-row geometry diagnostics. It callsuseListWindow.bodyOffsetis renamedstartOffset(internal;tableRuntime.ts).@astryxdesign/core/internal/virtualization(named re-exports; the same pattern asinternal/scroll-anchoring). The@astryx/no-core-internal-importrule allows it only in Core and Lab. It has no root export, no docs and noindex.ts, so it is not a public subpath.Co-authored with Humberto Virtudes, whose window controller and list-windowing module this lifts unchanged.
Records
architecture:list-windowingnamespackages/core/src/virtualization/and@astryxdesign/core/internal/virtualizationas the shared module and routes both paths.architecture:list-windowingowns the engine's home (its records PR adds the engine-home FR).This PR points
module:Table/useTableRowsVirtualization's shared claims at it: the range, overscan, gaps, anchor math, focus-island retention, and offset and measurement helpers. Table keeps admission and wiring.Evidence
packages/core/src/Tableandpackages/core/src/virtualizationsuites pass (42 files, 784 tests), including the 1k/100k identity-work and 100k pre-cell planning cases. Only the renamed geometry field changed in the Table window tests.useListWindow.test.tsx), independent of Table: a 10k list mounts only the visible rows plus four per side; one focused row stays mounted after it scrolls out and is released on blur; inserting rows above keeps the first visible key and its fractional offset; a list that may not window renders every row and subscribes to nothing.tsc --noEmit, eslint,check:changesets,check:knowledgeandcore-internal-entriespass. The generated API report has no engine symbol, so the public API is unchanged.Size (min+gzip JS, esbuild, other modules external)
Table/plugins/virtualization:useTableWindow+useTableRowsVirtualization)virtualization/:listWindow+useListWindow+measure)listWindowonly)The adapter is still above the 2 KB budget, by 168 B. The follow-up PR replaces the row-number width measurement with CSS and contains the remaining virtualization-only logic in the plugin.
Before/after harness report (head c518793; 9ffe3e6 changes only a baseline key and a record)
Engine-swap compare, CI run 42776381526: before = main
f6d2c316, after = this headc518793e. Medians of 3 seeded runs per cell; before and after share one runner in every throttle × text cell.Every row passes, all at 100% text. Each frame is checked for overlap or gaps between adjacent rows, each row within 1px of an unwindowed render of the same rows, viewport coverage, and no jump (>1px) of the anchored row without input. Dropped = frames over 25ms.
Scope
Writing rubric results
Present tense, describes the system: yes; the Table record states who computes the range, island and anchor.
No history, pull requests or research in the record: yes.
Owner routing: shared claims point to
architecture:list-windowing; Table-only admission and wiring stay inmodule:Table/useTableRowsVirtualization.One topic per sentence: yes.
architecture:list-windowing: present tense; it describes the module atpackages/core/src/virtualization/, its private entry and its consumers, with no history or pull requests;applies_toroutes both paths.