diff --git a/AGENTS.md b/AGENTS.md index e092489f..c0fc6e36 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,7 +21,7 @@ | `containers/MetricOverviewContainer.jsx` | `${dashboardSource}/${activeRegion}/${slug}/index.json` | title, description, `type: 'line'|'table'`, axes, columns, data, annotations | | `containers/SummaryMetricContainer.jsx` | same per-metric endpoint | buckets populations under 5% into "Other" | -`src/lib/withFetch.jsx` **is the entire data layer** and is used in exactly those three files: `withFetch(props => url)(Container)` passes a `dataFetch` prop (`pending`, `rejected`, `fulfilled`, `value`, `reason`), refetches when the URL changes (back to pending first), rejects on non-2xx, and drops a response that arrives after a newer request started. Responses are kept in `lib/fetchCache.js` until the page reloads: a URL fetched before is fulfilled from the first render, components asking for one URL at once share a request, and a failed request is forgotten so the next one tries again. Each one handles `dataFetch.pending` / `.rejected` / `.fulfilled` itself: `DashboardContainer` renders `views/Spinner.jsx` while pending, the two metric containers render a same-sized placeholder (`views/MetricOverviewPlaceholder.jsx`, `views/SummaryMetricPlaceholder.jsx`) so nothing moves when the data arrives, and all three render `views/Error.jsx` on rejection. All reshaping is client-side, in the `formatData` of `ChartContainer`, `DataTableContainer`, and `SummaryMetricContainer` (`ChartContainer` sorts populations by max y and drops nulls; `DataTableContainer` sorts rows by value descending). +`src/lib/withFetch.jsx` **is the entire data layer** and is used in exactly those three files: `withFetch(props => url)(Container)` passes a `dataFetch` prop (`pending`, `rejected`, `fulfilled`, `value`, `reason`), refetches when the URL changes (back to pending first), rejects on non-2xx, and drops a response that arrives after a newer request started. Responses are kept in `lib/fetchCache.js` until the page reloads: a URL fetched before is fulfilled from the first render, components asking for one URL at once share a request, and a failed request is forgotten so the next one tries again. On a dashboard URL, `src/index.jsx` calls `withFetch`'s `prefetchJSON` for that dashboard's `index.json` before rendering, so the request doesn't wait for the dashboard's code; `lib/utils.js`'s `dashboardIndexUrl` builds that URL for both. Each one handles `dataFetch.pending` / `.rejected` / `.fulfilled` itself: `DashboardContainer` renders `views/Spinner.jsx` while pending, the two metric containers render a same-sized placeholder (`views/MetricOverviewPlaceholder.jsx`, `views/SummaryMetricPlaceholder.jsx`) so nothing moves when the data arrives, and all three render `views/Error.jsx` on rejection. All reshaping is client-side, in the `formatData` of `ChartContainer`, `DataTableContainer`, and `SummaryMetricContainer` (`ChartContainer` sorts populations by max y and drops nulls; `DataTableContainer` sorts rows by value descending). Metric `description` strings are rendered as inline Markdown through `markdown-it('zero')` with only `link` and `entity` enabled plus the `markdown-it-sup` plugin, via `dangerouslySetInnerHTML`. The dashboard description in `views/Dashboard.jsx` enables only `emphasis`. `src/tests/jest/MetricOverview.test.jsx` exists **specifically to guard that sanitization** — never widen the enabled-rules list without extending that test. @@ -54,7 +54,7 @@ tests/playwright/ └── utils.js shared helpers: formatPercent, linkWorks, linksWork, flagForUpdate, metricTitleIsCorrect, changeRegionAndWaitForMetrics ``` -There is no `pages/`, `store/`, `hooks/`, `api/`, `locales/`, or `data/`. `index.html` at the repository root is Vite's entry point (with a hardcoded `og:image` and the `