Skip to content

Drop QA SSR; Demographics tab (live) + Data quality tab (coming soon) - #82

Merged
neuromechanist merged 3 commits into
mainfrom
feature/issue-81-dataset-tabs
May 27, 2026
Merged

neuromechanist merged 3 commits into
mainfrom
feature/issue-81-dataset-tabs

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Closes #81.

  • Removes the QA fetch from the SSR critical path. buildQaAggregates was walking data.nemar.org/<id>/qa/ recursively and fetching every per-file _dataqual.json at request time. For HBN-class datasets that was 5–28 s cold SSR (on005509 was hitting 503 because it overran the Worker subrequest budget). Page now paints from 2 backend fetches (landing + metadata).
  • Replaces inline <QualityPanel> with <DatasetTabs> carrying two tabs:
    • Demographics (primary) — client-side fetch of participants.tsv, parses sex + age columns, renders a small M/F/Other donut + age histogram stacked by sex.
    • Data quality — "Coming soon" placeholder linking to nemar-cli#511 (precomputed qa/aggregates.json artifact).
  • Leaves QualityPanel, AgeGenderChart, buildQaAggregates untouched in the tree. Dormant — ready to revive once Epic: Website compute surfaces (#493) #511 ships.

Lightweight on purpose: demographics is one HTTP fetch + ~70 KB TSV + deterministic SVG render. No skeleton machinery, no caches.

Test plan

  • bun run typecheck clean
  • bun run lint clean
  • bun run test — 387 pass (13 new participants.tsv parser cases)
  • bun run build clean
  • Local dev verification (puppeteer):
    • on005509 (HBN R5, 330 participants): Demographics tab renders donut showing ~2:1 male/female + 3-bucket age histogram (0-9, 10-19, 20-29). Data quality tab shows coming-soon copy with nemar-cli#511 link.
    • nm000103 (HBN-EEG NC, 447 participants, 258 M / 189 F): same flow, charts populated correctly.
    • Tab keyboard nav: ArrowLeft/Right wrap, Home/End jump to ends, focus moves with selection per ARIA tabs spec automatic-activation.
  • Post-deploy: cold SSR ttfb < 1.5 s for on005509 (was 5.2 s degraded) and on005514 (was 28 s).

Files

  • src/lib/participants.ts (+118) — TSV parser, sex/age normalization, fetch helper.
  • src/lib/participants.test.ts (+133) — 13 cases including column variants, sex tokens, NA handling.
  • src/lib/render-sex-donut.ts (+87) — pure renderSexDonutSvg(counts).
  • src/lib/render-age-gender.ts (+83) — pure renderAgeGenderStackedSvg(ages, sexes). Reuses bucketAgesBySex from qa.ts.
  • src/components/DatasetTabs.astro (+325) — tablist UI + inline client script (tab switching, keyboard nav, demographics hydration).
  • src/pages/dataset/[id].astro (-12 / +8) — drop getQaAggregates, swap QualityPanel for DatasetTabs.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 27, 2026 •

Copy link
Copy Markdown

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review pass — 3 sonnet agents

code-reviewer (pr-review-toolkit:code-reviewer)

  • Important / DOM collisions: hardcoded id="dtab-demo", dpanel-demo, etc. would collide if a second instance of <DatasetTabs> ever lands on the same page (the click + keydown delegates already scan the document). Fixed in 3dea71c: ids now carry a dt-${datasetId}- prefix derived from props.
  • Important / duplicate landmark labeling: outer <section aria-label="Dataset summary"> + inner <div role="tablist" aria-label="Dataset summary"> made AT announce the name twice on entry. Fixed in 3dea71c: removed the section-level aria-label (an unlabeled section isn't exposed as a landmark, which is the intent here — the tablist already labels itself).
  • Confirmed correct: donut math, stacked-bar geometry, ARIA tabs roving tabindex, theme tokens, is:global justification, no mocks / no emoji / no AI attribution.

silent-failure-hunter (pr-review-toolkit:silent-failure-hunter)

  • Medium / error swallowing: fetchParticipants was collapsing 404 + 403 + 500 + network errors into the same null return with only console.warn. A 5xx regression on data.nemar.org would have looked identical to "this dataset doesn't ship participants.tsv". Fixed in 3dea71c: explicit status === 404 branch stays silent; other non-ok responses + caught exceptions now console.error with status + url.
  • Low / copy nit: empty-state message "no usable sex or age columns" was technically misleading when the columns exist but every cell is n/a. Fixed in 3dea71c: now reads "no sex or age values to chart."
  • Confirmed safe: tab-switch early-returns are routine "not my event" guards. aria-busy has no stuck-busy path. encodeURIComponent on the version string is fine for current semver shapes.

pr-test-analyzer (pr-review-toolkit:pr-test-analyzer)

  • Important / coverage gap: parser had no test for a short row missing its trailing tab (common in OpenNeuro files when a participant has nothing recorded). Fixed in 3dea71c.
  • Important / coverage gap: no test pinning the age-only-column shape (sexes still pushes null per row to keep index alignment with ages). Fixed in 3dea71c.
  • Explicitly rejected: unit tests for renderSexDonutSvg / renderAgeGenderStackedSvg — pixel-geometry assertions would be implementation-coupled; puppeteer arc-length sanity check (M ≈ 67%, F ≈ 33% on on005509) is the right verification level.
  • Explicitly rejected: jsdom test for the DatasetTabs client script — DOM wiring + real fetch is exactly the puppeteer use case, and AGENTS.md's no-mocks rule rules out the alternative.

389/389 tests green, lint clean, typecheck clean, build clean.

@neuromechanist
neuromechanist merged commit ec22e25 into main May 27, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-81-dataset-tabs branch May 27, 2026 20:30
neuromechanist added a commit that referenced this pull request Sep 28, 2026
Staleness and missing data now have their own states instead of
falling through to OK:

- An unreadable generated_at is a warning ("Snapshot time is unknown"),
  not a fresh snapshot.
- A snapshot with no sections and no section errors reads "No data"
  instead of "All clear"; a section with no metrics is "No data", not
  OK, and is listed in the attention summary as unknown.
- Each section's updated_at is read against the snapshot's own time:
  past 3 hours (36 for the daily pushed storage and egress sections) it
  reads "Out of date" on its badge, unfolds, and gets an attention item.
  An old snapshot is said once, not once per section.

The storage card follows the same rules and the collector contract
from nemar-observability#82: the section's own "Data storage" label, a
failed-collection state, and "Measured <day>" only when the hint names
the CloudWatch day, else "Received <day>". Catalog figures now link to
the catalog block, which has no card of its own.

Tested: bun run test (admin-overview suite; storage cases use a
fixture built by #82's collector over its real CloudWatch capture,
marked contract-derived until a live snapshot carries the section),
bun run typecheck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop QA from SSR; tabs: Demographics (live) + Data quality (coming soon)

1 participant