Skip to content

feat(Table): Promise-based infinite loading with useTableInfiniteScroll - #10570

Merged
cixzhang merged 8 commits into
mainfrom
feat/table-infinite-loading
Nov 12, 2026
Merged

cixzhang merged 8 commits into
mainfrom
feat/table-infinite-loading

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

User impact

  • Who: people using a data Table that loads more rows as they reach the end, and the builders who wire that loading.
  • Before: Table had no incremental-loading plugin. Builders wrote their own observers and buttons, and an empty table that was still fetching its first rows showed "No data".
  • After: useTableInfiniteScroll({hasMore, isLoading, onLoadMore}) returns one Table plugin.
    • Reaching the end of the table loads the next batch automatically, and a Load more button below the table always offers the same request by keyboard or pointer.
    • One request runs at a time: observation, clicks and repeated presses share one latch.
    • A failed automatic request pauses automatic retry until the person retries with the button, so a broken source does not loop.
    • The busy button keeps focus and announces progress. When the last batch removes the focused button, focus moves to the table's scroll region instead of the page.
    • While an empty table loads its first rows, Table hides only its default "No data" message; caller-supplied empty content still shows.
  • Existing tables and plugins are unchanged unless they opt in.

Authority

  • module:Table/useTableInfiniteScroll (current): the public contract is the three-field hook; observation is progressive enhancement over an always-available manual command; failures pause automatic retry.
  • component:Table FR22 (current): Table reads a plugin's renderState source before it builds the sections, only in data mode with a flat row model and the default scroll wrapper; it suppresses only the default empty state while loading; focus left behind by a removed command moves to the named scroll region with preventScroll and temporary programmatic-only focusability.
  • component:Table public contract and concepts table: TablePlugin.renderState with subscribe, getSnapshot, getServerSnapshot and immutable {isLoading, hasMore?}.

What this adopts from #8282, and what it defers

This is #8282's loading work, ported onto main as one atomic PR. #8282 sits on top of #8280 (virtualization) and #8281 (activation, superseded by #8861), so its own commit does not apply to main.

Kept:

  • The hook, its tests, docs, the CLI usage block and the story, essentially as written.
  • Table's renderState loading protocol and default-empty-state suppression (FR22).

Changed in the port:

  • Admission: the hook and Table admit loading for data mode with a flat row model (and, in Table, the default scroll wrapper). feat(Table): add Promise-based infinite loading #8282 read a canLoad flag from feat(Table): window fixed-height flat tables through useTableRowsVirtualization #8280's admission module; TableRenderContext gains no new field here.
  • Focus: the surface uses the shared focus-leaving sequence (useFocusLeavingChange with a LayoutChangeSnapshot on hasMore), as Collapsible, LayoutPanel, SideNav and TreeList do. On exhaustion it calls main's moveFocusLeftBehind(focus, viewport, null, {preventScroll: true}), which already lends the scroll region a temporary tab stop; this PR no longer changes focusReturn.ts.
  • Diagnostics: the hook warns once per instance through main's createDevWarnings().

Adopted now that main windows rows (#8280 landed):

  • FR20's unknown row total: Table's loading store carries hasMore as well as isLoading. A windowed Table reports aria-rowcount="-1" while any admitted source has more rows, and the exact total once none does. TableIncrementalCount.test.tsx comes from feat(Table): add Promise-based infinite loading #8282.
  • The block-viewport observation root (module FR11, DEC-2): while Table windows its rows, the sentinel observes against Table's bounded block viewport; otherwise against the browser viewport. A root change disconnects the old observer. TableLoadingViewport.test.tsx comes from feat(Table): add Promise-based infinite loading #8282.
  • Admission reads main's admission.rowModel, and admits loading only with the Table-owned scroll wrapper (as windowing does): a caller's scrollWrapper may not render afterTable, where the loading surface lives, so with one Table keeps its default empty state. Table puts that admission on its private runtime context, and the hook's surface, observation and requests follow it (warning once when denied), so a caller's wrapper gets the whole loading behavior or none of it.

Evidence

  • Caller scroll wrapper: with a caller scrollWrapper and a loading source, the default empty state still shows. With a caller wrapper that renders afterTable, there is no Load more surface and no request, and one warning. Each test fails on the head before it.

  • Targeted suites (latest head): the hook, count, viewport, Table and plugin-loading suites pass (205 tests).

  • Main merge: 7 of the 16 ported count and viewport tests fail on the head before the merge with main's BaseTable, and pass after it. Core tsc and check:knowledge pass.

  • Red first: the test commit fails on main. Against main's Table, "reacts to a stable loading source before rendering the default empty state" fails because "No data" renders during loading; the hook tests fail because the hook does not exist.

  • After: the Table, utils, Collapsible, SideNav, TreeList and Layout suites pass (114 files, 2,560 tests, including the process.env type check). Core tsc --noEmit passes. eslint passes on every changed file. check:changesets passes.

  • Mutation: with Table's renderState subscription removed, "reacts to a stable loading source before rendering the default empty state" fails; the test clicks Settle with a stable plugin record.

  • The wide-table Chromium spec (TableInfiniteScrollWide.a11y.chromium.spec.ts) is included; it runs in CI's browser lane against the built story.

Scope

  • One capability, already decided by current records.
  • Public API is what the records name: useTableInfiniteScroll, UseTableInfiniteScrollConfig, TablePlugin.renderState and TablePluginRenderState.
  • Existing callers keep their behavior: focusReturn.ts is unchanged, and Table behaves as before without a renderState source.
  • Public text contains no internal Meta context.

Size

  • vs main: 21 files, +2140/−18. Product lines 745 across 13 files; the rest is tests (1,341), the story and the changeset.
  • New behavior module: this PR introduces useTableInfiniteScroll (module:Table/useTableInfiniteScroll, current): the hook is 523 product lines, plus its doc, index, CLI usage block and locale strings. Growth of existing modules is 92 product lines: BaseTable +65 (the FR22 loading store, the FR20 row count, and the owned-wrapper admission it shares with the hook), tableRuntime.ts +2 (the private admission flag), types.ts +18 (TablePluginRenderState, TablePlugin.renderState), useBaseTablePlugins.ts +4, index.ts +3.
  • App size: from CI's package-size report on this head (added after the run).

Testing

  • pnpm vitest run --project ui packages/core/src/Table/plugins/infiniteScroll packages/core/src/Table/TablePluginLoading.test.tsx packages/core/src/Table/TableIncrementalCount.test.tsx packages/core/src/Table/TableLoadingViewport.test.tsx packages/core/src/Table/Table.test.tsx
  • cd packages/core && npx tsc --noEmit -p tsconfig.json

Co-authored with Humberto Virtudes; supersedes the loading part of #8282.

Writing rubric results

The record change is limited to module:Table/useTableInfiniteScroll's verification map: verified_by and the AR1 row now name test files that exist.

  • Present tense, facts only: each line names a file and what it checks; unbuilt checks stay marked pending.
  • No history, pull requests or research in the record.
  • No behavior, API or owner decision changes; the approved contract rows are untouched.

cixzhang and others added 2 commits November 7, 2026 11:04
useTableInfiniteScroll({hasMore, isLoading, onLoadMore}) returns one flat
Table plugin. One request latch is shared by automatic observation and the
always-available Load more command; a failed automatic request pauses
automatic retry until a manual one; the busy Button keeps focus and
announces progress.

Table reads a plugin's renderState loading source before it builds the
sections, in data mode with a flat row model and the default scroll
wrapper, and hides only its default empty state while the first rows
load (component:Table FR22). When exhaustion removes the focused command,
focus moves to the Table scroll region with a temporary tab stop through a
new additive focusForLastInputTemporarily helper; moveFocusLeftBehind is
unchanged.

Ported from #8282 onto main without the windowing pieces (FR20's unknown
row total and the block viewport), which belong to row virtualization.

Co-authored-by: Humberto Virtudes <[email protected]>
@vercel

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

Request Review

@astracat-bot

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 12, 2026, 3:16 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 7, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 81fcf8f

Storybook · Sandbox · built from this PR's head

Modified components

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.1 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · ✗
lab/Comments 360.1 kB (+267 B) · 2.5 kB CSS (0) — — · — · —
Table 130.6 kB (+244 B) · 18.7 kB CSS (0) — ✓ · ✓ · —
lab/CommentThread 353.4 kB (+242 B) · 2.4 kB CSS (0) — — · — · —
Markdown 193.6 kB (+232 B) · 21.0 kB CSS (0) — — · — · —
TableCell 114.5 kB (0) · 18.2 kB CSS (0) — ✓ · ✓ · ✓
TableHeaderCell 114.1 kB (0) · 18.0 kB CSS (0) — ✓ · ✓ · ✓
TableSelectionToolbar 73.7 kB (0) · 13.6 kB CSS (0) — ✓ · ✓ · ✓

Package size:

  • @astryxdesign/cli 4.02 MB packed (+563 B); no new dependencies
  • @astryxdesign/core 7.40 MB packed (+13.0 kB); no new dependencies

API changes: core +7 · ~0 · −0

7 API changes (advisory)
Package Where Signature Usage
+ core . · Hooks · hook useTableInfiniteScroll hook useTableInfiniteScroll: <T extends Record<string, unknown>>(config: UseTableInfiniteScrollConfig) => TablePlugin<T> import {useTableInfiniteScroll} from '@astryxdesign/core'; useTableInfiniteScroll(…)
+ core . · Types · interface TablePlugin renderState?: TablePluginRenderState import type {TablePlugin} from '@astryxdesign/core'; const x: TablePlugin = {renderState: …}
+ core . · Types · interface TablePluginRenderState interface TablePluginRenderState import type {TablePluginRenderState} from '@astryxdesign/core'
+ core . · Types · interface UseTableInfiniteScrollConfig interface UseTableInfiniteScrollConfig import type {UseTableInfiniteScrollConfig} from '@astryxdesign/core'
+ core ./Table · Also exported from an earlier entry point · TablePluginRenderState TablePluginRenderState (.) import {TablePluginRenderState} from '@astryxdesign/core/Table'
+ core ./Table · Also exported from an earlier entry point · UseTableInfiniteScrollConfig UseTableInfiniteScrollConfig (.) import {UseTableInfiniteScrollConfig} from '@astryxdesign/core/Table'
+ core ./Table · Also exported from an earlier entry point · useTableInfiniteScroll useTableInfiniteScroll (.) import {useTableInfiniteScroll} from '@astryxdesign/core/Table'

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


Generated by PR Enrichment workflow | View full report

@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.

Requesting changes. The loading contract matches the approved module:Table/useTableInfiniteScroll and component:Table FR22 records, and the unit tests, typecheck and lint pass. One blocking issue remains: how the Load more command hands off focus.

