Skip to content

ref(aci): Automatically zoom metric issues to the event's open period#109212

Merged
malwilley merged 2 commits intomasterfrom
malwilley/metric-detector-url-effect
Feb 24, 2026
Merged

ref(aci): Automatically zoom metric issues to the event's open period#109212
malwilley merged 2 commits intomasterfrom
malwilley/metric-detector-url-effect

Conversation

@malwilley
Copy link
Member

Closes ISWF-907

When a metric issue loads, this will look at the open period start/end times and apply time range filters so that it is centered in the chart. This is a much better user experience than the default 14 days. This will only happen if a time range isn't already present in the URL.

Before:

CleanShot 2026-02-24 at 11 01 24

After:

CleanShot 2026-02-24 at 11 01 01

malwilley and others added 2 commits February 24, 2026 10:21
…ssues

Set the event ID in the URL and default statsPeriod to 4h when viewing
metric detector triggered issues. Uses useEffectEvent to avoid stale
closures while re-running when the event ID changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Rename useApplyMetricDetectorDefaults to useZoomTimeRangeToOpenPeriod
for clarity, update buildDetectorZoomQuery to accept the zoom range
object directly, and fix test router config to use routes array.

Co-Authored-By: Claude <noreply@anthropic.com>
@malwilley malwilley requested review from a team and scttcper February 24, 2026 19:06
@malwilley malwilley requested a review from a team as a code owner February 24, 2026 19:06
@linear
Copy link

linear bot commented Feb 24, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 24, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

intervalSeconds={snubaQuery?.timeWindow}
openPeriodStart={startDate}
openPeriodEnd={endDate}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Zoom fires before open period data finishes loading

Medium Severity

ZoomToOpenPeriod is rendered unconditionally, so the useEffect fires on mount before the open period API response arrives. At that point, endDate is the fallbackEndDate (current time) because openPeriod is still null. The effect navigates with a zoom range based on Date.now() instead of the real open period end. When the API response updates openPeriodEnd, the effect re-fires but bails out because the first navigation already set time params in the URL. For historical/resolved issues, this produces a much wider zoom window than intended.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

It only activates if there is a start date which won't happen if there is no api response

@malwilley malwilley merged commit ed3c13f into master Feb 24, 2026
64 checks passed
@malwilley malwilley deleted the malwilley/metric-detector-url-effect branch February 24, 2026 19:33
mchen-sentry pushed a commit that referenced this pull request Feb 24, 2026
…#109212)

When a metric issue loads, this will look at the open period start/end
times and apply time range filters so that it is centered in the chart.
This is a much better user experience than the default 14 days. This
will only happen if a time range isn't already present in the URL.
wedamija pushed a commit that referenced this pull request Feb 24, 2026
…#109212)

When a metric issue loads, this will look at the open period start/end
times and apply time range filters so that it is centered in the chart.
This is a much better user experience than the default 14 days. This
will only happen if a time range isn't already present in the URL.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants