Skip to content

Tell the assistant which dataset is on screen, for its notebook button - #351

Merged
neuromechanist merged 13 commits into
stagingfrom
feature/osa-widget-dataset
Sep 24, 2026
Merged

neuromechanist merged 13 commits into
stagingfrom
feature/osa-widget-dataset

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Tells the Open Science Assistant (OSA) widget which dataset is on screen and whether it has a Zarr copy, so its new notebook button (OpenScience-Collective/osa#436) can open that dataset in a hosted JupyterLite notebook when it can, and say why it cannot when it cannot. Staging only; production keeps the widget off until OSA releases.

What changes

  • src/lib/osa-dataset.ts: announceOsaDataset(value) records the latest null or {id, zarr} on window.__nemarOsaDataset and calls OSAChatWidget.setDataset when the loaded widget has it. Invalid input is dropped with a warning.
  • src/lib/osa-widget.ts: an optional PUBLIC_OSA_NOTEBOOK_URL (absolute https:; malformed makes the embed misconfigured, as a bad endpoint does), passed as notebookUrl in the same setConfig call and escaped like every other value. The generated onload replays a recorded dataset into setDataset before init(), so the order in which the widget and the page script run does not matter. Both halves feature-detect setDataset, so this is harmless against the widget pinned today, which lacks it.
  • src/pages/dataset/[id].astro: announces {id} when the tree hydrates, then {id, zarr: state.paths.size > 0} beside the existing "View data" reveal, from the same already-fetched index (no second request), and {id, zarr: false} when the index fetch returns nothing or throws.
  • Staging (deploy-test.yml, wrangler.test.toml): PUBLIC_OSA_NOTEBOOK_URL=https://develop-notebook.osc.earth/osa/ (the project in the path, per OSC hostnames: a shared plane is a subdomain, a project is a path). Production wrangler.toml: a comment only.
  • ADR 0018: a dated update recording the dataset context and why the page, not the widget, decides it.
  • No Content Security Policy change: the notebook opens in a new tab, a navigation no directive here governs.

The widget pin moves to the OSA commit that ships setDataset in a follow-up commit on this branch, once that commit exists.

Tests

  • osa-dataset.test.ts (10): records, calls setDataset only when it is a function, ignores 11 malformed shapes, warns.
  • osa-widget.test.ts (+18): the notebook URL resolved, trimmed, rejected, omitted and escaped (quote and </script> breakouts); the generated onload executed against a recording stand-in, asserting setConfig, then setDataset, then init, and that it never throws with or without setDataset.
  • Four mutations, each caught.
  • bun run test 2,381 passed; bun run lint, bun run typecheck and bun run build clean.

The inline hydrateTree call sites have no unit harness in this repository (like the "View data" reveal beside them); they get a staging walk-through once the widget pin moves.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: c3461a1
Status: ✅  Deploy successful!
Preview URL: https://4f43c9cc.nemar-website.pages.dev
Branch Preview URL: https://feature-osa-widget-dataset.nemar-website.pages.dev

View logs

@neuromechanist
neuromechanist merged commit f0cd550 into staging Sep 24, 2026
5 checks passed
@neuromechanist
neuromechanist deleted the feature/osa-widget-dataset branch September 24, 2026 07:01
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