Repository navigation
feat: Support single-select dashboard filters - #3295
Conversation
🦋 Changeset detectedLatest commit: bd596e2 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔴 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:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
5 finding(s): 🔴 0 critical · 🟠 2 major · 🔵 3 minor 4 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
Deep ReviewScope: PR #3295 — single-select dashboard filters ( The change is small, symmetric with the existing ✅ No critical issues found. No P0/P1 or P2 findings survived re-grading. The one substantive prior review comment (Greptile P1, "hidden input breaks typing test") is not confirmed: the e2e spec 🔵 P3 nitpicks (2)
Reviewers (6): correctness, api-contract, frontend-races, testing, maintainability, previous-comments. Testing gaps: Coverage is strong; two behaviors have no explicit assertion — clearing/removing a single-select pill back to empty, and toggling single-select off (confirming 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 |
E2E Test Results✅ All tests passed • 401 passed • 1 skipped • 1544s
Tests ran across 4 shards in parallel. |
| <PillsInput.Field | ||
| onFocus={() => combobox.openDropdown()} | ||
| onBlur={() => combobox.closeDropdown()} | ||
| type={isInputFieldLocked ? 'hidden' : 'visible'} |
There was a problem hiding this comment.
🟠 major — type="hidden" makes the combobox's only keyboard target unfocusable once a single-select filter has a value
A hidden input can't take focus and gets no key events. So once a value is picked, Tab skips the filter, arrow keys and Enter can't choose another option, the Backspace removal in handleKeyDown stops working, and you can't search a long list (e.g. the host picker from the MCP prompt) without clearing first. Keep the input type text and stop typing a second way instead: use readOnly plus caretColor: 'transparent', or ignore onChange while locked. Also drop 'visible': it isn't a valid input type and browsers just fall back to text.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| values: selection | ||
| ? Array.from(selection.included).map(String).sort() | ||
| : [], | ||
| maxSelections: filter.maxSelections, |
There was a problem hiding this comment.
🔵 minor — maxSelections is added to every tile's chart-config variables, and the app never reads it
The comment just above says variables are built explicitly 'so no extra key leaks into' react-query keys. This line adds such a key anyway: checking or unchecking single-select now refetches every tile that uses variables, and no query code reads it. Remove it here and from ChartVariableSchema (types.ts:1721). The only consumer is the MCP check in api/src/mcp/tools/dashboards/variables.ts, which can look up single-select names from the filters via getDashboardVariableFilters, the same way buildStaticOptionsByName already does.
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
| /** Empty means nothing is selected. */ | ||
| values: z.array(z.string()), | ||
| /** The filter's selection cap; 1 means the variable is single-select. */ | ||
| maxSelections: z.number().optional(), |
There was a problem hiding this comment.
🔵 minor — Selection cap is defined twice with different constraints
dashboardFilterBaseSchema.maxSelections is int().min(1).max(1), while the ChartVariableSchema copy accepts any number. If the variable-side field is kept, derive it from the filter schema (e.g. dashboardFilterBaseSchema.shape.maxSelections). Better, drop it, since only the declaration type needs it (see the useDashboardFilters finding).
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
| {showRequiredFilterOptions && ( | ||
| <Stack gap="xs"> | ||
| <Divider my="xs" /> | ||
| <CheckBoxControlled |
There was a problem hiding this comment.
🔵 minor — Single-select checkbox sits behind showRequiredFilterOptions, but that prop is documented as covering required-filter options only
The prop doc at line 69-70 (and in DashboardFiltersModal/index.tsx:19) says it controls 'the options for marking a filter as required', yet it now also hides the single-select option. Rename it (e.g. showSelectionLimitOptions) or give single-select its own flag, so a caller like ServicesDashboardPage can control the two separately.
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
## Summary This PR adds a new format for variable references - `promql`. This is intended to be used in promql expressions and is the new default when another format is not specified. This replaces the previous default (`regex`). The new format is identical in behavior to the previous format, except that single-select variables are not regex-escaped. Motivation: Single select variables are typically referenced in PromQL with `field="$var"`. If $var is regex escaped, that doesn't work. Multi-select should always be regex escaped and referenced via the regex match operator `field=~"$var"`. This is backwards compatible except for references to single-select variables (#3295), which have not yet been released. ### Screenshots or video <img width="795" height="201" alt="Screenshot 2026-10-05 at 1 04 19 PM" src="https://github.com/user-attachments/assets/67399be7-cb93-4ba7-9372-caff473533e5" /> ### How to test locally 1. Create a timeseries / promql source off of metrics_ts timeseries table 2. Create a dashboard with a promql labels variable 3. Reference the variable in a promql tile ### References - Linear Issue: Closes HDX-5563 - Related PRs:
Summary
Support configuring dashboard variables / filters as single-select, so that no more than one value can be selected.
If the URL contains multiple values for the filter, then the first is used.
Screenshots or video
How to test on Vercel preview
References