feat: Support dashboard variables in chart builder tiles - #2901
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 2e1a153 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 |
5531572 to
9df95f9
Compare
E2E Test Results✅ All tests passed • 296 passed • 1 skipped • 1108s
Tests ran across 4 shards in parallel. |
Greptile SummaryThis PR extends dashboard-variable support from raw SQL tiles to chart-builder configurations.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains in the eligible follow-up-review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/app/src/DBDashboardPage.tsx | Supplies referenced dashboard variables to builder tile query configurations and to the chart editor’s completion context. |
| packages/common-utils/src/variables.ts | Adds traversal, substitution, reference detection, formatting, and validation support for builder-chart variable templates. |
| packages/common-utils/src/core/renderChartConfig.ts | Applies dashboard-variable substitution before rendering builder chart configurations into queries. |
| packages/app/src/components/SQLEditor/variableCompletions.tsx | Centralizes SQL and Lucene variable completion generation and provides dashboard variables through React context. |
| packages/app/src/components/SQLEditor/variableValidation.tsx | Adds editor-side validation and warning presentation for variable references. |
| packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx | Integrates variable-aware preview rendering and validation into the builder chart form. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Filters[Dashboard filters] --> Variables[Chart variables]
Variables --> Referenced[Referenced-variable filtering]
Referenced --> TileConfig[Builder tile configuration]
TileConfig --> Substitute[Language-aware substitution]
Substitute --> Render[Chart SQL rendering]
Render --> ClickHouse[(ClickHouse)]
Variables --> Provider[Editor variable provider]
Provider --> Inputs[Builder SQL and Lucene inputs]
Inputs --> Completion[Completion and validation]
Reviews (6): Last reviewed commit: "fix: Fix sample matching events variable..." | Re-trigger Greptile
9df95f9 to
9e8fb64
Compare
9e8fb64 to
b94023d
Compare
| case 'lucene': | ||
| return values.length === 0 | ||
| ? '*' | ||
| ? '("")' |
There was a problem hiding this comment.
This is a no-op (1=1), whereas * is a notEmpty(...)
| }; | ||
|
|
||
| /** What `snippet` expands to against the variable's current selection. */ | ||
| function describeVariableExpansion( |
There was a problem hiding this comment.
All this stuff has been moved to packages/app/src/components/SQLEditor/variableCompletions.tsx
| * the user through `resolveRawSqlMacros` — except when there is no context at | ||
| * all, in which case they silently pass through and are reported here. | ||
| */ | ||
| function validateVariableReferences(chartConfig: RawSqlChartConfig): { |
There was a problem hiding this comment.
Moved to packages/common-utils/src/variables.ts
b94023d to
d59161d
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Additional context: touches the query rendering engine lightly (19 lines, under the 150-line bar for Tier 4) Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Deep Review✅ No critical issues found. The core template engine ( 🟡 P2 — recommended
🔵 P3 nitpicks (3)🔵 P3 nitpicks (3)
Reviewers (12): correctness, security, adversarial, testing, maintainability, kieran-typescript, api-contract, performance, julik-frontend-races, project-standards, agent-native, learnings-researcher. Testing gaps: Confirm the |
d59161d to
e797e6b
Compare
e797e6b to
498e5fb
Compare
Summary
This PR extends dashboard variable support to Builder charts.
Note that creation of variables is gated behind
NEXT_PUBLIC_ENABLE_DASHBOARD_VARIABLES(enabled by default in development locally.Future work
Future work includes, but is not limited to:
Screenshots or video
Screen.Recording.2026-08-13.at.12.21.41.PM.mov
How to test locally
NEXT_PUBLIC_ENABLE_DASHBOARD_VARIABLES=trueReferences