Skip to content

feat(app): create an SLO from a search, and duplicate an SLO - #3807

Open
alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-19-app-previewfrom
alex/HDX-3001-slo-20-app-from-search
Open

alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-19-app-previewfrom
alex/HDX-3001-slo-20-app-from-search

Conversation

@alex-fedotyev

@alex-fedotyev alex-fedotyev commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Search gets an SLO button that opens the SLO builder with the current
search as the eligible events: its source, query and filters are copied,
and a saved search's name becomes the SLO's name. The builder previews
such a definition as soon as its source loads. The list's row menu can
also duplicate an SLO, which opens the builder with its definition under a
"Copy of" name and without its alerts.

Stack

Part 20 of 27 PRs in a GitHub stack (stack #3815). The header says this PR merges into the branch below it, but the stack's base is main: merging a PR lands it and every PR below it on main, one squashed commit each. Each diff is only its own change, and CI runs as if each PR targets main.

  1. feat(common-utils): SLO definition schema #3788 common-utils: SLO definition schema
  2. feat(common-utils): SLO fast and slow burn rules #3789 common-utils: SLO fast and slow burn rules
  3. feat(common-utils): SLO alert targets and status types #3790 common-utils: SLO alert targets and status types
  4. feat(common-utils): SLO counts query #3791 common-utils: SLO counts query
  5. feat(common-utils): SLO stats and state #3792 common-utils: SLO stats and state
  6. feat(common-utils): SLO history and ordering #3793 common-utils: SLO history and ordering
  7. feat(api): SLO definitions behind ENABLE_SLOS #3794 api: SLO definitions behind ENABLE_SLOS
  8. feat(api): refresh SLO statuses in the check-alerts task #3795 api: refresh SLO statuses in the check-alerts task
  9. feat(api): SLO burn alerts as their own alert source #3796 api: SLO burn alerts as their own alert source
  10. feat(api): keep SLO alerts out of the external alerts API #3797 api: keep SLO alerts out of the external alerts API
  11. feat(api): evaluate SLO burn alerts and notify #3798 api: evaluate SLO burn alerts and notify
  12. feat(api): clickstack_get_slo MCP tool #3799 api: clickstack_get_slo MCP tool
  13. feat(api): SLO preview, save and delete MCP tools #3800 api: SLO preview, save and delete MCP tools
  14. feat(app): SLO list page behind NEXT_PUBLIC_ENABLE_SLOS #3801 app: SLO list page behind NEXT_PUBLIC_ENABLE_SLOS
  15. feat(app): search, filter, sort and delete SLOs in the list #3802 app: search, filter, sort and delete SLOs in the list
  16. feat(app): SLO builder for a new SLO #3803 app: SLO builder for a new SLO
  17. feat(app): SLO objective, details and editing in the builder #3804 app: SLO objective, details and editing in the builder
  18. feat(app): eligible-event filters and the latency template in the builder #3805 app: eligible-event filters and the latency template in the builder
  19. feat(app): preview an SLO in the builder before saving it #3806 app: preview an SLO in the builder before saving it
  20. feat(app): create an SLO from a search, and duplicate an SLO #3807 app: create an SLO from a search, and duplicate an SLO (this PR)
  21. feat(app): SLO detail page #3808 app: SLO detail page
  22. feat(app): bad events flyout on the SLO page #3809 app: bad events flyout on the SLO page
  23. feat(app): SLI, error budget and burn rate charts on the SLO page #3810 app: SLI, error budget and burn rate charts on the SLO page
  24. feat(app): fast and slow burn alerts in the SLO builder, list and page #3811 app: fast and slow burn alerts in the SLO builder, list and page
  25. feat(app): SLO alerts on the Alerts page #3812 app: SLO alerts on the Alerts page
  26. feat(app): group-by in the SLO builder #3813 app: group-by in the SLO builder
  27. feat(app): grouped SLOs in the list and on the SLO page #3814 app: grouped SLOs in the list and on the SLO page

Parts 1 to 6 are shared code, 7 to 13 the API and its MCP tools, and 14 to 27 the app. Everything ships behind ENABLE_SLOS (API) and NEXT_PUBLIC_ENABLE_SLOS (app), both off by default.

Screenshots or video

Before After
before, Search, light after, Search with the SLO button, light
after, dark
after, the builder opened from Search, light

How to reproduce

Starting point: yarn dev on this branch (the pages need the API). .env.development turns on ENABLE_SLOS and NEXT_PUBLIC_ENABLE_SLOS (parts 7 and 14). Use a trace or log source with data; the demo server works.

On the previous part: Search has no SLO button, and SLOs cannot be duplicated.

On this branch:

  1. In Search, run a query and click SLO next to Save and Alerts: the builder opens with the source, query and filters, and previews them.
  2. In the list, choose Duplicate from a row's menu: the builder opens with a "Copy of" name and no alerts.

Test plan

  • unit: sloForm.test.ts (copy without alerts, prefill from a search)
  • viewport: checked at 1440 px and in a narrow 900 px window. The list scrolls sideways and its toolbar wraps, the builder's preview moves under the form, and the SLO page's stats wrap to two columns.
  • app typecheck, lint and knip at this commit

How to test on Vercel preview

N/A: SLOs need the API, and the preview runs in local mode, where they are off.

References

  • Linear Issue: HDX-3001
  • Related PRs: the rest of this stack, listed above

[no-changeset: allow] The changeset for this piece is in part 27.

[no-story: allow] The new SLO components are page-level and fed by queries and form state, so this feature has no Storybook stories.

[ui-states: allow] No new empty, loading or error states here beyond the ones listed above.

[as-cast: allow] The cast check matches the word "as" in comments and strings here; the diff has no as casts.

@vercel

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

Request Review

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 53d40cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/api/src/routers/external-api/v2/alerts.ts:908-925 ↔ packages/api/src/routers/external-api/v2/alerts.ts:1181-1197 — 18 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


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

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 474 passed • 1 skipped • 1176s

Status Count
✅ Passed 474
❌ Failed 0
⚠️ Flaky 14
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

Search gets an SLO button that opens the SLO builder with the current
search as the eligible events: its source, query and filters are copied,
and a saved search's name becomes the SLO's name. The builder previews
such a definition as soon as its source loads. The list's row menu can
also duplicate an SLO, which opens the builder with its definition under a
"Copy of" name and without its alerts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev
alex-fedotyev force-pushed the alex/HDX-3001-slo-20-app-from-search branch from 400a06b to 53d40cf Compare November 24, 2026 18:58
@alex-fedotyev
alex-fedotyev marked this pull request as ready for review November 24, 2026 22:15
@alex-fedotyev
alex-fedotyev requested a review from a team as a code owner November 24, 2026 22:15
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 24, 2026
@github-actions

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: 6
  • Production lines changed: 162 (+ 35 in test files, excluded from tier calculation)
  • Branch: alex/HDX-3001-slo-20-app-from-search
  • Author: alex-fedotyev

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

if (autoPreviewedRef.current || !initializedRef.current || !source) return;
if (editId || !prefill.source) return;
autoPreviewedRef.current = true;
void trigger(PREVIEW_FIELDS).then(valid => {

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 — The preview for an SLO started from Search never runs, and a validation error shows instead

sloFormValuesFromSearch uses the default availability template with good: ''. SloIndicatorSchema's superRefine (packages/common-utils/src/slo.ts:215) rejects that, so trigger(PREVIEW_FIELDS) always resolves false. The user lands on a 'A good-event condition is required' error and no preview. The fix: validate only the eligible fields here, or skip validation of indicator.good (or build the preview from the eligible counts alone). Then add a test that drives this path, because the current unit test only checks the form values.

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

@github-actions

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 · 🟡 2 P2 · 🔵 0 P3

1 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

  • 🟡 P2 packages/app/src/components/Slos/CreateSloButton.tsx:74 — A missing whereLanguage falls back to 'lucene', but Search falls back to the stored language → DBSearchPage resolves a null whereLanguage as searchedConfig.whereLanguage ?? getStoredLanguage() ?? 'lucene' (e.g. DBSearchPage.tsx:1723). This button hardcodes 'lucene'. So a URL without whereLanguage, from a user whose stored language is SQL, hands the builder a SQL query labelled as Lucene. Use the same fallback, ideally by passing the resolved language in from DBSearchPage.

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

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. No P0/P1: the two behavioral defects below are edge-case paths (crafted/stale URL, or an SLO deleted between list-load and click), and every path that reaches a ClickHouse query or the server is gated by SloIndicatorSchema/SloInputSchema. P2 items are recommended before merge.

🟡 P2 — recommended

  • packages/app/src/components/Slos/SloEditorPage.tsx:70 — filters is parsed with parseAsJsonEncoded<Filter[]>() with no validator, so a URL whose filters param is valid JSON of the wrong shape (e.g. {}, 5, "x") flows through sloFormValuesFromSearch (whose ?? [] only guards null) into form state and crashes the builder at filters.filter(...) in SloEligibleFilters (TypeError, white screen); malformed JSON and the preview/save paths are already safe.
    • Fix: Pass a validator mirroring dashboardFilterValuesParser (z.array(FilterSchema).safeParse, falling back to null/[]) so a bad shape resolves to the empty default.
    • adversarial, kieran-typescript, security, correctness
  • packages/app/src/components/Slos/SloEditorPage.tsx:108 — when useSlo(duplicateId) errors or returns nothing (SLO deleted, unauthorized, or hand-edited id), the init effect's if (!original) return never sets initializedRef, so the page silently renders a blank New SLO form indistinguishable from a fresh create, with no error surfaced.
    • Fix: Surface the useSlo(duplicateId) error/not-found state (notification or inline message) instead of falling through to defaults.
    • adversarial
  • packages/app/src/components/Slos/__tests__/sloForm.test.ts:174 — the new unit tests cover only the lucene + null-filters path, leaving the feature's core branches untested: the non-lucene→sql coercion, non-empty filters pass-through, the 256-char name truncation, and the CreateSloButton encode → SloEditorPage decode round-trip that silently breaks the prefill if either side drifts.
    • Fix: Add cases asserting whereLanguage: 'sql'/omitted yields 'sql', a populated filters array lands in eligible.filters, a >256-char name is clamped, and the generated CreateSloButton href decodes back through prefillParsers.
    • testing, kieran-typescript, maintainability
🔵 P3 nitpicks (4)
  • packages/app/src/components/Slos/SloEditorPage.tsx:132 — the auto-preview effect has no dependency array (runs every render, self-gated by refs) and re-implements runPreview's validate-then-build sequence inline with no unmount flag or .catch; behavior is correct today but fragile to future edits.
    • Fix: Give the effect an explicit dependency array keyed on source/init state and call runPreview(), adding an ignored cleanup flag and a rejection handler.
  • packages/app/src/components/Slos/SloEditorPage.tsx:134 — the auto-preview guard excludes editId but not duplicateId, so a crafted ?duplicate=<id>&source=<...> URL loads the duplicate yet still auto-previews; benign and unreachable via normal flows.
    • Fix: Extend the guard to if (editId || duplicateId || !prefill.source) return;.
  • packages/app/src/DBSearchPage.tsx:2747 — the button is gated on !IS_LOCAL_MODE && IS_SLOS_ENABLED, but IS_SLOS_ENABLED already folds in !IS_LOCAL_MODE (config.ts:102-103), making the extra clause redundant and inconsistent with the single-gate pattern used elsewhere in the SLO code.
    • Fix: Gate on IS_SLOS_ENABLED alone.
  • packages/app/src/components/Slos/CreateSloButton.tsx:28 — the prefill param names are declared independently in three places (the URLSearchParams literals here, prefillParsers, and SloSearchPrefill), with nothing linking the encode side to the decode side, so a rename surfaces only as a silent runtime round-trip failure.
    • Fix: Share a single param-name constant/type across the encode and decode sides.

Reviewers (11): correctness, adversarial, security, kieran-typescript, julik-frontend-races, testing, maintainability, project-standards, agent-native, previous-comments, learnings-researcher.

Testing gaps:

  • No component test for SloEditorPage's edit-vs-duplicate-vs-prefill branch precedence or the one-shot auto-preview effect.
  • No test for a ?duplicate=<id> that errors/404s, asserting an error is surfaced rather than a silent blank form.
  • No test for a wrong-shape ?filters= param confirming the builder degrades to [] rather than crashing on render.
  • Agent-native parity confirmed (create-from-search and duplicate are reproducible via existing clickstack_get_slo/clickstack_save_slo/clickstack_preview_slo); no gap. No unaddressed prior-comment feedback (all four prior comments are automated bot notices).

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

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 53d40cf0 Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-storybook — 53d40cf0 Deployed Nov 24, 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.

1 participant