feat: Add generated PromQL preview - #2998
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 25c63a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
Greptile SummaryThis PR adds a read-only Generated PromQL panel that previews the last submitted expression after dashboard-variable substitution.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/app/src/components/DBEditTimeChartForm/utils.ts | Builds rendered PromQL with the same substitution helper used by query execution and returns an explicit error when expansion fails. |
| packages/app/src/components/DBEditTimeChartForm/ChartPreviewPanel.tsx | Adds the Generated PromQL accordion and derives its enabled state and content from the submitted chart configuration. |
| packages/app/src/components/PromQLEditor/PromQLPreview.tsx | Introduces a read-only, syntax-highlighted PromQL preview with clipboard support. |
| packages/app/src/components/DBEditTimeChartForm/tests/ChartPreviewPanel.test.tsx | Covers preview visibility, pre-run state, substitution results, empty selections, and substitution failures. |
| packages/app/tests/e2e/features/dashboard-filter-variables.spec.ts | Exercises generated PromQL against dashboard variable selections and explicit variable formats. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Input[PromQL editor template] --> Run[Run query]
Variables[Dashboard variables] --> Substitute[Substitute variables]
Run --> Substitute
Substitute -->|Success| Query[Send rendered PromQL to Prometheus]
Substitute -->|Success| Preview[Generated PromQL preview]
Substitute -->|Failure| Disabled[Disable preview and show reason]
Reviews (3): Last reviewed commit: "feat: Add generated PromQL preview" | Re-trigger Greptile
| return ( | ||
| <CopyToClipboard text={text ?? ''} onCopy={() => setCopied(true)}> | ||
| <Button | ||
| variant={copied ? 'light' : 'default'} |
There was a problem hiding this comment.
Copied state uses unapproved variant
The extracted copy button selects the unapproved light variant after copying, so both SQL and PromQL previews bypass the application's Button styling contract and can render inconsistently with the design system.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
That makes sense for the HDX_XXX placeholder behavior, but it appears to address a different review thread. This comment is specifically about PreviewCopyButton.tsx: variant="light" is not an approved Button variant in this repo. The copied state should use an approved variant such as default or subtle.
E2E Test Results✅ All tests passed • 320 passed • 1 skipped • 1410s
Tests ran across 4 shards in parallel. |
c0fb0cb to
12353c2
Compare
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Deep Review✅ No critical issues found. This PR adds a read-only "Generated PromQL" preview accordion and extracts two shared components ( 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Resolved from prior review: The earlier P1 "substitution failure shown as generated query" is fixed — Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, previous-comments. Testing gaps: |
12353c2 to
25c63a1
Compare
Summary
This PR adds a preview panel to the promql chart editor, similar to the existing Generated SQL preview panel. This allows the user to see the PromQL with variables substituted.
This PR also includes a couple of refactors to share parts of the preview component / accordion with the SQL version.
Screenshots or video
How to test
ResourceAttributes['service.instance.id']from the metrics gauge tablehttp_client_duration_milliseconds_count{instance=~"$Instance"}References