Skip to content

Phase 2: Dataset detail page + on* provenance + version switcher - #8

Merged
neuromechanist merged 3 commits into
feature/issue-1-epic-nemar-redesignfrom
feature/issue-3-phase2-dataset-detail
May 15, 2026
Merged

neuromechanist merged 3 commits into
feature/issue-1-epic-nemar-redesignfrom
feature/issue-3-phase2-dataset-detail

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of #1. Lands /dataset/<id> consuming the now-live data.nemar.org/<id>/{metadata.json, manifest.json} (issue nemarOrg/nemar-cli#449) plus a dedicated provenance surface for on* OpenNeuro-derived datasets.

Closes #3.

What landed

Library layer (src/lib/)

  • neuroschema.ts — types for NeuroschemaDataset, LandingPayload, Manifest, mirroring the live data.nemar.org responses
  • data-api.ts — typed getLanding / getMetadata / getManifest + fetchManifestEntryText with abortable timeouts; 404 -> null, network errors throw
  • provenance.ts — nm* is native, on* is derived. Best-effort resolution of the original OpenNeuro ID via related_identifiers DERIVED relations, URL/DOI patterns, with a last-ditch on->ds prefix swap. listMirrorVersions() returns every vN.0.0 newest-first per the policy in nemar-cli#448 comment.
  • bids-tree.ts — folds manifest into a nested tree with size aggregates, numeric+locale-aware sort (sub-2 before sub-10), file classifier for Vis/View buttons
  • markdown.ts — dep-free CommonMark subset (headings, paragraphs, lists, code fences + inline code, bold/italic, links + autolinks, hr); HTML-escapes everything; rejects javascript: / data: URLs

Components

Chip, DoiBadge (copy-on-click), ActionBar (Download / Compute stub / Issues / GitHub / OpenNeuro), ProvenanceCard, VersionSwitcher (segmented tabs + overflow), AuthorList (with ORCID icons + affiliations), BidsTree + BidsDirChildren (recursive collapsible), Readme (markdown rendering), DetailRail (sticky right rail).

Route

src/pages/dataset/[id].astro — SSR, parallel landing + metadata fetch, version via ?v= param, README fetched from manifest entry's presigned URL, graceful 404 + manifest-unavailable states.

Two new design surfaces

Provenance card for on* datasets

  • Title: "NEMAR-curated copy of OpenNeuro ds00xxxx"
  • Body explains the major-bump-per-pull policy in plain English
  • 2x2 DOI parity grid: NEMAR DOI ↔ OpenNeuro DOI (with "unknown" fallback)
  • Two CTAs: "View original on OpenNeuro" + "View as-imported mirror (vN.0.0)"
  • "All mirror snapshots" <details> when multiple vN.0.0 exist

First-class version switcher

  • Segmented tab strip below the header card with version tag + date + optional mirror chip on vN.0.0
  • Overflow <details> dropdown when > 4 versions
  • URL-bound: /dataset/<id>?v=v1.0.0 deep-links to a specific version
  • Hidden entirely for single-version datasets

Verified live

URL Expected Got
/dataset/nm000104 Native, 5,686-entry manifest ✅ Header + action bar + BIDS tree (lazy-expanded), no provenance card
/dataset/on005262 Derived; provenance card with DOI parity ✅ Card title shows NEMAR-curated copy of OpenNeuro ds005262, BIDS tree expanded
/dataset/nm000103 Manifest currently 404 ✅ Graceful "Manifest unavailable" panel; rail still populated from metadata.json with 8 authors + ORCIDs + related identifiers
/dataset/does-not-exist 404 ✅ Returns 404 status

Tests + checks

  • bun run typecheck — 0 errors across 46 files
  • bun run test — 69/69 (Phase-1 37 still pass + 32 new across data-api, provenance, bids-tree, markdown)
  • Browse-captured screenshots in screenshots/peer/ (will be moved to per-PR archive on merge)

Test plan

  • CI (when added later)
  • Cloudflare Pages preview deploys
  • Manual: navigate from /discover to a dataset card; detail page loads
  • Manual: visit /dataset/on005262; click "View as-imported mirror" — URL gains ?v=v1.0.0, version switcher highlights it
  • Manual: click Compute button; "coming with Phase 5" modal opens
  • Manual: click "Download zip" on a published version (currently the archive route isn't deployed; this surfaces as a 404 — issue tracked for Phase 5)
  • Manual: keyboard tab through action bar + version switcher + tree summary rows; verify focus rings
  • Manual: dark theme parity on detail + provenance card

Out of scope

  • QA data quality charts + HED wordcloud (Phase 3 / Phase 3: Data quality + HED visualization (website side) #4)
  • Live EEG viewer for .set files (Phase 5 — Vis button currently shows "soon" tag)
  • TSV viewer for .tsv files (Phase 5 — View button currently shows "soon" tag)
  • NSG REST connector backend (Phase 5)
  • archives/<v>.zip route on data.nemar.org — currently the Download zip link 404s. Either nemar-cli ships the archive route, or we point Download zip at https://data.nemar.org/<id>/<v>/manifest.json and let users fetch with rclone

Follow-ups

  1. Add the archive route on data.nemar.org so Download zip resolves (probably 5 lines in nemar-cli's data-router)
  2. Backfill participants and file_size in api.nemar.org/datasets for OpenNeuro-derived rows so Discover cards aren't sparse
  3. Add IsDerivedFrom related_identifiers to all on* datasets so provenance auto-resolution doesn't have to rely on the on->ds prefix swap fallback

…-tree + markdown

Lib layer for the upcoming dataset detail page.

- neuroschema.ts: types for NeuroschemaDataset, LandingPayload, Manifest
  (mirrors the live data.nemar.org responses verified this session)
- data-api.ts: typed getLanding/getMetadata/getManifest + fetchManifestEntryText
  with timeouts. Honors PUBLIC_DATA_BASE_URL override; 404 -> null, network
  errors throw so callers can render the right empty state
- provenance.ts: detect on*/ds* parity. nm* is native; on* is derived with
  best-effort original ds id resolution (related_identifiers DERIVED relations,
  URL host pattern, DOI pattern, last-ditch on->ds prefix swap). The mirror
  version is the highest vN.0.0 per the NEMAR policy that every OpenNeuro pull
  is a major version bump (see nemarOrg/nemar-cli#448 comment thread).
  listMirrorVersions returns every vN.0.0 newest-first.
- bids-tree.ts: fold manifest into nested TreeNode with size aggregates,
  numeric+locale-aware sort (sub-2 before sub-10). classifyFile gates the
  per-file Vis/View buttons by extension.
- markdown.ts: dep-free CommonMark subset (headings, paragraphs, lists,
  code fences + inline code, bold/italic, links + autolinks, hr). HTML-escapes
  everything and rejects javascript:/data: URLs. Scope deliberately small;
  follow-ups can add tables/blockquotes when a real README needs them.

69/69 unit tests passing.
…, README

Components:
- DetailHeader-equivalent inline in [id].astro (ID + lineage label + title +
  lede + modality chips + action row + DOI badge)
- ActionBar: Download zip, Compute (stub modal pointing at Phase 5 + NSG),
  Issues, GitHub, OpenNeuro for on* datasets
- ProvenanceCard (on* only): title 'NEMAR-curated copy of OpenNeuro ds00xxxx',
  2-cell DOI parity grid (NEMAR / OpenNeuro), View-original + View-mirror CTAs,
  All mirror snapshots <details> when vN.0.0 count > 1. The mirror version
  pointer points to highest vN.0.0 per the policy in nemar-cli#448 comment.
- VersionSwitcher: segmented tab strip + overflow dropdown when > 4 versions,
  'mirror' chip on vN.0.0 entries, hidden when only one version exists
- AuthorList: name + ORCID icon link + first affiliation (with +N more), expandable
- DoiBadge: copy-on-click with success state, label + value + small icon
- Chip: reusable label chip (neutral/accent/warning tones)
- BidsTree + BidsDirChildren: recursive collapsible tree from manifest paths,
  auto-opens shallow trees, EEG/.set + .tsv files tagged 'Vis · soon' / 'View · soon'
  pointing at Phase 5 visualizer work
- DetailRail: right-rail metadata (license, BIDS version, modalities/tasks/datatypes,
  sessions, publish date with relative time, authors, funding, keywords, related
  identifiers DOIs + URLs)
- Readme: server-side markdown rendering with empty-state for datasets without one

Route:
- pages/dataset/[id].astro SSR: parallel fetch of landing + metadata, then manifest
  for selected version (?v=... param falls back to latest). Defensive 404 when
  dataset is not public or doesn't exist. README pulled from manifest entry's
  presigned URL with 2.5s timeout. Cache-Control: max-age=60 to keep within
  presigned-URL TTL.

Verified live:
- /dataset/nm000104 (native, multi-thousand-file manifest)
- /dataset/on005262 (derived, exercises ProvenanceCard with DOI parity grid)
- /dataset/nm000103 (manifest 404 -> graceful 'Manifest unavailable' panel + rail
  still populated from metadata.json)
- /dataset/does-not-exist (404)
- 69/69 unit tests passing, 0 typecheck errors across 46 files
…auto-open

README:
- Wrapped in a 32rem max-block-size container with a bottom fade gradient
- 'Expand README' / 'Collapse README' button overlays the fade; jumps to
  full-height on click
- Auto-hides the toggle entirely when the README fits within the cap (short
  READMEs render unchanged)
- aria-expanded + aria-controls wired for keyboard / screen-reader users

BIDS tree:
- MAX_AUTO_OPEN_DEPTH 2 -> 1 + AUTO_OPEN_CHILD_CAP 12 -> 6 so large datasets
  (nm000104 with 100+ subjects, on005262 with 12+ subjects) render with
  only top-level subjects open. Users expand the ones they want.

Verified live against nm000104 (large tree) and on005262 (derived dataset).
@neuromechanist
neuromechanist merged commit 30bb186 into feature/issue-1-epic-nemar-redesign May 15, 2026
@neuromechanist
neuromechanist deleted the feature/issue-3-phase2-dataset-detail branch May 15, 2026 21:35
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.

1 participant