Skip to content

fix(app): highlight region above threshold for "above" alerts - #3488

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
cursor/fix-above-alert-highlight-e25c
Oct 29, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
cursor/fix-above-alert-highlight-e25c

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The alert preview chart shaded the wrong side of the threshold: for an "above" alert the red firing region was drawn below the threshold line. Outside/not between was also wrong.

Screenshots or video

Before

Screenshot 2026-10-29 at 8 43 35 PM Screenshot 2026-10-29 at 8 45 42 PM

After

Screenshot 2026-10-29 at 8 43 18 PM Screenshot 2026-10-29 at 8 45 50 PM

How to reproduce

Create an alert with an above or at least threshold.

References

  • Linear Issue: HDX-5836

@vercel

vercel Bot commented Oct 29, 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 29, 2026 7:53pm UTC
hyperdx-storybook Ready Ready Preview Oct 29, 2026 7:53pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 99ca2c9

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

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 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: 1
  • Production lines changed: 6 (+ 101 in test files, excluded from tier calculation)
  • Branch: cursor/fix-above-alert-highlight-e25c
  • 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 29, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

@github-actions

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 114 in total (1.41%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Corrects the shaded firing regions for above-threshold and outside-range alerts.

  • Alert charts shade above rules and outside not-between thresholds.

Reviews (3) · Last reviewed commit: "test(app): assert reference-area shading..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Scope: packages/app/src/components/Alerts.tsx (16 production lines) plus a new render-based test and a changeset. The fix swaps the open-ended ReferenceArea edges (y1↔y2) so above and not_between alerts shade the firing side of the threshold under Recharts v3.

The y1/y2 edge semantics are internally consistent across all branches (both "above" firing regions use bare y2; the "below" region uses bare y1), the new test renders each threshold type and asserts shaded-rect pixel positions against an independent ReferenceLine, and it would catch a future edge flip. Prior PR feedback is automated-bot only and the one substantive self-description checks out against the code.

✅ No critical issues found.

🟡 P2 — recommended

  • packages/app/src/components/Alerts.tsx:194 — The open-ended ReferenceArea edge convention (bare y1 shades toward the domain min, bare y2 toward the domain max) is subtle, un-commented, and is exactly the detail that produced this bug, so a future edit can silently re-invert the shading.
    • Fix: Add a short comment at the NOT_BETWEEN/ABOVE branches stating that a lone y1 shades downward and a lone y2 shades upward.
🔵 P3 nitpicks (3)
  • packages/app/src/components/__tests__/getAlertReferenceLines.test.tsx:94 — The NOT_BETWEEN assertions dereference rects.find(...)!, so a missing rect throws a cryptic TypeError instead of a readable assertion failure; the test still fails on a real regression, so this is diagnostics-only.
    • Fix: Assert expect(lower).toBeDefined() / expect(upper).toBeDefined() before reading .top/.bottom.
  • packages/app/src/components/Alerts.tsx:175 — threshold is typed number but guarded with threshold == null, so the guard is unreachable per the type; pre-existing and untouched by this diff.
    • Fix: Either widen the type to number | null | undefined or drop the dead guard to make the contract honest.
  • packages/app/src/components/Alerts.tsx:217 — BELOW uses a bounded area (y1={0} y2={threshold}) while the mirror-image ABOVE uses an open-ended area (y2={threshold} only), forcing a reader to reason about each case separately.
    • Fix: Add a one-line comment noting BELOW has a natural floor at 0 while ABOVE is intentionally open-ended.

Reviewers (5): correctness, testing, maintainability, kieran-typescript, previous-comments.

Testing gaps:

  • No assertion that the open edge of ABOVE/BELOW areas actually extends to the plot boundary — a bug clipping the open edge while keeping the correct side would pass.
  • The EQUAL/NOT_EQUAL ReferenceLine branch, the threshold == null early return, and negative-threshold extendDomain behavior remain uncovered (pre-existing paths, unchanged by this diff).

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 29, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 457 passed • 1 skipped • 1626s

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

Tests ran across 4 shards in parallel.

View full report →

cursoragent and others added 2 commits October 29, 2026 20:38
Recharts v3 flipped the default edge for open-ended ReferenceAreas: on the
Y axis a missing y1 now snaps to the top and a missing y2 to the bottom, the
reverse of v2. ABOVE/ABOVE_EXCLUSIVE used only y1, so the red firing region
filled below the threshold. NOT_BETWEEN was similarly inverted.

Move the single open-ended bound to the correct prop so the shaded region
lands on the firing side of the threshold, and pin the y1/y2 props per
threshold type in unit tests.

Co-authored-by: Drew Davis <pulpdrew@gmail.com>
Replace the prop-only getAlertReferenceLines tests with ones that render the
areas in a fixed-size chart and check which side of the threshold line gets
shaded. The prop-only checks restated the implementation and would survive a
future Recharts default-edge flip; they also tripped the app lint warning cap
via unsafe type assertions.

Co-authored-by: Drew Davis <pulpdrew@gmail.com>
@kodiakhq
kodiakhq Bot merged commit 4ea523a into main Oct 29, 2026
30 of 31 checks passed
@kodiakhq
kodiakhq Bot deleted the cursor/fix-above-alert-highlight-e25c branch October 29, 2026 20:33

This branch was successfully deployed

2 active deployments
Preview – hyperdx-storybook — 99ca2c93 Deployed Oct 29, 2026 by vercel[bot]
Preview – hyperdx-oss — 99ca2c93 Deployed Oct 29, 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.

3 participants