Blocking

  • The exhaustion focus handoff in useTableInfiniteScroll.tsx (the Button's onFocus/onBlur note and the layout effect at lines 300–323) repeats moveFocusLeftBehind's lost-focus check outside the shared useFocusLeavingChange path, which architecture:react-component-runtime INV16 does not allow: give moveFocusLeftBehind an optional options argument (preventScroll and the temporary tab stop), have the surface call useFocusLeavingChange with a LayoutChangeSnapshot on hasMore, and delete the component's own copy.

Also worth fixing

  • useTableInfiniteScroll.doc.mjs says observation uses the parent block viewport while Table is windowing, but the hook always observes the browser viewport and Table has no windowing yet.
  • "reacts to a stable loading source…" still passes with Table's renderState subscription removed. Click its Settle button with a stable plugins record so the test checks the notification.

[Automated review]

…aving sequence

The exhaustion handoff repeated moveFocusLeftBehind's lost-focus check.
moveFocusLeftBehind now takes optional preventScroll and temporaryTabStop
options (existing callers unchanged), and the loading surface notes focus
through useFocusLeavingChange with a LayoutChangeSnapshot on hasMore. The
renderState test clicks Settle with a stable plugin record, so it fails
when Table does not subscribe. The usage doc names the browser viewport,
and the diagnostics no longer read process.env.

Co-authored-by: Humberto Virtudes <[email protected]>

@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 Load more focus handoff now runs through the shared useFocusLeavingChange and moveFocusLeftBehind path, which resolves the earlier blocking issue, and the loading behaviour matches the current module:Table/useTableInfiniteScroll and component:Table FR22 records. CI has not run on this head yet because the pull request is a draft; it runs once the pull request is marked ready for review.

Also worth fixing (non-blocking)

  • The renderState JSDoc in types.ts and the matching comment in BaseTable.tsx say Table reads it only with "the default scroll wrapper", but any scroll wrapper is admitted; say "a scroll wrapper".
  • Miss: the comment at focusReturn.ts:174 gives the wrong reason for its else branch, which runs only when the target cannot take focus; suggest "Focus can fail, for example on a hidden target. Then remove the attribute at once."

[Automated review]

Comment thread packages/core/src/Table/types.ts Resolved
Comment thread packages/core/src/utils/focusReturn.ts Resolved
@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 10:58

@humbertovirtudes humbertovirtudes 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.

Recheck at 7297108: REVISE. The authority is in place (module:Table/useTableInfiniteScroll, Table FR22) and the core hook is sound: one request at a time, completion only after the Promise settles, failure pauses auto-retry, and remounts ignore old requests. CI was green, but on a base 361 commits behind main, and the branch now conflicts.

Blocking

  1. utils/focusReturn.ts conflicts and is superseded by #10655. A plain resolution exports focusForLastInputTemporarily twice, and temporaryTabStop no longer type-checks against FocusOptions. Drop this PR's focusReturn.ts change, call moveFocusLeftBehind(focus, target, null, {preventScroll: true}) from useTableInfiniteScroll.tsx:307-313, and regenerate api-report.md.

Major (these break silently: BaseTable.tsx merges without a conflict)
2. Row count while windowed. The store keeps isLoading but drops hasMore, and main's windowed Table sets aria-rowcount to the loaded count. A windowed table with more rows to load therefore reports a wrong total; FR20 requires -1 while any source says hasMore. Thread hasMore through the store and bring over #8282's TableIncrementalCount.test.tsx.
3. Observation root. root = null is hard-coded (useTableInfiniteScroll.tsx:333-335, :405), but main now has a Table block viewport, which module FR11/DEC-2 require as the root when it exists. Use context.viewport.current while windowed, add a windowed version of the test at test.tsx:328, port TableLoadingViewport.test.tsx, and update the docs.

Minor

  • Use main's createDevWarnings() instead of the hook's own once-per-instance warning set (:89-120).
  • types.ts:518 and BaseTable.tsx:540 say "default scroll wrapper", but the code admits any wrapper (ScrollWrapper != null).
  • The browser spec path doesn't match the record (__tests__/TableInfiniteScroll.a11y.chromium.spec.ts), and it lacks browser cases for the focus handoff when the last batch removes a focused button and for the busy button blocking the keyboard; the Table.perf extension is also missing.

Ownership: this PR should own infinite loading. #8282 can close as superseded once its row-count and viewport tests move here.

@astracat-bot

astracat-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

In reply to @humbertovirtudes

I'll run a full review to re-check this with your note.

@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.

Requesting changes. The hook itself matches module:Table/useTableInfiniteScroll and Table FR22 at this head, but main has moved since it was approved: Table windowing landed in #8280, and #10655 moved temporary focus targets and per-instance warning dedupe into shared owners. The branch needs a rebase that adopts those owners and finishes the windowed parts it deferred.

Blocking

  • Regression: packages/core/src/utils/focusReturn.ts conflicts with main, whose moveFocusLeftBehind(…, options?: FocusOptions) already lends the temporary tab stop, so drop this PR's focusReturn.ts change and call moveFocusLeftBehind(focus, viewport, null, {preventScroll: true}) from useTableInfiniteScroll.tsx:308-313.
  • Regression: BaseTable.tsx:566 reads a rowModel local that main replaced with admission.rowModel, so the hunk merges without a conflict and then every data-mode Table throws ReferenceError: rowModel is not defined.
  • Regression: the hook's own warned set (useTableInfiniteScroll.tsx:90, :114-120) duplicates main's createDevWarnings(), which should own the per-instance warning dedupe.
  • Regression: Table's loading store keeps only isLoading, so on main a windowed Table using the hook reports the loaded total (aria-rowcount="101" for 100 rows) instead of FR20's -1 while hasMore is true; carry hasMore through and bring over TableIncrementalCount.test.tsx.
  • Regression: the observer root is hard-coded to the browser viewport (useTableInfiniteScroll.tsx:335), but FR11 requires the Table block viewport when present, which main's windowed Table now has; observe context.viewport.current while windowed and port TableLoadingViewport.test.tsx.

Worth doing in the same push: browser cases for the focus handoff and the busy keyboard path, the Table.perf extension the module record's verification map lists, and "a scroll wrapper" instead of "the default scroll wrapper" in types.ts:518 and BaseTable.tsx:540.

[Automated review]

Comment thread packages/core/src/utils/focusReturn.ts Resolved
Comment thread packages/core/src/Table/BaseTable.tsx Resolved
Comment thread packages/core/src/Table/BaseTable.tsx Resolved
…wners

- Focus: drop this branch's focusReturn.ts change. Exhaustion calls main's
  moveFocusLeftBehind(focus, viewport, null, {preventScroll: true}), which
  lends the temporary tab stop itself.
- BaseTable: loading is admitted on admission.rowModel === 'flat'; main
  replaced the bare rowModel local.
- Row count: the loading store carries hasMore as well as isLoading. A
  windowed Table reports aria-rowcount -1 while any admitted source has
  more rows (Table FR20), and the exact total once none does.
- Observation root: the Table block viewport while Table windows its rows,
  otherwise the browser viewport (module FR11, DEC-2). A root change
  disconnects the old observer.
- Warnings: per-instance dedupe goes through main's createDevWarnings().
- api-report.md: main deleted it; the deletion is kept.

TableIncrementalCount.test.tsx and TableLoadingViewport.test.tsx come from
Humberto's earlier infinite-loading branch and fail on the previous head.

Co-authored-by: Humberto Virtudes <[email protected]>
@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
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 23:21
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 23:22
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3a16845

@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 infinite-loading hook and Table's loading protocol match their records, and every point from the previous round is fixed: the shared focus and warning owners, the hasMore row count and the block-viewport root. One stated claim does not hold.

  • Newly live check: Table admits a plugin's loading state with any scroll wrapper (BaseTable.tsx:742-743), not only the default one as the description, the TablePlugin.renderState JSDoc (types.ts:518-519) and the comment at BaseTable.tsx:710-712 say, so a caller scrollWrapper that does not render afterTable shows a blank body with no Load more while the first rows load; gate on isTableScrollWrapperOwned(ScrollWrapper) as windowing does (BaseTable.tsx:630) and add a caller-wrapper test, or correct the three texts if any wrapper should qualify.

test-node (2/4) and (4/4) failed on timeouts in unrelated CLI tests, so please re-run them. The verification map's browser focus and keyboard flows and the Table.perf extension are still open but do not block.

Claims and files checked
  • Claim: the hook returns one Table plugin from three fields: verified (useTableInfiniteScroll.tsx:466-508; the API changes list exactly the four new names).
  • Claim: reaching the end loads the next batch, and a Load more Button is always offered: verified (unit tests; Chromium spec in LTR and RTL).
  • Claim: observation, clicks and repeated presses share one request: verified (invoke latch, :183-242; latch test).
  • Claim: a failed automatic request pauses automatic retry until a manual retry: verified (throw, reject and non-Promise tests).
  • Claim: the busy Button keeps focus and announces progress, and exhaustion moves its focus to the scroll region: verified (unit keyboard and focus tests).
  • Claim: an empty loading table hides only the default "No data", and caller content still shows: verified (BaseTable.tsx:1031; TablePluginLoading.test.tsx).
  • Claim: existing tables and plugins are unchanged unless they opt in: verified (no source keeps the store at zero).
  • Claim: Table reads the loading state only in data mode, with a flat row model and the default scroll wrapper: false (BaseTable.tsx:742-743 admits any wrapper).
  • Claim: the render context gains no new field: verified (types.ts).
  • Claim: the focus handoff uses the shared focus-leaving sequence and the shared focus mover, and focusReturn.ts is unchanged: verified (useTableInfiniteScroll.tsx:303-314).
  • Claim: warnings come once per instance through the shared dev-warning helper: verified (:92).
  • Claim: a windowed table reports an unknown total while more rows exist and the exact total once none do: verified (BaseTable.tsx:928-934; TableIncrementalCount.test.tsx).
  • Claim: the sentinel observes the table viewport while windowed, else the browser viewport, and a root change disconnects the old observer: verified (useTableInfiniteScroll.tsx:335-347; TableLoadingViewport.test.tsx).
  • Claim: admission reads the shared row-model admission: verified (BaseTable.tsx:743).
  • Claim: the named suites, typecheck, eslint and changeset checks pass: verified by CI at this head (two unrelated CLI test shards timed out).
  • Claim: the wide-table Chromium spec runs in CI's browser lane: verified (10 of 10 pass).
  • Claim: the earlier ported tests fail on the previous head, and the test commit fails first on the base branch: not re-run in this review.
  • Claim: removing Table's subscription makes the empty-state test fail: verified by reading the test (a stable plugin record; only the source's notification re-renders).
  • Claim: the size figures (19 files, 2,019 added and 4 deleted, 714 product and 1,263 test lines, 508 hook lines): verified.
  • Changeset: one Promise latch, failure pause, and the busy Button owning announcements and focus: verified.
  • Files with a finding: packages/core/src/Table/BaseTable.tsx, packages/core/src/Table/types.ts; non-blocking: packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx (comment at :333-334).
  • Files clear: .changeset/table-infinite-loading.md, apps/sandbox/scripts/next-export-routes.json, apps/storybook/stories/TableInfiniteScroll.stories.tsx, internal/shadcn-registry/routes.lock.json, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx, packages/core/locales/en.json, packages/core/src/Table/TableIncrementalCount.test.tsx, packages/core/src/Table/TableLoadingViewport.test.tsx, packages/core/src/Table/TablePluginLoading.test.tsx, packages/core/src/Table/index.ts, packages/core/src/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.ts, packages/core/src/Table/plugins/infiniteScroll/index.ts, packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.test.tsx, packages/core/src/Table/useBaseTablePlugins.ts, packages/core/src/Table/useTableInfiniteScroll.doc.mjs.

Automated review (maintainer link)

Comment thread packages/core/src/Table/BaseTable.tsx Resolved
…rapper

The loading surface renders in the wrapper's afterTable. A caller's
scrollWrapper that does not render it showed a blank body with no Load
more while the first rows loaded, because Table still hid its default
empty state. Table now admits loading only with its own wrapper, as
windowing does, which is what the renderState JSDoc and the PR describe.

Test: with a caller scroll wrapper and a loading source, the default empty
state still shows. It fails on the previous head. A comment that restated
the observer-root line is removed.
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 05:25
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 05:26
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 9732e3f

@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 loading hook and Table's renderState protocol match their current records, and CI passes at this head. Two things remain:

  • Table reads a plugin's loading state only with its own scroll wrapper (BaseTable.tsx:744-748), but the hook still shows its busy Load more Button and runs requests under any wrapper (useTableInfiniteScroll.tsx:474), so a caller scrollWrapper that renders afterTable shows "No data" above a busy Load more Button during the first load; let the hook follow Table's admission (for example through Table's private runtime context), correct the comment at BaseTable.tsx:742-743, and add a test with a caller wrapper that renders afterTable.
  • Miss: the description says the hook, count, viewport, Table and plugin-loading suites pass with 201 tests, but those five files run 204 tests at this head; please update the number.

Non-blocking: the module record's verification map still names a different browser-spec path and a Table.perf.test.tsx extension that this pull request does not add.

Claims and files checked
  • Changeset: adds Table infinite loading through the three-field hook — verified (useTableInfiniteScroll.tsx:464-506, Table index.ts).
  • Changeset: one Promise latch coordinates automatic and manual loading — verified (useTableInfiniteScroll.tsx:183-242; latch test).
  • Changeset: failures pause automatic retry — verified (useTableInfiniteScroll.tsx:191, :217-219; throw, reject and void tests).
  • Changeset: the persistent busy Button owns progress announcements and focus — verified (useTableInfiniteScroll.tsx:435-440; Button's persistent polite region; keyboard and focus tests).
  • Reaching the end loads the next batch, and a Load more Button always offers the same request — verified (useTableInfiniteScroll.tsx:326-407, :423-443).
  • One request at a time across observation, clicks and repeated presses — verified (latch and keyboard tests).
  • A failed automatic request pauses until a manual retry — verified (failure tests).
  • The busy Button keeps focus; when the last batch removes it, focus moves to the scroll region — verified (useTableInfiniteScroll.tsx:303-314; exhaustion focus tests).
  • An empty table that is loading hides only the default "No data", and caller empty content still shows — verified with Table's own wrapper (BaseTable.tsx:1036); false under a caller wrapper that renders afterTable (first finding).
  • Existing tables and plugins are unchanged unless they opt in — verified (BaseTable.tsx:713-751, useBaseTablePlugins.ts:153).
  • The hook and Table admit data mode with flat rows, Table also needs its own wrapper, and the render context gains no field — accurate; the mismatch is the first finding.
  • The focus handoff uses the shared focus-leaving sequence and the shared focus helper is unchanged — verified (useTableInfiniteScroll.tsx:303-314; that helper is not in the diff).
  • Diagnostics warn once per instance through the shared warning helper — verified (useTableInfiniteScroll.tsx:92).
  • A windowed table reports an unknown row total while more rows exist and the exact total at exhaustion — verified (BaseTable.tsx:933-939; TableIncrementalCount.test.tsx).
  • Observation uses Table's block viewport while windowing and the browser viewport otherwise, and a root change disconnects the old observer — verified (useTableInfiniteScroll.tsx:278, :333-340; TableLoadingViewport.test.tsx).
  • With a caller scroll wrapper, Table keeps its default empty state — true for Table, but the hook's Button and requests still run (first finding).
  • The caller-wrapper test fails on the previous head — verified by reading (the previous gate admitted any wrapper).
  • Seven of the sixteen ported count and viewport tests fail on the previous head — not rerun; consistent with that head's code.
  • The five touched suites pass with 201 tests — false: 204 at this head (second finding).
  • The red-first test commit fails on the base, and removing Table's subscription fails the Settle test — verified by reading the tests and the base Table.
  • The unit suites, typecheck, lint and changeset checks pass — consistent with CI at this head.
  • The wide-table Chromium spec runs in CI's browser lane — verified (10 of 10 pass at this head).
  • Size: 19 files, +2,053/−4, 717 product lines, 1,294 test lines, a 506-line hook and 81 lines of growth in existing modules — verified.
  • The public API is the four named entries — verified (the API delta for this head lists the same rows).
  • Existing callers keep their behaviour without a renderState source — verified.
  • Public text carries no internal context — verified.
  • Files with findings: packages/core/src/Table/BaseTable.tsx (admission and comment at 742-748), packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx (admission at 66-73, 187, 423, 474), packages/core/src/Table/TablePluginLoading.test.tsx (no case for a caller wrapper that renders afterTable).
  • Files clear: .changeset/table-infinite-loading.md, apps/sandbox/scripts/next-export-routes.json, apps/storybook/stories/TableInfiniteScroll.stories.tsx, internal/shadcn-registry/routes.lock.json, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx, packages/core/locales/en.json, packages/core/src/Table/TableIncrementalCount.test.tsx, packages/core/src/Table/TableLoadingViewport.test.tsx, packages/core/src/Table/index.ts, packages/core/src/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.ts (path differs from the record; non-blocking), packages/core/src/Table/plugins/infiniteScroll/index.ts, packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.test.tsx, packages/core/src/Table/types.ts, packages/core/src/Table/useBaseTablePlugins.ts, packages/core/src/Table/useTableInfiniteScroll.doc.mjs.

Automated review (maintainer link)

Comment thread packages/core/src/Table/BaseTable.tsx Resolved
Table admits a loading plugin only with its own scroll wrapper, but the hook
still showed its busy Load more Button and ran requests under any wrapper.
A caller scrollWrapper that renders afterTable then showed the default empty
state above a busy Load more Button during the first load.

Table now puts its loading admission on the private runtime context. The
hook's surface, its observation and its requests follow it, and the hook
warns once when Table denies it, so a caller's wrapper gets the whole
loading behavior or none of it. A surface rendered outside any Table has no
runtime to deny it.

Test: a caller wrapper that renders afterTable shows the default empty
state, no Load more surface and no request, with one warning. It fails on
the previous head.
verified_by named a browser spec path that does not exist and a perf test
with no infinite-loading extension. It now names the wide-table browser
spec, the hook suite, and the three Table loading suites. The AR1 row names
the wide-table spec and what it checks; the rest of that row stays pending.
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 11:46
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 12, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 11:46
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3297a8c

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 12, 2026
BaseTable: main keys its column and plugin caches on identities (#10940)
and no longer uses useRef; the import keeps only this branch's
useSyncExternalStore. The loading gate and its runtime-context admission
are unchanged.

@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 loading hook and Table's renderState protocol match their current records, and the hook now follows Table's loading admission, so a caller scrollWrapper keeps the default empty state and gets no Load more Button, sentinel or request. CI has not run on this head because the branch conflicts with main in BaseTable.tsx's React import list; rebase, keeping useSyncExternalStore and dropping useRef, so CI can run.

Non-blocking:

  • Under a caller wrapper that Table denies, the hook still adds its display: grid viewport style (useTableInfiniteScroll.tsx:503), so the "whole loading behavior or none of it" comment at BaseTable.tsx:742-744 overstates it; let Table add the style only when it admits loading, or narrow the comment.
  • The hook doc's usage text and the module record need small fixes: say that a caller scrollWrapper does not load (useTableInfiniteScroll.doc.mjs:19), drop "Pending:" from the changed verification row, and keep Table.perf.test.tsx in verified_by while the Performance row names it.
Claims and files checked
  • Changeset: adds Table infinite loading through the three-field hook — verified (useTableInfiniteScroll.tsx:481-522, Table index.ts:55).
  • Changeset: one Promise latch coordinates automatic and manual loading — verified (useTableInfiniteScroll.tsx:189-249; latch test).
  • Changeset: failures pause automatic retry — verified (useTableInfiniteScroll.tsx:214-248; throw, reject and void tests).
  • Changeset: the persistent busy Button owns progress announcements and focus — verified (useTableInfiniteScroll.tsx:452-457; keyboard and focus tests).
  • Before this change Table had no loading plugin and an empty loading table said "No data" — verified on the base.
  • Reaching the end loads the next batch, and a Load more Button always offers the same request — verified (useTableInfiniteScroll.tsx:357-418, :440-460).
  • One request at a time across observation, clicks and repeated presses — verified (latch and keyboard tests).
  • A failed automatic request pauses until a manual retry — verified (failure tests).
  • The busy Button keeps focus, and when the last batch removes it, focus moves to the scroll region — verified (useTableInfiniteScroll.tsx:314-325; exhaustion tests).
  • An empty loading table hides only the default "No data", and caller empty content still shows — verified (BaseTable.tsx:1034-1037; Settle test).
  • Existing tables and plugins are unchanged unless they opt in — verified (BaseTable.tsx:713-752, useBaseTablePlugins.ts:153).
  • The governing records are current and name the public contract — verified.
  • Admission is data mode with flat rows, plus Table's own wrapper, and the render context gains no field — verified (BaseTable.tsx:745-749; render context type unchanged).
  • The focus handoff uses the shared focus-leaving sequence, and the shared focus helper is unchanged — verified (useTableInfiniteScroll.tsx:314-325; that helper is not in the diff).
  • Diagnostics warn once per instance through the shared warning helper — verified (useTableInfiniteScroll.tsx:92).
  • A windowed table reports an unknown total while more rows exist and the exact total at exhaustion — verified (BaseTable.tsx:934-938; TableIncrementalCount.test.tsx).
  • Observation uses Table's block viewport while windowing and the browser viewport otherwise, and a root change disconnects the old observer — verified (useTableInfiniteScroll.tsx:349; TableLoadingViewport.test.tsx).
  • The count and viewport tests come from the earlier stacked branch — verified (that pull request's file list).
  • Table hands its admission to the hook, whose surface, observation and requests follow it with one warning — verified (BaseTable.tsx:1114-1128; useTableInfiniteScroll.tsx:289, :341-345); "none of it" leaves out the grid style (non-blocking).
  • With a caller wrapper the default empty state stays, and a caller wrapper that renders afterTable gets no Button, no request and one warning; each test fails on the head before it — verified by reading (TablePluginLoading.test.tsx:100-176).
  • The five targeted suites pass with 205 tests — count verified (157 + 28 + 9 + 7 + 4); not yet run on this head.
  • Seven of the sixteen ported count and viewport tests fail before the main merge and pass after — consistent (7 + 9 = 16); not rerun.
  • The red-first test commit fails on the base, and removing Table's subscription fails the Settle test — verified by reading.
  • The wider unit suites, typecheck, lint and changeset checks pass — verified by CI on the previous head; not yet run on this head.
  • The wide-table Chromium spec runs in CI's browser lane against the built story — verified (spec file and its scope line).
  • Scope: one capability under current records, a public API of the four named entries, unchanged behavior for existing callers, and no internal context in public text — verified.
  • Size: 21 files, +2,140/−18, 745 product lines in 13 files, 1,341 test lines, a 523-line hook and 92 lines of growth in existing modules — verified; the remainder also includes a 26-line record edit.
  • App size will come from CI's package-size report — not available yet, since CI has not run on this head.
  • The record change is limited to the verification map, names test files that exist, keeps unbuilt checks pending and changes no contract row — verified; it also drops the existing perf test path (non-blocking).
  • Files with notes: packages/core/src/Table/BaseTable.tsx (import conflict with main; comment at 742-744), packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx (grid style at 503), packages/core/src/Table/useTableInfiniteScroll.doc.mjs (wrapper rule at 19), docs/specs/components/Table/plugins/infiniteScroll/useTableInfiniteScroll.spec.md (verification row 196, Performance row 199, verified_by).
  • Files clear: .changeset/table-infinite-loading.md, apps/sandbox/scripts/next-export-routes.json, apps/storybook/stories/TableInfiniteScroll.stories.tsx, internal/shadcn-registry/routes.lock.json, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs, packages/cli/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx, packages/core/locales/en.json, packages/core/src/Table/TableIncrementalCount.test.tsx, packages/core/src/Table/TableLoadingViewport.test.tsx, packages/core/src/Table/TablePluginLoading.test.tsx, packages/core/src/Table/index.ts, packages/core/src/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.ts, packages/core/src/Table/plugins/infiniteScroll/index.ts, packages/core/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.test.tsx, packages/core/src/Table/tableRuntime.ts, packages/core/src/Table/types.ts, packages/core/src/Table/useBaseTablePlugins.ts.

Automated review (maintainer link)

}
return {
...props,
xstyle: [...props.xstyle, styles.viewport],

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 adds display: grid for any data-mode, flat-row context, before Table's admission is known, and types.ts:697 tells a caller scrollWrapper to apply xstyle. So under a caller wrapper that Table denies, the wrapper's display still changes even though no surface renders. Let Table add this style only when it admits loading, or narrow the comment at BaseTable.tsx:742-744.

'Incrementally load flat Table data with one shared automatic/manual request lifecycle. Returns a stable TablePlugin<T>. A localized Load more Button stays available while hasMore is true; IntersectionObserver adds automatic loading when the end sentinel is visible. The Button remains mounted and focusable while busy and owns the loading announcement.',
usage: {
description:
'Call useTableInfiniteScroll<T>({hasMore, isLoading, onLoadMore}) and pass the result to <Table plugins={{infiniteScroll: plugin}} />. Keep accumulated rows in your own state. onLoadMore must return a Promise<void> that settles when the batch work completes. A fulfilled request finishes after settlement and a subsequent committed isLoading=false; a true loading phase is not required. Visible short batches can automatically request again in a later task, so update hasMore when the source is exhausted. A resolved request that appends no rows must not incorrectly claim endless more data. Throws, rejections and invalid non-Promise results pause automatic loading; the manual Button can retry once controlled loading is false. The hook does not render product errors or cancel transport. For a new dataset, key and remount the component owning both the hook and its Table, not only the Table child; prevent stale responses from committing caller data yourself. Children mode and unsupported row models do not load and emit a deduplicated development warning. Body modifiers must declare compatible rowModel: flat. Observation uses the Table scroll area while the Table windows its rows, and the browser viewport otherwise, with zero look-ahead and no ancestor discovery. Without IntersectionObserver, the same manual command works.',

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: a caller scrollWrapper now gets no loading and one development warning, but this text names only children mode and unsupported row models. Suggest adding: "A caller scrollWrapper does not load; use Table's own wrapper."

| FR1, FR3-FR7, FR14, ORD1-ORD5 | Pending deterministic observer/manual events and controlled-commit tests in the module unit suite. | Reentry; Promise pending/fulfilled/rejected with controlled true/false; synchronous fulfillment without a true phase; invalid non-Promise result and operable manual recovery; visible short batches; callback replacement; hook-owning reset versus child-only remount. | Overlap, stale-false rearm, same-stack recursion, immediate failure loop, dead-ended short batches, or prior-generation request/paint fails. |
| FR2, FR8-FR10, FR12-FR13, ORD6-ORD7 | Pending render/composition tests through the parent mode/render plan. | Data/children/unknown context; flat/non-flat/custom; empty initial loading; chrome/refs; caller errors. | Invalid DOM, children sentinel, repeated warning, replaced chrome, contradictory empty/progress, or duplicated error UI fails. |
| FR11, PR1-PR5 | Pending lifecycle and geometry tests under StrictMode. | Parent block root/viewport fallback/nested ancestor clipping; root/node replacement; ready/loading/exhausted/false-to-true; absent IO; unmount. | Ancestor discovery, leaked/multiple observers, stale entries, callback churn, or new-generation effects fails. |
| AR1, AR3-AR7 | `TableInfiniteScrollWide.a11y.chromium.spec.ts` checks that loading keeps a wide table's intrinsic width in LTR and RTL. Pending: DOM/tree, axe, browser keyboard/touch/zoom/motion/focus flows. | Ready/busy/manual/unsupported IO, append, focused and unrelated-focus exhaustion, fitting Scroll region. | Native disabling loses focus, busy requests fire, missing manual command, false row semantics, or focus handoff scroll/steal fails. |

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: "Pending:" is temporary status; keep the checks this row requires without it. Also, verified_by (lines 14-24) drops Table.perf.test.tsx, which exists, while the Performance row (line 199) still names it: keep the path or update the row.

@cixzhang
cixzhang marked this pull request as draft November 12, 2026 14:49
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 14:50
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 81fcf8f

@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. useTableInfiniteScroll and Table's renderState loading protocol match the current module and Table records, and every CI check on this head passes. The earlier caller-scroll-wrapper mismatch stays fixed: Table and the hook now admit loading only with Table's own scroll wrapper, so a caller wrapper keeps its "No data" row with no Load more button and no request.

Three earlier non-blocking notes still apply: mention the caller-wrapper case in the hook doc, apply the hook's display: grid wrapper style only when Table admits loading, and drop the temporary "Pending:" wording from the record's AR1 row while keeping Table.perf.test.tsx in verified_by.

Claims and files checked
  • Changeset: the three-field hook adds Table infinite loading. Verified: hook source and CI's API report.
  • Changeset and description: one request latch serves automatic loading, clicks and repeated presses. Verified: latch unit test; in a real browser a second Enter on the busy button adds no request.
  • Changeset and description: a failure pauses automatic loading until a manual retry. Verified: throw, reject and non-Promise tests.
  • Changeset and description: the busy button keeps focus and owns the loading announcement. Verified: keyboard unit test; the browser probe shows aria-busy, kept focus and no extra live region.
  • When the last batch removes a focused Load more button, focus moves to the scroll region. Verified: unit tests and the browser probe.
  • An empty loading Table hides only the default "No data"; caller empty content still shows. Verified: Table loading tests.
  • Existing Tables and plugins behave as before unless they opt in. Verified: every Table test passes; Table visual regression is unchanged.
  • Loading needs data mode, flat rows and Table's own scroll wrapper; the render context gains no field; the hook follows Table's decision and warns once. Verified: Table and hook source, caller-wrapper tests.
  • The focus handoff uses the shared focus-leaving helpers, and the focus-return utility is unchanged. Verified.
  • Diagnostics warn once per hook instance through the shared helper. Verified.
  • A windowed Table reports an unknown row count while more rows exist and the exact count after exhaustion. Verified: row-count tests.
  • Observation uses Table's block viewport while windowed, else the browser viewport, and drops the old observer on a root change. Verified: viewport tests.
  • The caller-wrapper tests fail on the earlier heads. Verified: those heads admitted any wrapper or lacked the hook's gate.
  • The targeted suites pass with 205 tests. Verified: CI counts 157 + 28 + 9 + 7 + 4.
  • Seven of the sixteen ported count and viewport tests failed before the main merge. Consistent with the code (five need the more-rows signal, two the block root); not re-run.
  • Red-first on main, type check, knowledge check, lint, changeset check and the wider suites. CI passes all of them on this head; the local counts were not recounted.
  • Removing Table's subscription fails the stable-source test. Verified by reading the test.
  • The wide-table browser spec runs in CI. Verified: its 10 cases pass.
  • The public API is exactly the hook, its config type, the plugin field and its type. Verified: CI's API report.
  • Size: 21 files, +2140/−18, 745 product lines and 1,341 test lines. Verified.
  • The record change only updates verification targets and keeps unbuilt checks pending. Verified; it also drops the perf test target (non-blocking note).
  • Files, all 21 visited. Clear: the changeset, both route lists, the story, both template block files, the locale catalog, BaseTable.tsx, tableRuntime.ts, types.ts, useBaseTablePlugins.ts, both index files, the four unit test files and the browser spec. Notes: the hook (grid style under a denied wrapper), the hook doc (caller-wrapper case) and the module record (status wording, dropped perf target).

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor Author

Decision: D-20261112-474

@cixzhang
cixzhang merged commit 58b844d into main Nov 12, 2026
138 checks passed
@github-actions
github-actions Bot deleted the feat/table-infinite-loading branch November 13, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 81fcf8fc 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants