Skip to content

Phase 5: View data button opens the enlarge viewer - #262

Merged
neuromechanist merged 5 commits into
feature/issue-256-epic-viewer-workbenchfrom
feature/issue-260-phase5-view-data-button
Sep 1, 2026
Merged

neuromechanist merged 5 commits into
feature/issue-256-epic-viewer-workbenchfrom
feature/issue-260-phase5-view-data-button

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a "View data" button to the dataset action bar, next to Download. SSR'd hidden; the dataset page's hydration script reveals it once the Zarr index resolves with at least one store, and leaves it hidden for a dataset with zero stores (e.g. pre-backfill on004696) or a failed index fetch.
  • Clicking opens the enlarge dialog directly on the first viewable recording in the user's current nav order (orderedRecordings + the persisted nav-order setting from recording-nav.ts), starting detached from birth per ADR 0012 — there is no originating tree row, so closing the dialog destroys the instance.
  • Reuses the existing eegLive/eegSeq single-live-viewer machinery, mountEegViewer, and the recording-nav dropdowns/prev-next, rather than duplicating them. eegLive.btn/slot become nullable to represent a viewer opened with no row; resetEegRow and the dialog close handler treat null as a no-op, leaving every row-opened path unchanged.
  • A mount failure renders an explicit error in the dialog (mirrors navigateEegViewer's failure state) — never a blank dialog.
  • The Phase 3: capped background preload of recordings #259 preload setting is respected automatically: it's read from localStorage inside mountEegViewer itself, independent of the caller.
  • New pure helper firstRecording(list, order) in recording-nav.ts picks the first recording in a given iteration order; covered with realistic BIDS paths including .mefd-style directory recordings, and every nav order (runs, subjects, file).

Review follow-ups (addressed)

A Sonnet review found no critical/important issues but flagged four small gaps, all fixed:

  1. openRecordingInDialog never toggled aria-busy on its host, unlike openEegViewerInline/navigateEegViewer — now set right after the host is inserted and cleared in a finally.
  2. The target recording's own store metadata was never warmed before the mount — only its neighbours were, via prefetchAdjacentRecordings. Now warmed the same way prefetchZarrButton warms a tree row.
  3. Pre-existing gap, fixed now (no-debt policy): setEegDialogTitle only updated the visible heading text; the dialog's own aria-label stayed the static "Signal viewer" from EegViewerDialog.astro, so a screen reader never heard which recording was open. Fixed in the one setter all three entry points (inline enlarge, in-dialog navigation, View data) funnel through.
  4. Added the missing firstRecording(list, "subjects") test case.

Test plan

  • bun run test — 1198 tests pass (recording-nav.test.ts covers firstRecording for every nav order — runs, subjects, file — plus empty list, .mefd directory recordings, mixed file/directory ordering, and unparsed-path degradation)
  • bun run typecheck — 0 errors
  • bun run lint — clean
  • bun run build — succeeds
  • Manual verification against bun run dev on on005514: button is hidden on load, appears once the Zarr index resolves; clicking it opens the enlarge dialog directly on the dataset's first recording (sub-NDARAC589YMB_task-DespicableMe_eeg.set, "1 of 2885"), with subject/task dropdowns and the recording streaming correctly.
  • Staging QA item: Esc-close cleanup and prev/next click-through were not re-verified live end-to-end — the browser automation tool crashed mid-session and could not reach the dev server again afterward (a tab-visibility limitation reproduced independently on a bare vanilla <dialog>, unrelated to this change: Chrome defers the native close event while document.visibilityState is "hidden"), and the review sandbox hit the same dev-server-unreachable constraint. Both paths were verified by exhaustive code trace instead (the close-handler's detached branch clears eegLive + the dialog slot — exercised via a direct dispatch of the close event during manual testing — and prev/next reuses navigateEegViewer/stepRecording unchanged). Spot-check both on the test.nemar.org deploy.
  • Both themes (light/dark) — the button reuses .action/.action--ghost from ActionBar.astro with no new CSS, so no new theme-specific styling was introduced, but worth a quick look on a preview deploy.

Part of epic #256. Implements #260.

Picks the first recording in a given iteration order, reusing
orderedRecordings. Backs website#260 (dataset page "View data" button),
which needs to resolve a starting recording without a tree click.
SSR hidden next to Download; the dataset page's hydration script reveals
it once the Zarr index resolves with at least one store (website#260).
Clicking opens the first recording in the user's current nav order
straight into the enlarge dialog, detached from birth (ADR 0012): no
originating tree row, so closing the dialog destroys the instance.

Reuses the existing eegLive/eegSeq machinery, mountEegViewer, and the
recording-nav dropdowns/prev-next rather than duplicating them. A
mount failure renders an explicit error in the dialog, mirroring
navigateEegViewer's failure state.

eegLive.btn/slot become nullable to represent a viewer with no
originating row; resetEegRow and the dialog close handler are updated
to treat null as a no-op, matching behavior for every existing
row-opened viewer exactly.
@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Review follow-ups on the View data button (website#260):

- openRecordingInDialog never toggled aria-busy on its host, unlike
  openEegViewerInline and navigateEegViewer. Set it right after the
  host is inserted and clear it in a finally, mirroring
  navigateEegViewer.
- The target recording's own store metadata was never warmed before
  the mount -- only its neighbours were, via prefetchAdjacentRecordings.
  Warm it the same way prefetchZarrButton does for a tree row.
- setEegDialogTitle only ever updated the visible heading; the
  dialog's own aria-label stayed the static "Signal viewer" from
  EegViewerDialog.astro, so a screen reader never heard which
  recording was open. This was a pre-existing gap across all three
  entry points (inline enlarge, in-dialog navigation, and now View
  data); fixed here since all three funnel through this one setter.
Only "runs" and "file" were covered for firstRecording; add the
missing "subjects" case.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Addressed all four review items in 3bd32ff and 8e14129:

  1. openRecordingInDialog now sets aria-busy="true" on the host right after insertion and clears it in a finally, mirroring navigateEegViewer.
  2. The target recording's own store metadata is now warmed before the mount (mirrors prefetchZarrButton's cache-and-warm pattern), not just its neighbours.
  3. setEegDialogTitle now also updates the dialog's aria-label to Signal viewer: <name>. Noting per the review comment: this was a pre-existing gap across all three entry points (inline enlarge, in-dialog nav, and now View data), not something introduced by this PR — fixed here since all three converge on this one setter.
  4. Added the missing firstRecording(list, "subjects") case to recording-nav.test.ts.

Gates re-run clean: bun run test (1198 passed), typecheck (0 errors), lint (clean), build (succeeds). No package.json version change.

Also updated the PR body: Esc-close cleanup and prev/next click-through remain a staging QA item — neither this session's re-verification nor the review sandbox could reach the dev server, so both paths were confirmed by code trace only (detached-close branch and navigateEegViewer reuse, respectively).

@neuromechanist
neuromechanist merged commit e8f9d6c into feature/issue-256-epic-viewer-workbench Sep 1, 2026
5 checks passed
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Live browser verification completed post-merge (local dev server on the phase-4 worktree, which contains this PR's code rebased): the View data button stays hidden until the zarr index resolves, reveals with stores present, and opens the enlarge dialog directly on the first recording in nav order (sub-NDARAC589YMB_task-DespicableMe_eeg.set, 1 of 2885, 129 channels streaming). Next navigates to 2 of 2885 with the title/dropdowns following; closing the dialog destroys the viewer (slot emptied, zero canvases); reopening mounts fresh at 1 of 2885. The dialog aria-label now carries the recording name. Also confirmed on the pages.dev preview that the zero-index CORS-blocked case correctly keeps the button hidden. The staging QA caveat in the PR body is resolved.

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