Skip to content

Commit c2f6736

Browse files
Release 0.2.48
Release 0.2.48
2 parents 0069702 + d2e507c commit c2f6736

30 files changed

Lines changed: 2137 additions & 107 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ src/
9696
data-api.ts / data-base.ts data.nemar.org client (landing/metadata/manifest/README fetch)
9797
auth.ts auth-dev.ts auth-proxy.ts orcid-proxy.ts session types/helpers, dev mock session, backend proxies
9898
dashboard-api.ts admin-api.ts collaborators-api.ts upload-client.ts authenticated API clients
99+
decision-card.ts reads the API review detail's `decision_card` (nemar-cli ADR 0142) and draws it first in the approval panel; decides nothing, never prints its terminal command
99100
mail-admin-api.ts admin Mail client (browser-safe): tickets, queues, away window, reply failure classes, badge count, staff directory
100101
mail-admin-contract.ts hand copy of nemar-cli shared/contract/mail-admin.ts (drift-tested, test/mail-admin-contract-drift.test.ts)
101102
compute-api.ts compute-contract.ts browser-safe client for GET /compute/me, /me/usage, /me/jobs (guards copy out only the keys read; a rejected body is a `shape` error, never zeros) and the hand copy of the vocabulary it needs, the one place the job-state and front-door words live here (drift-tested, test/compute-user-contract-drift.test.ts; extractors in test/compute-contract-drift.ts)

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ The release pull request from `staging` to `main` moves those entries under the
1313

1414
## [Unreleased]
1515

16+
### Fixed
17+
18+
- **Readable numbers on quality-view drawings** (nemar-cli ADR 0134 views).
19+
The Spectrum's axis ticks, the scalp maps' text rows, a heatmap's legend and a density histogram's top tick printed values at full binary64 precision (`-29.811042743271745`), and the long y ticks were clipped at the chart's left edge.
20+
A number on a drawing now keeps three significant digits of the range it sits in (`-29.8`, `3.48 dB`), and a stored text already that short prints as stored.
21+
The readouts, the data tables and the downloads keep the stored texts exactly.
22+
- **A quality deep link opens Recording quality.**
23+
A fresh load of `/dataset/<id>#quality/<recording>/<view>` selected the inner view tab but left the page on Demographics, because the panel's script clicked the outer tab before the tab list had bound its click.
24+
The tab list now opens the tab that owns the hash itself, whichever script runs first.
25+
- **Missing space on the admin Pipelines pages.**
26+
"This page showsone recipe's runs" and the run page's lede lost the space Astro drops between two expressions in a slotted Fragment; a test now refuses that pattern in every slotted Fragment.
27+
- **Local backend in `astro dev`.**
28+
With `PUBLIC_API_BASE_URL` or `PUBLIC_DATA_BASE_URL` pointing at a local backend, the Content-Security-Policy refused every browser fetch to it.
29+
In dev only, their origins are added to `connect-src`; a production build's policy is unchanged.
30+
1631
## [0.2.47] - 2026-11-27
1732

1833
### Added

‎e2e/dataset-tabs-deep-link.spec.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* The dataset page's summary tabs and the quality deep link in a real browser: a fresh load of
3+
* `#quality/<recording>/<view>` opens Recording quality although the panel's script clicks the
4+
* tab before DatasetTabs' script has bound the click (the order the page's scripts run in, since
5+
* QualityPanel renders inside DatasetTabs). The real module (`src/lib/dataset-tabs.ts`) binds the
6+
* DatasetTabs markup, written into the dev server's `robots.txt` as quality-panel.spec.ts does.
7+
*
8+
* Run with `bun run test:e2e e2e/dataset-tabs-deep-link.spec.ts`.
9+
*/
10+
11+
import { type Page, expect, test } from "@playwright/test";
12+
13+
const MODULE = "/src/lib/dataset-tabs.ts";
14+
15+
const SHELL = `
16+
<section class="dtabs">
17+
<div class="dtabs__list" role="tablist">
18+
<button role="tab" id="t-demo" aria-controls="p-demo" aria-selected="true" tabindex="0" type="button">Demographics</button>
19+
<button role="tab" id="t-rq" aria-controls="p-rq" aria-selected="false" tabindex="-1" type="button" data-quality-tab data-hash-prefix="#quality">Recording quality</button>
20+
</div>
21+
<div role="tabpanel" id="p-demo" aria-labelledby="t-demo">demographics</div>
22+
<div role="tabpanel" id="p-rq" aria-labelledby="t-rq" hidden><section data-quality-panel>panel</section></div>
23+
</section>`;
24+
25+
/** Load the shell with `hash`, let the panel click its tab first (as QualityPanel.astro's
26+
* `showTab` does), then bind the tab list as DatasetTabs.astro's script does. */
27+
async function load(page: Page, hash: string): Promise<void> {
28+
await page.goto(`/robots.txt${hash}`);
29+
await page.evaluate(
30+
async ({ shell, module }) => {
31+
document.body.innerHTML = shell;
32+
const panel = document.getElementById("p-rq")!;
33+
if (panel.hidden) document.getElementById("t-rq")!.click();
34+
const { bindTablist } = await import(/* @vite-ignore */ module);
35+
for (const list of document.querySelectorAll<HTMLElement>(".dtabs__list")) bindTablist(list);
36+
},
37+
{ shell: SHELL, module: MODULE },
38+
);
39+
}
40+
41+
test("a fresh load of a quality deep link opens Recording quality", async ({ page }) => {
42+
await load(page, "#quality/sub-X/eeg/sub-X_task-Y_eeg.edf/icmaps");
43+
await expect(page.locator("#t-rq")).toHaveAttribute("aria-selected", "true");
44+
await expect(page.locator("#p-rq")).toBeVisible();
45+
await expect(page.locator("#p-demo")).toBeHidden();
46+
});
47+
48+
test("a load with no quality hash keeps Demographics, and a click still switches", async ({
49+
page,
50+
}) => {
51+
await load(page, "#readme");
52+
await expect(page.locator("#t-demo")).toHaveAttribute("aria-selected", "true");
53+
await expect(page.locator("#p-rq")).toBeHidden();
54+
await page.locator("#t-rq").click();
55+
await expect(page.locator("#p-rq")).toBeVisible();
56+
});

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nemar-website",
33
"packageManager": "[email protected]",
44
"type": "module",
5-
"version": "0.2.47",
5+
"version": "0.2.48",
66
"private": true,
77
"license": "CC-BY-NC-ND-4.0",
88
"description": "nemar.org is the largest archive tool and compute resource for human biosignals",

‎src/components/DatasetTabs.astro‎

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import DatasetQualitySummary from "./quality/DatasetQualitySummary.astro";
1212
* Both tabs render server-side as static markup; only the demographics
1313
* panel hydrates client-side. The tabs themselves switch via a tiny
1414
* delegated click + keydown handler implementing the WAI-ARIA tabs
15-
* pattern (left/right cycle with wrap, Home/End to jump to ends).
15+
* pattern (left/right cycle with wrap, Home/End to jump to ends), and a
16+
* tab naming a hash prefix (`data-hash-prefix`) opens on a page loaded
17+
* with that hash (`lib/dataset-tabs.ts`).
1618
*/
19+
import { HASH_PREFIX as QUALITY_HASH_PREFIX } from "../lib/quality-views/panel-model";
1720
import QualityPanel from "./quality/QualityPanel.astro";
1821
1922
interface Props {
@@ -46,7 +49,7 @@ const idp = `dt-${datasetId}`;
4649
</button>
4750
)}
4851
{recordingQuality && version && (
49-
<button class="dtabs__tab" role="tab" id={`${idp}-tab-rq`} aria-controls={`${idp}-panel-rq`} aria-selected="false" tabindex="-1" type="button" data-quality-tab>
52+
<button class="dtabs__tab" role="tab" id={`${idp}-tab-rq`} aria-controls={`${idp}-panel-rq`} aria-selected="false" tabindex="-1" type="button" data-quality-tab data-hash-prefix={QUALITY_HASH_PREFIX}>
5053
Recording quality
5154
</button>
5255
)}
@@ -82,6 +85,7 @@ const idp = `dt-${datasetId}`;
8285
import { fetchParticipants, type ParticipantsData } from "../lib/participants";
8386
import { renderSexDonutSvg } from "../lib/render-sex-donut";
8487
import { renderAgeGenderStackedSvg } from "../lib/render-age-gender";
88+
import { bindTablist } from "../lib/dataset-tabs";
8589

8690
function escapeHtml(s: string): string {
8791
return s
@@ -156,67 +160,10 @@ const idp = `dt-${datasetId}`;
156160
panel.innerHTML = renderDemographics(data);
157161
}
158162

159-
/** Activate the tab at `index` within `tabs`, deactivating the others.
160-
* Pure DOM bookkeeping — keyboard nav calls this with `focus=true` to
161-
* move focus alongside the selection (per the ARIA tabs spec for
162-
* automatic activation). */
163-
function activateTab(tabs: HTMLButtonElement[], index: number, focus: boolean): void {
164-
tabs.forEach((tab, i) => {
165-
const active = i === index;
166-
tab.setAttribute("aria-selected", active ? "true" : "false");
167-
tab.tabIndex = active ? 0 : -1;
168-
const panelId = tab.getAttribute("aria-controls");
169-
const panel = panelId ? document.getElementById(panelId) : null;
170-
if (panel) {
171-
if (active) panel.removeAttribute("hidden");
172-
else panel.setAttribute("hidden", "");
173-
}
174-
});
175-
if (focus) tabs[index]?.focus();
176-
}
177-
178-
function bindTablist(list: HTMLElement): void {
179-
const tabs = Array.from(list.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
180-
if (tabs.length === 0) return;
181-
182-
list.addEventListener("click", (event) => {
183-
const target = event.target;
184-
if (!(target instanceof Element)) return;
185-
const tab = target.closest<HTMLButtonElement>('[role="tab"]');
186-
if (!tab) return;
187-
const idx = tabs.indexOf(tab);
188-
if (idx >= 0) activateTab(tabs, idx, false);
189-
});
190-
191-
list.addEventListener("keydown", (event) => {
192-
const active = document.activeElement;
193-
if (!(active instanceof HTMLElement)) return;
194-
const current = tabs.indexOf(active as HTMLButtonElement);
195-
if (current < 0) return;
196-
let next = current;
197-
switch (event.key) {
198-
case "ArrowRight":
199-
next = (current + 1) % tabs.length;
200-
break;
201-
case "ArrowLeft":
202-
next = (current - 1 + tabs.length) % tabs.length;
203-
break;
204-
case "Home":
205-
next = 0;
206-
break;
207-
case "End":
208-
next = tabs.length - 1;
209-
break;
210-
default:
211-
return;
212-
}
213-
event.preventDefault();
214-
activateTab(tabs, next, true);
215-
});
216-
}
217-
218163
// The summary's own tab lists only: the quality panel inside one of its panels has its own.
219-
document.querySelectorAll<HTMLElement>('.dtabs__list[role="tablist"]').forEach(bindTablist);
164+
document
165+
.querySelectorAll<HTMLElement>('.dtabs__list[role="tablist"]')
166+
.forEach((list) => bindTablist(list));
220167
document.querySelectorAll<HTMLElement>("[data-demo-defer]").forEach((el) => void hydrateDemographics(el));
221168
</script>
222169

‎src/components/quality/QualityPanel.astro‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ const idp = `qp-${datasetId}`;
127127
};
128128
const tabpanel = root.closest<HTMLElement>('[role="tabpanel"]');
129129
const tab = tabpanel ? document.getElementById(tabpanel.getAttribute("aria-labelledby") ?? "") : null;
130+
const isLink = (): boolean =>
131+
location.hash === HASH_PREFIX || location.hash.startsWith(`${HASH_PREFIX}/`);
132+
// The click does nothing when this script runs before DatasetTabs' script has bound its tab list; that
133+
// one then opens the tab for a `#quality` hash itself (lib/dataset-tabs.ts), and the observer
134+
// below opens the panel and brings it into view.
130135
const showTab = (): void => {
131136
if (tabpanel?.hidden) tab?.click();
132137
open();
@@ -137,10 +142,11 @@ const idp = `qp-${datasetId}`;
137142
if (tabpanel.hidden) return;
138143
observer.disconnect();
139144
open();
145+
if (isLink()) root.scrollIntoView({ block: "start" });
140146
}).observe(tabpanel, { attributes: true, attributeFilter: ["hidden"] });
141147
}
142148
const followLink = (): void => {
143-
if (location.hash === HASH_PREFIX || location.hash.startsWith(`${HASH_PREFIX}/`)) {
149+
if (isLink()) {
144150
showTab();
145151
root.scrollIntoView({ block: "start" });
146152
}

‎src/lib/dataset-tabs.ts‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* The dataset page's summary tabs (`DatasetTabs.astro`): the WAI-ARIA tabs pattern (a click, or
3+
* left and right with wrap, Home and End) and the deep link a tab answers for.
4+
*
5+
* A tab that owns a deep link names its hash prefix (`data-hash-prefix`; the Recording quality tab
6+
* owns `#quality`, the panel's `HASH_PREFIX`). The tab list opens that tab itself when the page
7+
* loads with such a hash, so a fresh load of `#quality/<recording>/<view>` shows the panel whichever
8+
* script runs first: the panel's own `showTab` clicks the tab, which does nothing before
9+
* `bindTablist` has bound the click.
10+
*/
11+
12+
/** Whether `hash` is `prefix` itself or a path under it (`#quality`, `#quality/...`). */
13+
export function hashMatches(prefix: string, hash: string): boolean {
14+
return prefix !== "" && (hash === prefix || hash.startsWith(`${prefix}/`));
15+
}
16+
17+
/** The index of the first tab whose hash prefix `hash` matches, or -1. */
18+
export function tabForHash(prefixes: readonly (string | null | undefined)[], hash: string): number {
19+
return prefixes.findIndex((prefix) => prefix != null && hashMatches(prefix, hash));
20+
}
21+
22+
/** Activate the tab at `index` within `tabs`, deactivating the others; `focus` moves focus with
23+
* the selection (keyboard navigation, per the ARIA tabs pattern's automatic activation). */
24+
export function activateTab(
25+
tabs: readonly HTMLButtonElement[],
26+
index: number,
27+
focus: boolean,
28+
): void {
29+
tabs.forEach((tab, i) => {
30+
const active = i === index;
31+
tab.setAttribute("aria-selected", active ? "true" : "false");
32+
tab.tabIndex = active ? 0 : -1;
33+
const panelId = tab.getAttribute("aria-controls");
34+
const panel = panelId ? document.getElementById(panelId) : null;
35+
if (panel) {
36+
if (active) panel.removeAttribute("hidden");
37+
else panel.setAttribute("hidden", "");
38+
}
39+
});
40+
if (focus) tabs[index]?.focus();
41+
}
42+
43+
/** Bind one tab list's click and keys, then open the tab the page's hash names, if any. */
44+
export function bindTablist(list: HTMLElement, hash: string = location.hash): void {
45+
const tabs = Array.from(list.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
46+
if (tabs.length === 0) return;
47+
48+
list.addEventListener("click", (event) => {
49+
const target = event.target;
50+
if (!(target instanceof Element)) return;
51+
const tab = target.closest<HTMLButtonElement>('[role="tab"]');
52+
if (!tab) return;
53+
const idx = tabs.indexOf(tab);
54+
if (idx >= 0) activateTab(tabs, idx, false);
55+
});
56+
57+
list.addEventListener("keydown", (event) => {
58+
const active = document.activeElement;
59+
if (!(active instanceof HTMLElement)) return;
60+
const current = tabs.indexOf(active as HTMLButtonElement);
61+
if (current < 0) return;
62+
let next = current;
63+
switch (event.key) {
64+
case "ArrowRight":
65+
next = (current + 1) % tabs.length;
66+
break;
67+
case "ArrowLeft":
68+
next = (current - 1 + tabs.length) % tabs.length;
69+
break;
70+
case "Home":
71+
next = 0;
72+
break;
73+
case "End":
74+
next = tabs.length - 1;
75+
break;
76+
default:
77+
return;
78+
}
79+
event.preventDefault();
80+
activateTab(tabs, next, true);
81+
});
82+
83+
const linked = tabForHash(
84+
tabs.map((tab) => tab.dataset.hashPrefix),
85+
hash,
86+
);
87+
if (linked >= 0) activateTab(tabs, linked, false);
88+
}

0 commit comments

Comments
 (0)