Skip to content

fix(app): Improve heatmap hover state alignment and reliability - #3273

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
drew/heatmap-series-1
Oct 2, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
drew/heatmap-series-1

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR makes three improvements to the heatmap hover state

  1. The hover state is applied to the closest cell with bounds that are within a margin of the cursor, instead of a cell whose center is within in a margin of the cursor. This improves the hover state functionality when the cells are larger than the defined margin
  2. The hover state highlight is now centered over the cell, rather than offset 50% to the right and below.
  3. Previously, onMouseEnter did not fire when the data refreshed while the cursor was still in the chart, so changing heatmap settings or query would break the hover state until the mouse exited and re-entered the heatmap. Using onMouseMoveCapture makes this more reliable.

Screenshots or video

Before

Screen.Recording.2026-10-02.at.8.23.08.AM.mov

After

Screen.Recording.2026-10-02.at.8.22.36.AM.mov

How to test on Vercel preview

View the heatmap either on chart-explorer, dashboards, or search page event deltas

References

  • Linear Issue: Closes HDX-5603
  • Related PRs:

@changeset-bot

changeset-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 98820bb79b7b661639444280ac5243de74404ede

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 2, 2026 12:25pm UTC
hyperdx-storybook Ready Ready Preview Oct 2, 2026 12:25pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 3
  • Production lines changed: 140 (+ 137 in test files, excluded from tier calculation)
  • Branch: drew/heatmap-series-1
  • Author: pulpdrew

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 127 in total (1.80%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

setHighlightedPoint(point);
// Keep the same object while the cursor stays on one cell, so
// moving within it doesn't re-render the tooltip.
setHighlightedPoint(prev =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Tooltip dedup keyed only on closestIndex keeps stale count/position after a data refresh or resize

When the cursor stays still and the data refreshes (live mode) or the chart resizes, uPlot runs setCursor again and the plugin reports a fresh point with the same closestIndex. Because the updater returns prev whenever the indices match, the tooltip keeps the old countVal/xVal/xCoord/xSize. After a live refresh the same index can even point to a different time bucket. Before this PR, a resize rebuilt the plugin and reset lastDataPointIndex; now the state survives that. Fix: keep prev only when the fields that are rendered also match (xVal, yVal, countVal, xCoord, yCoord, xSize, ySize), and add a HeatmapPlot test for it.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor

None could be anchored to changed lines; they are listed below.

Findings outside the changed lines

2 minor
  • 🔵 packages/app/src/components/DBHeatmapChart/highlightDataPlugin.ts:50 — uPlot's hidden-cursor position (-10,-10) now highlights the top-left cell → When the pointer leaves uPlot's over element, uPlot calls setCursor with left/top = -10. That position is still inside the parent container, over the axes, so mouseInsideRef stays true. Edge-distance matching then finds the top-left cell: its distance is hypot(10,10)≈14, which is under the margin of 20, and it is 0 if that cell overhangs the plot edge. So moving from the plot onto the y-axis or x-axis labels pops the tooltip onto whichever non-empty top-left cell is nearby. Fix: treat left < 0 || top < 0 as hidden and report undefined, e.g. if (top == null || left == null || left < 0 || top < 0) { onPointHighlight(undefined); return; }. Add a test for it.
  • 🔵 packages/app/src/components/DBHeatmapChart/__tests__/HeatmapPlot.test.tsx:149 — No test covers the isSameRenderedPoint dedupe the PR adds → The new tests only check that the tooltip updates when values change. If setHighlightedPoint(prev => isSameRenderedPoint(prev, point) ? prev : point) went back to always storing the new object, every test would still pass, so the dedupe that avoids re-renders is never exercised. Add a case that sends an equal-valued but different object to onPointHighlight and asserts the tooltip does not re-render. For example, spy on HeatmapTooltip renders, or check that the rendered highlight element is the same node.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes heatmap tooltip positioning and hover detection.

The PR appears safe to merge; no new actionable issue was established.

Summary

The PR selects heatmap cells by distance to their bounds, centers the highlight over the selected cell, and updates hover handling and tests. The change since the previous review switches the hover gate from mouse entry to captured mouse movement.

Reviews (3) · Last reviewed commit: "fix(app): Match heatmap hover to the cel..."

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a focused, well-tested heatmap-hover fix. The cursor→cell matching now measures distance to cell bounds (via distanceToRect) instead of cell centers, the highlight box is correctly re-centered (yCoord - ySize/2, xCoord - xSize/2), and onMouseMoveCapture is a sound choice: the container's capture-phase handler sets mouseInsideRef before uPlot's native setCursor listener on the inner over element runs, so the gate is reliably set on the first move after a data refresh. The prior greptile P1 ("stale hover after refresh") is substantively addressed — isSameRenderedPoint now compares countVal and geometry, so a same-index cell with new values updates the tooltip.

🟡 P2 — recommended

  • packages/app/src/components/DBHeatmapChart/__tests__/HeatmapPlot.test.tsx:118 — tests cover the gating and the same-index-new-values update, but not the core dedup no-op path where isSameRenderedPoint returns prev so no re-render occurs when the cursor moves within one cell.
    • Fix: Add a test that invokes onPointHighlight twice with an equal point (differing only in non-rendered fields like closestDistance) and assert the tooltip content/state is retained without a new render.
🔵 P3 nitpicks (3)
  • packages/app/src/components/DBHeatmapChart/HeatmapPlot.tsx:22 — isSameRenderedPoint hand-lists every HighlightedPoint field, so adding a rendered field to the type later will silently omit it from the equality check and reintroduce stale-tooltip behavior.
    • Fix: Drive the comparison from an explicit key array typed as (keyof HighlightedPoint)[] (or add a comment tying it to the type) so new fields surface at review time.
  • packages/app/src/components/DBHeatmapChart/highlightDataPlugin.ts:60 — the data-space prefilter applies Math.min/Math.max for the y bounds (pixels invert values) but assumes a strictly increasing x axis, so xLo/xHi would be swapped and over-cull cells if the x scale were ever reversed.
    • Fix: Compute xLo/xHi with Math.min/Math.max for symmetry, or add a comment documenting the ascending-x assumption.
  • packages/app/src/components/DBHeatmapChart/HeatmapPlot.tsx:294 — if the data refreshes while the cursor is perfectly stationary, uPlot does not re-fire setCursor, so the tooltip can briefly retain the pre-refresh values until the next mouse move.
    • Fix: Document this as an accepted edge case, or re-run the highlight computation when the grid/plot data changes.

Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, previous-comments.

Testing gaps: No assertion that moving within a single cell avoids a re-render (the isSameRenderedPoint identity-preserving path); stationary-cursor-during-refresh behavior is unverified.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 393 passed • 1 skipped • 1486s

Status Count
✅ Passed 393
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the drew/heatmap-series-1 branch from 98820bb to 4e7c8e0 Compare October 2, 2026 12:22
@pulpdrew pulpdrew changed the title fix(app): Match heatmap hover to the cell under the cursor fix(app): Improve heatmap hover state alignment and reliability Oct 2, 2026
@pulpdrew
pulpdrew requested a review from karl-power October 2, 2026 12:35

@teeohhem teeohhem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@kodiakhq
kodiakhq Bot merged commit 3615f12 into main Oct 2, 2026
32 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/heatmap-series-1 branch October 2, 2026 13:33

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 4e7c8e0a Deployed Oct 2, 2026 by vercel[bot]
Preview – hyperdx-storybook — 4e7c8e0a Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants