Skip to content

Fix quality-view number labels, deep link, lede spacing and dev CSP - #617

Merged
neuromechanist merged 11 commits into
stagingfrom
fix/quality-view-polish
Nov 27, 2026
Merged

neuromechanist merged 11 commits into
stagingfrom
fix/quality-view-polish

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes five issues a browser check found in the quality views (nemar-cli ADR 0134) against a local backend.

  1. Spectrum axis ticks. Numbers on a drawing are rounded to three significant digits of the range they sit in (roundedText / labelText in render/scale.ts). A stored text that already has four or fewer significant digits is printed unchanged.
  2. Scalp-map text rows. Same rounding for each map's "from ... at ... to ..." row, and for the near-flat note. The heatmap legend and the density histogram's top tick, which had the same problem, are rounded too.
  3. Quality deep link on a fresh load. The tab logic moves to src/lib/dataset-tabs.ts. A tab can name the hash prefix it owns (data-hash-prefix; Recording quality owns #quality), and bindTablist opens that tab when the page loads with a matching hash.
  4. "This page showsone recipe's runs". Astro drops whitespace-only text between two expressions when they are direct children of a component, which includes a slotted Fragment. The two admin Pipelines ledes that did this now use template literals, and a source test rejects the pattern in every slotted Fragment.
  5. Dev CSP and a local backend. devConnectOrigins adds the origins of PUBLIC_API_BASE_URL and PUBLIC_DATA_BASE_URL to connect-src, only when import.meta.env.DEV === true. It skips non-http(s) values and hosts that https://*.nemar.org already admits.

Before / after

Item Before After
1 y ticks -29.811042743271745 / 18.801075851290445, clipped to 743271745 at the left edge -29.8 / 18.8; x ticks rounded the same way; the readout, data table and downloads keep the stored text
2 6: from -3.4706225147472876 dB at C4 to 3.4803197825169043 dB at Fp2 6: from -3.47 dB at C4 to 3.48 dB at Fp2; the data table keeps the stored text
3 /dataset/<id>#quality/.../icmaps on a fresh load selects Components but leaves the page on Demographics. QualityPanel's script runs first and clicks the outer tab before DatasetTabs has bound the click. Recording quality opens whichever script runs first. The panel's observer opens the panel and scrolls it into view once the tab is shown.
4 This page showsone recipe's runs; the run page's lede had the same bug ({failuresLead} {failuresMeaning()}) Both ledes keep the space. No other slotted Fragment had it (checked by the new test); admin/compute.astro already used {" "}.
5 With a loopback PUBLIC_API_BASE_URL, every browser fetch fails ("Failed to fetch") In astro dev only, connect-src also admits http://127.0.0.1:8787. Production policy unchanged: a test checks that every route's policy with DEV: false matches the policy without dev origins byte for byte, and I diffed the default policy against staging with no difference.

Tests added

  • test/quality-views-render.test.ts: rounding vectors (the observed values, exponent form, the near-flat cap, -0). Lines ticks are rounded while the readout keeps the stored text, and the scalp-map row is rounded. The existing "stored text" row check now also accepts the rounded label.
  • test/dataset-tabs.test.ts (tabForHash) and test/quality-panel.astro.test.ts (the rendered tab carries data-hash-prefix="#quality").
  • e2e/dataset-tabs-deep-link.spec.ts: in a real browser, the panel's click lands before the tab list is bound, and #quality/... still opens Recording quality. A non-quality hash keeps Demographics.
  • test/astro-slot-whitespace.test.ts: fails on the old source of both admin pages.
  • src/middleware.test.ts: devConnectOrigins returns nothing unless DEV === true, production CSP is unchanged on five routes, and malformed or non-http bases cannot add a source.

Gates run (the CI steps' own commands)

  • bun run lint: clean
  • bun run typecheck (astro check): 0 errors, 0 warnings
  • bun run test: 273 files passed, 8 skipped (the nemar-cli contract drift tests, which need the CI sparse checkout); 8881 tests passed
  • bun run test:quality-views-perf: 7 passed
  • bunx astro build: complete
  • bun scripts/check-quality-views-size.mjs --require-build: passes (Spectrum first screen 29.0 KB of the 30.0 KB budget)
  • Playwright, run locally: e2e/quality-panel.spec.ts, e2e/admin-quality.spec.ts, e2e/dataset-tabs-deep-link.spec.ts; 39 passed, 7 skipped (the admin spec's backend-dependent cases)

Not run: a manual check of the real dataset page against the local backend. The running dev servers were left alone.

Review round 1

  • Env leak in the production bundle. Passing the whole import.meta.env to devConnectOrigins made Vite write it into the worker bundle as Object.assign(__vite_import_meta_env__, ...), including the build machine's PATH. The middleware now reads DEV and the two bases by name, so a production build drops the dev branch entirely. osa-widget.ts (leaked PATH) and osa-overview.ts (leaked _) had the same pre-existing problem and are fixed in their own commit. After a rebuild, the only PATH: literal left in the bundle is in the pre-existing resolveDocsBase; that and the other remaining cases are filed as Build-machine env vars written into the worker bundle #618.
  • Tests. The rounding tests now render the lines table and fieldTable and check the exact stored texts. New cases cover a heatmap with long cell texts (legend rounded; table and readout exact), a density histogram's rounded top tick, and noteCaption("near_flat", 0.0123456789, "µV"). All five fail against the pre-fix renderers.
  • Hermetic CSP test. It stubs both bases and reloads the module. It passes with PUBLIC_API_BASE_URL exported in the shell. The older middleware tests' sensitivity to that variable predates this PR: 8 of them fail on staging too. Filed as Middleware tests fail when PUBLIC_API_BASE_URL is exported #619.
  • The QualityPanel comment wording is fixed.
  • Image exports now carry the same rounded axis and legend labels as the screen. This is intended. The data files in an export are still the exact recorded bytes.

Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5426dd5
Status: ✅  Deploy successful!
Preview URL: https://d2386c0d.nemar-website.pages.dev
Branch Preview URL: https://fix-quality-view-polish.nemar-website.pages.dev

View logs

@neuromechanist
neuromechanist merged commit 58385a9 into staging Nov 27, 2026
4 checks passed
@neuromechanist
neuromechanist deleted the fix/quality-view-polish branch November 27, 2026 10:31
@neuromechanist neuromechanist mentioned this pull request Nov 28, 2026
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