Skip to content

docs: Toast needs no provider; Table hooks name their row-type generic - #12696

Closed
josephfarina wants to merge 2 commits into
mainfrom
ca2-answers-4
Closed

josephfarina wants to merge 2 commits into
mainfrom
ca2-answers-4

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Reader impact

In blind tests, agents still read package files for two things:

  1. Toast: whether useToast() needs a provider or a mounted ToastViewport. The Toast page's first sentence now says it does not.
  2. Table hook generics: seven Table hooks take the row type T, but their config never mentions it. TypeScript cannot infer T, so it becomes Record<string, unknown>, and <Table<Walk>> rejects the plugin (TablePlugin<Record<string, unknown>> is not assignable to TablePlugin<Walk>). The docs now say so and show typed examples.

Source of truth

  • packages/core/src/Toast/useToast.tsx: useToast reads ToastContext (set by LayerProvider's toast host and by ToastViewport), else getFallbackContext() mounts a ToastViewport on document.body and warns once in development.
  • useTableSortable<T, TSortKey>(config: UseTableSortableConfig<TSortKey>), useTablePagination<T>(config: UseTablePaginationConfig), useTableFiltering<T>, useTableColumnSettings<T, TColumnKey>, useTableColumnResize<T>, useTableInfiniteScroll<T>, useTableStickyColumns<T>: none of these configs mention T. Hooks whose config uses T (selection, row expansion, row status, row index, tree data) infer it and are unchanged.
  • Checked with tsc against the Core sources: without <Walk>, plugins={{sort: plugin}} on a TableColumn<Walk>[] table fails with TS2322; with <Walk> it passes. A sort-key or column-key union (or keys inferred from defaultSort / columns in the State hooks) also needs the second type argument: useTableSortable<Walk, WalkSortKey>.

Correction

  • Toast: the first sentence (en, zh, dense) says to show one with const showToast = useToast(), which needs no provider or mounted ToastViewport, and how the fallback viewport works.
  • Table hooks: each of the seven hook pages (en, zh where present, dense) says T is the row type, that it cannot be inferred and falls back to Record<string, unknown>, and to pass it (useX<Walk>(…)). The sortable and column-settings pages also cover the key type argument.
  • Typed examples: useTableSortable (both examples typed, with a typed comparator and useState<TableSortState>), a new useTablePagination example (it draws the page controls and you pass the current page's rows), and useTableFiltering. The sortConfig / columnSettingsConfig returns of the State hooks say to pass the same type arguments on.
  • Every example was compiled with tsc against Core before this PR.

Evidence

astryx component Toast, astryx component useTablePagination and astryx component useTableSortable on this branch show the new text.

Scope

Components: Toast, useTableSortable, useTableSortableState, useTablePagination, useTableFiltering, useTableColumnSettings, useTableColumnSettingsState, useTableColumnResize, useTableInfiniteScroll, useTableStickyColumns

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project node packages/cli/test/{experimental-isolation,core-doc-quality,core-doc-types,core-prop-docs,golden-reads,docs-graph,docs-topic-refs}.test.mjs: 82 passed, 1 failed. The failure ("doctor reports an invalid installed set", a snapshot mismatch) also fails on this machine on clean main, and no golden changed.
  • pnpm exec vitest run --project ui packages/core/src/docPropLiterals.test.ts packages/core/src/docPropReferences.test.ts: 22 passed.
  • pnpm review:pre: 0 findings.

@vercel

vercel Bot commented Nov 18, 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 18, 2026 10:47pm UTC

Request Review

@josephfarina
josephfarina marked this pull request as ready for review November 18, 2026 21:34
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 18, 2026
@astracat-bot

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 10:54 PM UTC

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec e3fe3ab

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 734a5fd

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) — — · ✓ · ✗
6 more components
Component Size LoC Visual · A11y · RTL
TableRow 7.1 kB (0) · 4.0 kB CSS (0) — — · ✓ · ✗
Table 121.7 kB (0) · 19.8 kB CSS (0) — — · ✓ · —
TableCell 104.6 kB (0) · 19.3 kB CSS (0) — — · ✓ · ✓
TableHeaderCell 104.4 kB (0) · 19.1 kB CSS (0) — — · ✓ · ✓
TableSelectionToolbar 76.7 kB (0) · 14.1 kB CSS (0) — — · ✓ · ✓
Toast · Storybook 105.6 kB (0) · 11.1 kB CSS (0) 1,739 (0) — · ✓ · ✓

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

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.

Current run: CI concluded cancelled; parts of this report may be missing.


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.

Changes requested. The Toast and row-type corrections match the code, and every new example compiles under strict TypeScript, but one change hides the hook's usage code from the default CLI answer.

  • The first useTableSortable example is now 28 lines (useTableSortable.doc.mjs:18-45), over the CLI's 20-line limit for the short answer, so astryx component useTableSortable and --dense no longer print any usage code; keep the first example at 20 lines or fewer, for example by leading with the shorter useTableSortableState example.

The same limit keeps the new useTablePagination example out of that hook's short answer. A small wording fix is suggested inline on useTableColumnSettingsState.doc.mjs.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim (changeset): the Toast page's first sentence says useToast() needs no provider or mounted viewport. Verified: Toast.doc.mjs:137, and it is the lead paragraph astryx component Toast prints.
  • Claim (changeset): the seven hooks say T is the row type, is not inferred, falls back to Record<string, unknown>, and must be passed. Verified: each hook's signature declares T with no default and a config that never names it (for example useTableSortable.tsx:376-379, useTablePagination.tsx:203-205).
  • Claim (changeset): their examples are typed. Verified: both sortable examples, the new pagination example and the filtering example; the other four hooks have no examples.
  • Claim (changeset): no API or behavior changes. Verified: the built API surfaces of Core and the seven themes are identical at base and head.
  • Claim (description): useToast uses the provider's or a ToastViewport's context, else mounts a fallback viewport on document.body and warns once in development. Verified: useToast.tsx:140-144, :69-107, toastHost.tsx:228-241, devWarning.ts:125-136.
  • Claim (description): hooks whose config names T infer it. Verified: those configs take UseXConfig<T>; checked with tsc for row status.
  • Claim (description): without <Walk> a typed Table rejects the plugin with TS2322, and with it the code compiles. Verified with tsc for sortable, pagination, column resize, sticky columns and infinite scroll.
  • Claim (description): a key union, or keys the State hooks infer, needs the second type argument. Verified with tsc (TS2345 for sortable and column settings).
  • Claim (description): every example compiles against Core. Verified with tsc at this head.
  • Claim (description): the pagination plugin draws the controls and the caller passes the current page's rows. Verified: useTablePagination.tsx only wraps the table with Pagination and never slices data.
  • Claim (description): the CLI shows the new text for Toast, useTablePagination and useTableSortable. Verified, but the useTableSortable short answer also loses its usage block (the finding above).
  • Claim (description): the doc and prop-doc test suites pass apart from one machine-specific failure, and the pre-review report has 0 findings. Verified: 83 node tests and 22 ui tests pass here, and the pre-review report has 0 findings.
  • File .changeset/toast-no-provider-table-hook-row-type.md: clear.
  • File packages/core/src/Toast/Toast.doc.mjs: clear.
  • File packages/core/src/Table/useTableSortable.doc.mjs: finding (short-answer usage code lost).
  • File packages/core/src/Table/useTablePagination.doc.mjs: clear; its new example is also over the short-answer limit.
  • File packages/core/src/Table/useTableFiltering.doc.mjs: clear.
  • File packages/core/src/Table/useTableColumnResize.doc.mjs: clear.
  • File packages/core/src/Table/useTableColumnSettings.doc.mjs: clear.
  • File packages/core/src/Table/useTableInfiniteScroll.doc.mjs: clear.
  • File packages/core/src/Table/useTableStickyColumns.doc.mjs: clear.
  • File packages/core/src/Table/plugins/sortable/useTableSortableState.doc.mjs: clear.
  • File packages/core/src/Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs: non-blocking wording suggestion.

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 734a5fd

@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 finished on this head yet. The Toast and row-type corrections match the code, every changed example compiles under strict TypeScript, and the first useTableSortable and useTablePagination examples now fit the CLI's short answer, so astryx component prints their typed usage.

  • Miss: (non-blocking) the --dense return notes for sortConfig (useTableSortableState.doc.mjs:151) and columnSettingsConfig (useTableColumnSettingsState.doc.mjs:145) still say only to pass the config on; consider naming the type arguments there too, as the English notes now do.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim (changeset): the Toast page's first sentence says useToast() needs no provider or mounted viewport. Verified: Toast.doc.mjs:137, the lead paragraph astryx component Toast prints.
  • Claim (changeset): the seven hooks say T is the row type, is not inferred, falls back to Record<string, unknown>, and must be passed. Verified: each signature declares T with no default and a config that never names it (for example useTableSortable.tsx:376-379, useTablePagination.tsx:203-205).
  • Claim (changeset): their examples are typed. Verified: both sortable examples, the pagination example and the filtering example; the other three hooks have no examples.
  • Claim (changeset): no API or behavior changes. Verified: the built API surfaces of Core and the seven themes are identical at base and head.
  • Claim (description): useToast uses the provider's or a ToastViewport's context, else mounts a fallback viewport on document.body and warns once in development. Verified: useToast.tsx:144, :69-107, ToastViewport.tsx:1031, utils/devWarning.ts:131.
  • Claim (description): hooks whose config names T infer it and are unchanged. Verified: selection, row expansion, row status, row index and tree data take a config typed with T, and none of their docs change.
  • Claim (description): without the row type a typed Table rejects the plugin with TS2322, and with it the code compiles. Verified with tsc for all seven hooks.
  • Claim (description): a key union, or keys the State hooks infer, needs the second type argument. Verified with tsc (TS2345 for sortable and column settings).
  • Claim (description): every example compiles against Core. Verified with tsc at this head for the four changed examples.
  • Claim (description): the pagination plugin draws the controls and the caller passes the current page's rows. Verified: useTablePagination.tsx never slices data.
  • Claim (description): the State hooks' return notes say to pass the same type arguments on. Verified for the English notes; the dense notes are unchanged (non-blocking note above).
  • Claim (description): the CLI shows the new text for Toast, useTablePagination and useTableSortable. Verified in the default and --dense reads.
  • Claim (description): the doc and prop-doc tests pass apart from one machine-specific failure, and the pre-review report has 0 findings. Verified: 83 node tests and 22 ui tests pass here, and the pre-review report has 0 findings.
  • File .changeset/toast-no-provider-table-hook-row-type.md: clear.
  • File packages/core/src/Toast/Toast.doc.mjs: clear.
  • File packages/core/src/Table/useTableSortable.doc.mjs: clear; the earlier short-answer finding is fixed.
  • File packages/core/src/Table/useTablePagination.doc.mjs: clear.
  • File packages/core/src/Table/useTableFiltering.doc.mjs: clear.
  • File packages/core/src/Table/useTableColumnResize.doc.mjs: clear.
  • File packages/core/src/Table/useTableColumnSettings.doc.mjs: clear.
  • File packages/core/src/Table/useTableInfiniteScroll.doc.mjs: clear.
  • File packages/core/src/Table/useTableStickyColumns.doc.mjs: clear.
  • File packages/core/src/Table/plugins/sortable/useTableSortableState.doc.mjs: clear; its dense return note is unchanged (non-blocking).
  • File packages/core/src/Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs: clear; the earlier wording note is fixed, and its dense return note is unchanged (non-blocking).

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12367 [experimental] export: checks the file it wrote and names the one file to share
  Author: @josephfarina
- #12405 [experimental] export: the size output names each part of the file under its JSON key
  Author: @josephfarina
- #12295 fix(Markdown): keep task lists inside their column
  Author: @josephfarina
- #12696 docs: Toast needs no provider; Table hooks name their row-type generic
  Author: @josephfarina
- #12733 [experimental] export: a package linked from a folder inside the project is a package, so --reverse gives the page back
  Author: @josephfarina
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12859.

@github-actions
github-actions Bot deleted the ca2-answers-4 branch November 20, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 734a5fda Deployed Nov 18, 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