Repository navigation
Phase 2: recording navigation in the viewer - #258
neuromechanist merged 9 commits into
Conversation
0c3229e to
6a382bf
Compare
Pure module behind website#253: parse sub/ses/task/acq/run/recording entities out of zarr index store paths (files and .mefd/.ds/BTi directories alike), order the list three ways for the prev/next control, enumerate subjects and tasks for the dropdowns, and resolve a (subject, task) pick to a recording. Paths that parse to nothing keep file order instead of scrambling. Also holds the persisted iteration order, read through an injected Storage so it is testable. Tested: 51 new vitest cases (1127 total), typecheck, lint, build green.
The gear popover gains one section, "Next moves through", persisting the prev/next iteration order and announcing changes on a bubbling event so the dialog chrome can relabel its controls without polling storage. `transfer`/`onTransfer` let a caller carry window length, manual gain, channel zoom, filters and the display toggles into the next recording. Window position, bad channels and group index deliberately do not travel; the notch re-defaults from the new recording's PowerLineFrequency unless the user set it themselves. Tested: typecheck, lint, build, full vitest suite green.
Subject and task dropdowns plus prev/next in the enlarged viewer's header row swap the mounted recording in place, reusing the eegSeq supersession the tree-click path uses so rapid navigation cannot strand a mount or a WebGL context (website#208). Settings carry over; the window resets to the start of the new recording. Neighbours are warmed with the same prefetch a hovered tree row gets. The first navigation collapses the inline row the viewer came from and the dialog owns the instance from then on -- the target recording often sits in a directory the tree never rendered, so re-anchoring is not available. The inline panel gains no controls. Tested: typecheck, lint, build, full vitest suite green.
Why navigating inside the dialog collapses the originating inline row instead of re-anchoring under the new recording, and why the alternatives lost.
Stepping onto the first or last recording disabled the button under the user's focus, dropping focus to the body; hand it to the opposite button. Tested: typecheck and lint green.
Same behaviour, expressed as two candidate lookups picked by `prefer` instead of a key-dispatched find. Tested: full vitest suite, typecheck and lint green.
"Subjects first" promises the subject moves fastest, but sorting ses before sub walked one subject's sessions before reaching the next subject, which is what runs order already does. Also pins what happens to recordings that tie on every tracked entity (BIDS split files): they keep source order, a dropdown pick lands on the first, prev/next reaches the rest. Review findings 3a and 3b on PR #258. Tested: 8 new vitest cases, full suite green.
renderUnavailable always linked "Download the file", which for a .mefd/.ds/BTi recording (website#252) resolves to raw directory listing JSON. Thread `dirRecording` through ViewerOptions from both mount sites and reuse the page's own wording. The nav path has no tree row to read data-dir-recording from, so `isDirRecordingName` decides from the name. Also stops the gear from showing a filter that never runs: a cutoff at or above the new recording's Nyquist, whether transferred or taken from the declared PowerLineFrequency, now reads as off. Review findings 4 and 5 on PR #258. Tested: 3 new vitest cases, full suite, typecheck, lint green.
A throw outside mountEegViewer's own try/catch (DOM build, WebGL setup, transfer) left the dialog naming the target while the host held a half-built viewer and no message: the previous instance is torn down as the mount's first act, so there is nothing to fall back to. Render the failure with the same fallback the inline path offers, and put the title and dropdowns back on the recording the user came from. Prev/next also now update aria-label alongside title, so a screen reader hears which recording is next rather than the static markup label. Review findings 1 and 2 on PR #258. Tested: typecheck, lint, full suite green.
Deploying nemar-website with
|
| Latest commit: |
a5c2384
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7c8ae056.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-253-phase2-vie.nemar-website.pages.dev |
6a382bf to
a5c2384
Compare
|
Review findings addressed, all six. Branch rebased onto the current epic tip 1. IMPORTANT — 2. IMPORTANT — prev/next accessible names. Fixed in 3. SUGGESTION — test gaps. Both added in 4. SUGGESTION — transferred cutoffs above the new Nyquist. Fixed rather than commented, in 5. SUGGESTION — 6. FYI — "abort" means ignore-the-result, not cancel-the-network. No code change, as instructed. The PR body now says so explicitly and points at #208 and #259 as the owners of true cancellation. Worth adding: #259's preload controller is per-mount and its Rebase. Two rebases, actually — first onto Gates on the rebased branch: |
2e775f4
into
feature/issue-256-epic-viewer-workbench
Summary
Implements #253. Once the signal viewer is open, moving to the next run, task or subject no longer means closing it, scrolling the tree and clicking another file. The enlarged (dialog) viewer gains subject and task dropdowns plus prev/next in its header row, and swapping a recording remounts in place rather than reopening the page.
Everything is driven off the Zarr
index.jsonthe page already fetches: no backend change, and no dependency on which directories the tree happens to have rendered.New pure module
src/lib/eeg-viewer/recording-nav.ts— parsessub/ses/task/acq/run/recordingout of store paths (directory recordings like.mefd/.ds/BTi included; nothing looks at extensions), orders the list three ways, enumerates subjects and tasks, resolves a (subject, task) pick, and holds the persisted iteration order behind an injectedStorage. Paths that parse to no entities sort after the ones that did, so a dataset the parser cannot read degrades to plain file order.Gear setting "Next moves through" —
runs, then tasks, then subjects(default),subjects first,file order. Persisted inlocalStorageundernemar:viewer:nav-order, read lazily at each navigation, and tolerant of storage that throws on access. The viewer announces a change on a bubbling event rather than reaching into the dialog chrome. In the gear menu this section sits above Phase 3's Preload section; the two are independent.State that transfers across a swap — window length, a manually set gain, channel zoom, filters and the display toggles. Window position resets to the start of the new recording, and bad channels and group index do not travel at all (per-recording labels; see the
ViewerTransferStatedoc comment). The notch re-defaults from the new recording's ownPowerLineFrequencyunless the user picked one, and any cutoff at or above the new recording's Nyquist is carried over as "off" rather than as a setting the gear shows active whiledesignFiltersdrops it.Inline mode gets no controls, per the issue. The first navigation inside the dialog collapses the inline row the viewer was opened from and the dialog owns the instance from then on; closing it then destroys the viewer instead of handing it back. The alternative — re-anchoring under the new recording's row — cannot be done honestly, because the target usually sits in a directory the tree never rendered. Written up as ADR 0012.
The swap reuses the existing
eegSeqsupersession and the mount'sisStalepredicate, so rapid next/next/next cannot strand a mount or a WebGL context. Note what that does and does not mean: superseding a navigation ignores the superseded mount's result, it does not cancel its network reads —openRecordingtakes noAbortSignal. True cancellation belongs to #208 and to Phase 3 (#259), which is addingAbortSignalplumbing tostore.ts; this PR deliberately does not touch that. Phase 3's per-mount preload controller is stopped by the same teardown a swap already triggers, so background preload does not leak across a navigation.Neighbours are warmed with the same
prefetchZarrStoreMetadataa hovered tree row gets.Part of epic #256. Rebased onto the epic branch after #257 and #259 merged.
Test plan
bun run test— 1192 passing (62 new:recording-nav.test.tsover realistic BIDS paths — sessions, multi-run, HBN-style subject labels,.mefd/.ds/extensionless directory recordings, split files that tie on every tracked entity, non-BIDS paths, storage round-trip and private-mode failures — plusisDirRecordingNamecases inbids-tree.test.ts)bun run typecheck,bun run lint,bun run buildgreenon005514(2885 recordings, 295 subjects) on the dev server, re-run after the rebase onto Phase 1: directory-format recording viewer rows #257 + Phase 3: capped background preload of recordings #259:6 of 2885, 295 subject options, 9 task options, both dropdowns showing the recording on screenrun-1torun-2of the same subject and task; position, title and botharia-labels follow00:00:00mountEegViewer's own try/catch renders "Couldn't open <name>" with the right fallback and puts the title and dropdowns back on the previous recording; the next navigation recovers normallyNotes
—placeholder rather than another recording's label..mefd/.ds/BTi recording reached by navigation has no tree row to readdata-dir-recordingfrom, soisDirRecordingNamedecides from the name and the viewer's "unavailable" message offers Viewer: directory-format recordings (.mefd/.ds/BTi) never get a viewer row #252's browse-the-files fallback instead of a download link onto directory listing JSON.