feat(web): selectable preview timeframe on the alert rule form - #576
Merged
Conversation
The create/edit form's preview chart was pinned to a canned last-24h lookback. Put the standard TimeRangePicker in the hero header so the window the preview query evaluates over — and the chart domain and threshold/would-fire rendering that follow it — can be changed while authoring. The selection is component-local (not URL, not persisted) and never reaches the saved rule; it only feeds `useAlertRulePreview`, which already accepted a range for the rule detail page. The edit page shares this surface via /alerts/create?ruleId=, so it gets the same control.
🍁 Maple PR previewNote Preview resources were removed when this pull request closed. Final commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The alert create/edit form's preview chart was pinned to a canned last-24h lookback, so there was no way to check a candidate rule against a shorter spike or a longer stretch of history before saving it.
What changed
RuleLiveChartHerorenders the standardTimeRangePicker(default preset set, 5m–1mo) in its header strip, next to "Test rule". The static "Live · last 24h" label is gone — the picker's trigger carries the window.useAlertRulePreview(which already accepted a range for the rule detail page) and the chart domain, so the axis, threshold line, and would-fire bands all follow it.AlertCreateFormSurface: not in the URL, not persisted, and never part of the rule payload that gets saved. Default stays24h, matching the rule detail page./alerts/create?ruleId=, so it gets the control for free.The server caps a preview at 200 evaluation buckets and reports
truncated_to_start, so a long window degrades rather than failing.Verification
bun typecheck— 40/40 tasks pass.bun run --cwd apps/web test -- src/components/alerts— 5 files / 40 tests pass, including a newrule-live-chart-hero.test.tsxcovering the picker label for a preset and for a custom range.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.