Skip to content

feat(viewer): gear settings menu + notch default from PowerLineFrequency + cursor white-flash fix - #104

Merged
neuromechanist merged 2 commits into
mainfrom
feat/viewer-settings-menu
Jun 3, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
feat/viewer-settings-menu

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Viewer refinements (follows P1 #103). Companion producer: nemarDatasets/.github#26.

Gear settings menu

The set-once controls (HP/LP/notch filters + DC/Events/Butterfly/Clock) move into a gear popover, so the primary bar is just Time / Scale / Channels. Click-outside and Escape close it; a dot on the gear marks an active filter so it's clear the trace is filtered even with the menu closed. Keyboard shortcuts (d/b/t) still work since they drive the same checkboxes.

Notch default from PowerLineFrequency

The store now carries a power_line_frequency attr (embedded by the converter, #26 above). openRecording parses it into RecordingStore.powerLineFrequency, and the viewer defaults the Notch select + filter to it (50/60 Hz). Datasets without the sidecar field open unfiltered — exactly the "if it has it, set it; if not, leave it off" behavior. This is inert until a dataset re-converts with #26.

Cursor white-flash fix

Moving the pointer in/out of the scope could flash the canvas white: the readout row changing height fired the ResizeObserver → render() → sizeCanvas() reassigned canvas.width, and assigning canvas dimensions clears the bitmap. Fix:

  • only reassign canvas dimensions on an actual size change (so a non-resize re-render repaints over the prior frame),
  • only re-render on width changes (the scope height tracks width),
  • keep the readout to one line so it never grows the layout.

546 tests pass, 0 type errors, lint clean, build green. Verified on nm000132 via the dev server (primary bar = Time/Scale/Channels; Filter+Display in the popover; notch defaults off since nm000132's store predates the attr).

- Collapse the set-once controls (HP/LP/notch filters + DC/Events/Butterfly/
  Clock) into a gear popover so the primary bar is just Time/Scale/Channels.
  Click-outside / Escape close it; a dot on the gear marks an active filter.
- Default the notch from the recording's BIDS PowerLineFrequency: the store
  now carries a `power_line_frequency` attr (embedded by the converter), and
  the viewer turns the notch on at that frequency (50/60). Datasets without
  the sidecar field open unfiltered.
- Fix the canvas flashing white when the cursor enters/leaves: assigning
  canvas.width/height clears the bitmap, so only do it on an actual size
  change, only re-render on width changes, and keep the readout to one line.
- .eegv__menu: hide via the stylesheet (display:none) too, not only the inline
  style, so the closed state survives if the inline style is stripped.
- ResizeObserver: init lastObservedW to -1 so a zero-width first observation
  (viewer mounted into a hidden/zero-width container) still renders once.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review response (code-reviewer + silent-failure-hunter, Sonnet)

Addressed in d87378b:

  • .eegv__menu display: now hidden from the stylesheet (display: none) too, not only the inline style, so the closed state survives if the inline style is ever stripped. setMenu keeps toggling the inline flex/none.
  • ResizeObserver zero-width mount: lastObservedW inits to -1 so a zero-width first observation still fires one render.

Verified and intentionally not changed:

  • Group-switch stale frame (silent-failure Finding 3): not a bug — renderFrame starts with clearRect(0,0,w,h) + a background fillRect, so every re-render fully repaints. The skip-clear guard only avoids the redundant clear on a no-size-change paint; it cannot leave a stale frame.
  • Escape preventDefault: only runs when the menu is open (consuming the Escape that closed it) — intended; it does not swallow Escape otherwise.
  • TDZ on Escape's menuOpen/setMenu: none — both are declared earlier in mount scope and the handler fires after init.
  • DPR-change-without-resize: pre-existing (also on main); not introduced or worsened here.
  • Number(...)||null fragility / unsupported-Hz info log / mid-mount listener leak: low-priority defensive notes. NOTCH_CHOICES are numeric constants, non-50/60 line frequencies don't occur in practice, and the document listener is removed via _eegvCleanup. Deferred.

546 tests, 0 type errors, lint clean, build green.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: d87378b
Status: ✅  Deploy successful!
Preview URL: https://39bc7a01.nemar-website.pages.dev
Branch Preview URL: https://feat-viewer-settings-menu.nemar-website.pages.dev

View logs

@neuromechanist
neuromechanist merged commit 521143b into main Jun 3, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feat/viewer-settings-menu branch June 3, 2026 15:27
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