Skip to content

feat(app): pick the dashboard live mode refresh interval - #3745

Open
MikeShi42 wants to merge 4 commits into
mainfrom
cursor/dashboard-live-refresh-interval-06d1
Open

MikeShi42 wants to merge 4 commits into
mainfrom
cursor/dashboard-live-refresh-interval-06d1

Conversation

@MikeShi42

@MikeShi42 MikeShi42 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Dashboard live mode always refreshed at the time range's auto granularity: every 30m on a 24-hour range, for example. That is too slow for dashboards watched during an incident, and there was no way to change it.

The Live button is now a split button. The left side still toggles live mode. The right side shows the refresh interval and opens a "Refresh every" menu:

  • Auto (5m) is the first item and the default. It follows the time range, so the value in parentheses changes as the range changes.
  • Below a divider are fixed intervals from 30s up to the time range's auto value. Every one of them is fixed, including the one equal to auto: pinning 5m on a 3-hour range keeps 5m after widening to 24 hours.
  • The trigger reads "Auto (5m)" in auto mode and just "5m" for a fixed choice.
  • Picking any item turns live mode on.
  • If the range is narrowed so a fixed interval is slower than auto, auto is used. Widening the range again restores the fixed choice.
  • Chart granularity in live mode is unchanged; only how often the dashboard refreshes changes.
  • For ranges of 15 minutes or less auto is 15s, which is below the 30s floor, so auto is the only choice.

Screenshots or video

Before After (auto) After (fixed 5m on 24h)
Before: plain Live button Auto (5m) selected on a 3-hour range Fixed 5m kept after widening to 24 hours

How to reproduce

Starting point: yarn app:dev:local connected to the demo server, or the Vercel preview.

On main:

  1. Open Dashboards and create a dashboard.
  2. Set the time picker to "Last 24 hours".
  3. Hover "Live": there is no way to change the refresh interval.

On this branch:

  1. Open Dashboards and create a dashboard.
  2. Set the time picker to "Last 3 hours".
  3. Click "Auto (5m)" next to "Live". The menu lists "Auto (5m)" (checked), then 30s, 1m and 5m.
  4. Pick the fixed "5m". Live turns on and the trigger reads "5m".
  5. Set the time picker to "Last 24 hours". The trigger still reads "5m"; the menu now shows "Auto (30m)" and fixed 30s, 1m, 5m, 15m, 30m.
  6. Pick "Auto (30m)", then set the range back to "Last 3 hours". The trigger reads "Auto (5m)".

How to test on Vercel preview

Preview routes: /dashboards

Steps:

  1. Create a new dashboard.
  2. Set the time picker to "Last 3 hours".
  3. Click data-testid="dashboard-refresh-interval-button".
  4. Verify the menu lists "Auto (5m)", 30s, 1m and 5m, with "Auto (5m)" checked.
  5. Click "5m".
  6. Set the time picker to "Last 24 hours".
  7. Verify the "Live" button is highlighted and the interval button reads "5m".

References

  • Linear Issue: Resolves HDX-6135
  • Related PRs:
Open in Web Open in Cursor 

cursoragent and others added 2 commits November 20, 2026 18:46
Live mode refreshed at the date range's auto granularity only. The Live
button is now a split button whose menu offers 30s up to that default.

Co-authored-by: Mike Shi <mike@hyperdx.io>
Co-authored-by: Mike Shi <mike@hyperdx.io>
@MikeShi42
MikeShi42 requested a review from a team as a code owner November 20, 2026 18:49
@vercel

vercel Bot commented Nov 20, 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 Nov 20, 2026 7:18pm UTC
hyperdx-storybook Ready Ready Preview Nov 20, 2026 7:18pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 726b2e4

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 Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 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: 217 (+ 297 in test files, excluded from tier calculation)
  • Branch: cursor/dashboard-live-refresh-interval-06d1
  • Author: MikeShi42

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

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

@github-actions

github-actions Bot commented Nov 20, 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:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • 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
    priority. Reply with one sentence; if it is P0, 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 P0/P1 · 🟡 1 P2 · 🔵 1 P3

1 posted as inline comment(s) on the changed lines. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/hooks/useDashboardRefresh.tsx:17 — REFRESH_INTERVAL_CHOICES copies the auto-granularity ladder from convertDateRangeToGranularityString, and no test keeps the two in sync → The comment says this list is the set of values convertDateRangeToGranularityString (packages/common-utils/src/core/utils.ts:654) can return, minus 15s. If that ladder changes (for example, if it stops skipping 10m), the auto value can drop out of the fixed list and nothing fails. Fix: derive the list from one shared exported ladder in common-utils, or add a test that runs a series of date ranges and asserts each auto value of 30s or more appears in getRefreshIntervalOptions(auto).

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. No P0/P1 defects: the fixed-vs-auto fallback, the getRefreshIntervalOptions boundary filter, the Math.min(..., MAX_TIMER_DELAY_MS) clamp, and the setInterval effect were all traced and confirmed correct. Both prior cursor[bot] comments (empty options below 30s with the divider hidden, and the 2³¹-1 ms delay clamp) are genuinely addressed and covered by tests. convertGranularityToSeconds never returns 0 for any reachable Granularity, so the setInterval(0) tight-loop is unreachable.

🟡 P2 -- recommended

  • packages/app/src/hooks/__tests__/useDashboardRefresh.test.tsx:114 -- The headline new behaviors lack tests: the narrow→auto→widen→restore cycle (a fixed interval that drops below auto, then returns when the range widens) and re-establishing the timer at a new cadence when the selected interval changes mid-session; current tests cover each half separately but never the full transition.
    • Fix: Add a renderHook/rerender test that selects a fixed interval, narrows the range so it falls back to auto, then widens and asserts the original selection is restored, plus one that advances fake timers after an interval change to assert the new cadence fires without a double-fire.
    • testing, correctness, adversarial
  • packages/app/src/hooks/useDashboardRefresh.tsx:17 -- REFRESH_INTERVAL_CHOICES is a hand-maintained mirror of the granularities convertDateRangeToGranularityString can return, with no compile-time link or test guarding the asserted invariant ("a default of 30s or more is always one of the choices"); a future granularity added to that ladder would be silently unselectable.
    • Fix: Derive the choices from the Granularity enum filtered to >= 30s, or add a test asserting every value convertDateRangeToGranularityString can return appears in REFRESH_INTERVAL_CHOICES.
    • maintainability, kieran-typescript
🔵 P3 nitpicks (4)
  • packages/app/src/components/DashboardLiveButton.tsx:22 -- The interval menu is a single-select (radio) group but each item signals selection only via an icon and a non-semantic data-checked attribute, so screen readers do not announce the active interval.
    • Fix: Give the items role="menuitemradio" with aria-checked={checked}, and add aria-pressed to the Live toggle button whose state is otherwise only in title.
  • packages/app/src/components/DashboardLiveButton.tsx:27 -- refreshInterval, defaultRefreshInterval, and isAutoRefreshInterval are overlapping derived props whose equality in auto mode is an implicit invariant the caller must maintain.
    • Fix: Pass only the fixed selection (Granularity | undefined) plus defaultRefreshInterval and derive the label/auto-state inside the component to shrink the prop surface.
  • packages/app/src/hooks/useDashboardRefresh.tsx:126 -- Pre-existing: the effect depends on refresh, whose identity changes every time searchedTimeRange updates, so each tick tears down and recreates the interval, making it a self-chaining timeout that restarts the countdown per refresh rather than a steady schedule.
    • Fix: Hold the latest refresh in a ref and key the interval effect on [isRefreshEnabled, refreshInterval] only; out of scope for this PR since the diff neither introduces nor worsens it.
  • packages/app/src/hooks/useDashboardRefresh.tsx:78 -- Pre-existing: the manualRefreshCooloff setTimeout(…, 1000) id is never captured or cleared, so unmounting within a second fires setState on a dead component.
    • Fix: Store the timeout id in a ref and clear it on effect cleanup; out of scope for this PR.

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

Testing gaps:

  • No test exercises the narrow→auto→widen→restore cycle or the timer re-establishment when the selected interval changes mid-session.
  • No test covers DBDashboardPage wiring where picking any interval force-enables live mode (onRefreshIntervalChange → setIsLive(true)).
  • No test guards the REFRESH_INTERVAL_CHOICES ↔ convertDateRangeToGranularityString coupling against drift.

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 Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

❌ 1 test failed • 472 passed • 1 skipped • 1061s

Status Count
✅ Passed 472
❌ Failed 1
⚠️ Flaky 9
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

Every listed interval, including the date range's default, is now a
fixed choice. Auto is a separate first item.

Co-authored-by: Mike Shi <mike@hyperdx.io>
defaultInterval: Granularity,
): Granularity[] {
const maxSeconds = convertGranularityToSeconds(defaultInterval);
if (maxSeconds < MIN_REFRESH_INTERVAL_SECONDS) {

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.

🟡 P2 — Ranges of 15 minutes or less offer a fixed 15s interval that goes below the 30s floor, not 'auto only'

When the default is below MIN_REFRESH_INTERVAL_SECONDS, getRefreshIntervalOptions returns [defaultInterval]. DashboardLiveButton then renders it as a separate fixed item under 'Auto (15s)'. If the user picks it, selectedRefreshInterval becomes 15s and the trigger reads '15s', so the user has pinned a 15s refresh. The PR description says auto should be the only choice in this case. Fix: return [] here so only Auto is shown and no 15s selection can be stored. Then update the keeps a default faster than 30s test, which currently locks in the wrong behaviour.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed in 726b2e4: getRefreshIntervalOptions returns [] when the default is under 30s, so only Auto shows (the divider is hidden too). Test updated, plus a DashboardLiveButton test for the auto-only menu.

refresh();
},
convertGranularityToSeconds(granularityOverride) * 1000,
convertGranularityToSeconds(refreshInterval) * 1000,

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.

🟡 P2 — A 30d refresh interval overflows setInterval's 32-bit delay and refreshes in a tight loop

REFRESH_INTERVAL_CHOICES includes ThirtyDay. convertDateRangeToGranularityString returns it for ranges over about 420 days (60 buckets × 7d). 30d is 2,592,000,000 ms, which is above setInterval's limit of 2^31-1 ms, so browsers fire it almost immediately. Each refresh changes searchedTimeRange, which rebuilds refresh and restarts the interval, so the dashboard re-queries continuously. Fix: clamp the delay, e.g. Math.min(seconds * 1000, 2**31 - 1), or cap the choices at 7d.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed in 726b2e4: the delay is clamped to 2^31-1 ms, with a test for a 2-year range (30d auto). This also covers auto mode, which had the same overflow on main.

…elay

Ranges of 15 minutes or less now offer only Auto. A 30d interval exceeded
setInterval's maximum delay and refreshed in a tight loop. Also derives
auto vs fixed once and adds DashboardLiveButton tests.

Co-authored-by: Mike Shi <mike@hyperdx.io>
onClick: () => void;
}) {
return (
<Menu.Item

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.

🟡 P2 — Screen readers can't tell which refresh interval is selected

The selected item is marked only by a visual IconCheck and a data-checked attribute, and assistive tech reads neither. Give each Menu.Item role="menuitemradio" and aria-checked={checked}, and have the tests assert aria-checked instead of data-checked.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tried this: Mantine's Menu.Item sets role: "menuitem" after spreading props, so role="menuitemradio" is overridden, and aria-checked isn't valid on a plain menuitem. Fixing it means replacing Menu.Item with a custom item, which is more than this PR should take on; leaving it for a maintainer to decide.

This branch was successfully deployed

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

Labels

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