Skip to content

feat: multi-annotation hover tooltip (#234)#254

Draft
Moomboh wants to merge 4 commits into
mainfrom
feat/multi-annotation-tooltip-234
Draft

feat: multi-annotation hover tooltip (#234)#254
Moomboh wants to merge 4 commits into
mainfrom
feat/multi-annotation-tooltip-234

Conversation

@Moomboh
Copy link
Copy Markdown
Collaborator

@Moomboh Moomboh commented May 13, 2026

Summary

Closes #234.

Lets users opt extra annotation features into the hover tooltip alongside the primary (legend-defining) annotation.

Dropdown UI (protspace-annotation-select)

  • Filled primary indicator dot on the currently selected row.
  • Small (i) toggle button on every non-primary row. Click flips that annotation in/out of the hover tooltip; native title provides the help text ("Show in hover tooltip" / "Hide from hover tooltip"). aria-pressed reflects state.
  • Toggle dispatches tooltip-annotation-toggle (separate from annotation-select); the row label still selects the primary.

Hover tooltip

  • TooltipView now carries an ordered blocks[] array. Each AnnotationBlock has its own key, displayValues, numericValue/numericType, scores, evidence.
  • The primary annotation renders first, then any extras in dropdown-add order — each gets the full treatment (header, scores/evidence column, raw numeric row).

State + persistence

  • New ?tooltip=foo,bar URL param (comma-separated). Parser dedupes, drops the primary, drops names not in the dataset, marks anything off for normalization on next URL write.
  • Dataset-scoped localStorage (protspace:tooltip-annotations:<hash>) seeded on dataset load when the URL does not pin a value; kept in sync afterwards via the existing view-change subscription.
  • Promoting an extra annotation to primary drops it from the extras (no double-render).

Test coverage

  • 11 new url-state tests, 5 localStorage-store tests, 6 component tests for the dropdown UI, multi-annotation tests for buildTooltipView.
  • New Playwright spec multi-annotation-tooltip.spec.ts (3 tests) covers the dropdown indicator/toggle, URL writes on toggle, and round-trip removal — all pass locally.
  • Existing 818 + 73 + 243 unit/component tests still pass.

Test plan

  • Primary annotation visually distinguished in the dropdown (radio-dot)
  • (i) icon toggles tooltip inclusion without changing the primary annotation
  • Hover tooltip shows extra blocks for opted-in annotations in stable order
  • State persists across reloads (URL + dataset-scoped localStorage)
  • Keyboard nav unchanged; aria-pressed + title on (i) for a11y
  • Type-check, knip, unit/component tests, docs build (via pre-commit)
  • Local Playwright e2e spec for the new dropdown + URL plumbing

🤖 Generated with Claude Code

@Moomboh Moomboh force-pushed the feat/multi-annotation-tooltip-234 branch from e4a0bb2 to d271e0f Compare May 13, 2026 10:39
@Moomboh Moomboh self-assigned this May 13, 2026
@Moomboh Moomboh requested a review from tsenoner May 13, 2026 11:05
@Moomboh Moomboh marked this pull request as ready for review May 13, 2026 11:10
@tsenoner
Copy link
Copy Markdown
Owner

  • Ensure that the tooltip uses the available vertical space and does not go outside the bottom if selecting points in the lower area.
  • Update the annotation selection toggle icon to be a closed and open eye
  • make the numeric value in the tooltip non-bold and simply call it "value" not "raw value"

@tsenoner tsenoner marked this pull request as draft May 14, 2026 10:35
@Moomboh
Copy link
Copy Markdown
Collaborator Author

Moomboh commented May 19, 2026

Addressed the three review items:

  • (i) → eye icons — the per-row tooltip toggle now uses an open-eye when the annotation is included in the hover tooltip and a closed-eye (slashed) when it isn't (packages/core/src/components/control-bar/annotation-select.ts).
  • "Raw value:" → "Value:" (non-bold) — renamed the label and replaced the bold .label styling with new .tooltip-annotation-raw-label / .tooltip-annotation-raw-value classes (both font-weight: normal, muted color) (packages/core/src/components/scatter-plot/protein-tooltip.{ts,styles.ts}). The numeric-binning Playwright test that greps the row was updated accordingly.
  • Tooltip overflow at the bottomscatter-plot.ts now measures the real rendered tooltip height in updated() and uses it for the vertical clamp in _getTooltipStyle() instead of a hardcoded tooltipApproxHeight = 160, so multi-block tooltips on points near the bottom edge stay fully inside the plot viewport.

@Moomboh Moomboh requested review from tsenoner and removed request for tsenoner May 19, 2026 12:35
Moomboh and others added 4 commits May 19, 2026 14:49
Lets users opt additional annotation features into the hover tooltip
alongside the primary annotation that drives the legend.

Dropdown UI:
- Primary indicator dot on the currently selected annotation row.
- (i) toggle on every other row that flips the annotation on/off in the
  hover tooltip. Hidden on the primary row (it is already shown).

Hover tooltip:
- Refactored TooltipView to carry an ordered blocks[] array. Each block
  carries its annotation key, display values, scores, evidence, and raw
  numeric value when applicable. The primary block renders first.

Persistence:
- New ?tooltip= URL param (comma-separated, deduped, primary stripped).
- Dataset-scoped localStorage seeded on dataset load when the URL does
  not pin a value, then kept in sync with subsequent toggles.
- Promoting an extra annotation to primary drops it from the extras.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Elias Kahl <contact@elias.works>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Swap (i) icon for open/closed-eye icons in annotation dropdown.
- Rename "Raw value" → "Value" and render it non-bold in the tooltip.
- Measure the actual tooltip height after render so multi-block tooltips
  no longer overflow the bottom of the plot viewport.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Moomboh Moomboh force-pushed the feat/multi-annotation-tooltip-234 branch from 4d21dfa to 2546e9f Compare May 19, 2026 12:50
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.

[FEATURE] Multi annotation tooltip

2 participants