Repository navigation
Signal viewer: open inline, enlarge into the modal on demand - #218
Conversation
The viewer mounts into the clicked row's own preview panel; an Enlarge control moves the mounted host into the page-level dialog and the dialog close moves it back. Moving rather than remounting keeps the montage, filter, gain and time window across the transition. At most one viewer is live page-wide, as before: each mount holds a WebGL context and browsers cap those. Closes #217
Deploying nemar-website with
|
| Latest commit: |
63188aa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b5aecc52.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-217-viewer-inl.nemar-website.pages.dev |
mountEegViewer returns no disposer exactly when it mounted nothing and left an unavailable message instead. The inline bar was surviving that, offering an Enlarge that opened a full-screen modal onto one line of text, and the row kept counting as the live instance despite holding no observers or GL context to release. Also corrects the viewer module docs, which still described the slot as a modal body and told callers to dispose on dialog close -- disposing on a move is now the specific bug to avoid.
Three review findings, none reachable through the UI today but all one refactor away from being reachable: - releaseEegViewer empties the dialog synchronously instead of relying on the queued close event, which can fire after eegLive has moved on to a different row. - The !host guard now clears aria-busy/data-loaded and shows an error. It returns before eegSeq/eegLive exist, so the try/finally cannot clean up after it and a bare return left the row spinning forever. - The close handler warns when it recovers a viewer whose inline anchor vanished, rather than silently patching a broken invariant, and no longer mistakes a newly opened row for the one being returned.
Review round 1Four reviewers (code, error-handling, comments, tests). Every finding is addressed below; none deferred. Fixed1. Enlarge control survived a "resolved but no viewer" mount failure. Found independently by the error-handling and test reviewers. Reproduced by rejecting zarr requests at the network layer, which is a real state (unreachable or corrupt store), not a synthetic one. Confirmed the modal-onto-a-message behavior, then fixed: 2. 3. The 4. Silent recovery in the close handler. The anchor-missing 5. Comment rot in Verified, no change neededThe code reviewer traced every interleaving and found the state machine sound, resting on one browser guarantee it confirmed: a superseded mid-flight mount checks The test reviewer mutation-tested the new negative assertion by reintroducing Not actionable"Open a row while another is enlarged" is unreachable: Re-verified after all fixes: enlarge round trip preserves the same canvas element (1257x540 enlarged, 778x389 inline) and the 2.0-12.0 s window in both directions; anchor removed; dialog slot empty; switching files collapses the previous row and leaves one instance page-wide; no spurious warnings. |
Closes #217.
What changed
The EEG/MEG/iEEG/EMG signal viewer opens inline again, in the clicked BIDS tree row's own preview panel. The full-screen dialog added in #206 stays, but it is no longer the entry point: it sits behind an Enlarge control in the inline panel.
src/lib/render-dir-listing.ts— signal rows get a[data-preview-slot]again, and the eeg branch collapses into the shared previewable-file branch since it now uses the samearia-expandedtoggle semantics as md/json/tsv. Only the tooltip still distinguishes them. The slot is markedtree__preview--signal, which carries two differences from a text preview:aria-live. A live region wrapped around a mounted viewer would announce every cursor-readout and legend update. The transient messages that genuinely need announcing carryrole="status"/role="alert"themselves, which is the targeted mechanism anyway.src/pages/dataset/[id].astro—openEegViewerModalbecomesopenEegViewerInline, plusenlargeEegViewerand a rewritten dialog-close handler. State moves from a bare(seq, destroy)pair to aneegLiverecord holding the row, the portable host, and the teardown handle, since three different events (a new open, a collapse, a dialog close) now each need to find the current instance and its DOM.src/components/EegViewerDialog.astro— receives an already-mounted host rather than hosting a mount. Droppedaria-live(it no longer receives the loading/unavailable messages, only a live viewer) and grew tomin(92vw, 1800px)xmin(90vh, 1100px)from ~70%, since the user now arrives here by explicitly asking for more room than the inline panel gives.src/components/BidsTree.astro—is:globalstyles for the inline bar, the Enlarge button, the stand-in marker, and the signal panel's sizing.Design decisions
Move the host, don't remount. This is the whole feature. Montage, filter, gain, channel page and time window are closure state inside a single
mountEegViewercall, so remounting on enlarge would reset exactly the state the user enlarged in order to look at more closely. Instead the viewer mounts into a dedicated[data-eegv-host]child of the panel (not the panel itself, so the row's chrome stays behind), and enlarging moves that one node into the dialog.The move is safe, and specifically so for this instance: its
MutationObserverwatchesdocument.documentElementfor theme flips rather than its host, so relocation does not trip it, and itsResizeObserverwatches the viewer root inside the moved subtree, so the move triggers exactly one repaint at the new width. It also works mid-mount, sincemountEegViewerholds a reference to the host element and moving a node does not invalidate that.One live viewer page-wide, kept. This constraint arrived with the modal in #199, but it was never really about the modal: each mount holds a WebGL context and browsers cap those (~16), so a viewer per row accumulates toward a hard limit. Opening a second signal file therefore releases the first and collapses its row. Collapsing the previous row is a deliberate choice over leaving it expanded-but-emptied, which would read as a rendering failure.
Rows expanded without a live instance. A row showing a recorded "unavailable" message has no instance to release, so
releaseEegVieweralone would not collapse it.openEegViewerInlinecallsresetEegRowunconditionally alongside it; both are idempotent.Ordering in
releaseEegViewer.eegLiveis cleared beforedialog.close(), because the close handler's job is to hand a live viewer back to its row and there is about to be neither. Seeing null, it empties the dialog instead, which is also what the release-while-enlarged case needs.No aria-haspopup on the row button. It toggles its adjacent panel now; the dialog is a second step behind a separate control, so claiming
aria-haspopup="dialog"would misdescribe what the button does.What I verified in the browser
Puppeteer against the dev server on
nm000103(HBN-EEG NC), real 129-channel recordings, both themes:data-loaded="true", dialog untouched.beforeCanvas === afterCanvas(same DOM node, so no remount), canvas repainted at 1257x540, window and scale and status line all unchanged.aria-expanded=false, 0 canvases.zarrAvailable="false": surfaces the reason plus a download link routed throughdata.nemar.org/<id>/<v>/<bids-path>,role="status", no Enlarge offered, collapses cleanly.bun run test1012/1012,typecheck0 errors,lintclean,buildcomplete.