Skip to content

feat(web): selectable preview timeframe on the alert rule form - #576

Merged
JeremyFunk merged 1 commit into
mainfrom
feat/alert-preview-timeframe
Aug 23, 2026
Merged

feat(web): selectable preview timeframe on the alert rule form#576
JeremyFunk merged 1 commit into
mainfrom
feat/alert-preview-timeframe

Conversation

@JeremyFunk

@JeremyFunk JeremyFunk commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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

  • RuleLiveChartHero renders the standard TimeRangePicker (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.
  • The picked window drives 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.
  • Selection is component-local state in AlertCreateFormSurface: not in the URL, not persisted, and never part of the rule payload that gets saved. Default stays 24h, matching the rule detail page.
  • The edit page reaches the same surface via /alerts/create?ruleId=, so it gets the control for free.
  • The breach pill no longer hardcodes "No breaches in 24h".

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 new rule-live-chart-hero.test.tsx covering the picker label for a preset and for a custom range.
  • Not verified in a browser: no web dev server was running locally.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
@JeremyFunk
JeremyFunk merged commit 8496278 into main Aug 23, 2026
31 checks passed
@JeremyFunk
JeremyFunk deleted the feat/alert-preview-timeframe branch August 23, 2026 14:52
@github-actions

Copy link
Copy Markdown

🍁 Maple PR preview

Note

Preview resources were removed when this pull request closed.

Final commit 7d28d49 · View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant