Repository navigation
feat(app): pick the dashboard live mode refresh interval - #3745
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a46d993 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
4 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 3 P3 No inline comments. 3 P3 folded at the bottom. 1 unchanged from an earlier push (already inline above). 🔵 3 P3 — no action needed before merge
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. |
Deep Review✅ No critical issues found. This is a small, well-tested client-side feature: the refresh interval is ephemeral view state driving a 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers (3 returned): maintainability, previous-comments, agent-native. Correctness, testing, adversarial, kieran-typescript, and julik-frontend-races were dispatched but had not returned when output was finalized; the orchestrator independently verified the interval-selection/fallback logic, the Testing gaps: No test guards the 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 |
E2E Test Results✅ All tests passed • 476 passed • 1 skipped • 1054s
Tests ran across 4 shards in parallel. |
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) { |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Auto-approved by the AI review gate on a46d993. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
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:
Screenshots or video
How to reproduce
Starting point:
yarn app:dev:localconnected to the demo server, or the Vercel preview.On
main:On this branch:
How to test on Vercel preview
Preview routes: /dashboards
Steps:
data-testid="dashboard-refresh-interval-button".References
Note
Low Risk
UI and client-side refresh timing only; chart query granularity in live mode is unchanged, and the hook API remains backward compatible for other call sites.
Reviewed by Cursor Bugbot for commit a46d993. Bugbot is set up for automated code reviews on this repo. Configure here.