Skip to content

feat: add an "All" option to static list dashboard filters - #3847

Open
karl-power wants to merge 3 commits into
claude/sql-filter-all-foundationfrom
claude/sql-filter-all-static-list
Open

karl-power wants to merge 3 commits into
claude/sql-filter-all-foundationfrom
claude/sql-filter-all-static-list

Conversation

@karl-power

@karl-power karl-power commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Static list dashboard filters can now offer an "All" choice in their dropdown, which selects every option. Stacked on #3830, which added the data model and macro behaviour.

  • An Include "All" option checkbox in the static list filter settings sets allowAll. It's hidden for single-select filters.
  • The dropdown's "All" row and pill are ported from EE's source-filter dropdown (VirtualMultiSelect).
  • Picking "All" stores { type: 'variable', name, values: [], all: true } in the filters= state. It survives changes to other filters (fixes the feat: add groundwork for an "All" option on dashboard filters #3830 review comment) and counts as a selection for required filters.
  • Tiles get every option: $variable and $__filter expand to the full list, and $__conditionalAll expands to 1=1, matching Grafana.
  • The external API rejects a saved "all" value on a filter without "All". The internal API drops it instead, so a stale default left after turning "All" off doesn't block later saves. The external API and MCP now accept allowAll on static list filters and all on saved filter values. SQL query filters still reject allowAll until a follow-up expands their options.
  • MCP tile runs can simulate "All" with { name, values: [], all: true }.
  • The $__conditionalAll description in the SQL editor hint, the MCP prompt and the OpenAPI spec now covers "All".

Screenshots or video

to be filled

How to test on Vercel preview

to be filled

References


Note

Medium Risk
Touches dashboard variable resolution, filter URL state, and multiple API surfaces; behavior changes for macros when "All" is selected, but scope is limited to opt-in static list filters with broad test coverage.

Overview
Adds an "All" choice to static list dashboard filters when allowAll is enabled (multi-select only). Filter settings get an Include "All" option checkbox; VirtualMultiSelect exposes the row/pill and emits { all: true } instead of a value list.

Selections persist as { type: 'variable', name, values: [], all: true } in URL/saved state. "All" counts as satisfying required filters, expands to every static option for $variable / $__filter, and makes $__conditionalAll match 1=1 (Grafana-style). Shared helpers (resolveVariableSelection, dropUnsupportedAllValues, expandAllSelections) wire this through the app, OpenAPI, external API (validates allowAll and all: true), internal dashboard save (drops stale all when allowAll is off), and MCP (schema, prompts, variableValues simulation). SQL query filters still reject allowAll until a follow-up.

Reviewed by Cursor Bugbot for commit ff28689. Bugbot is set up for automated code reviews on this repo. Configure here.

- Static list filters get an `Include "All" option` setting; their dropdown
  then offers "All", ported from EE's source-filter dropdown
- "All" is stored as `all: true`, survives changes to sibling filters, counts
  as a selection for required filters, and expands to every option for tiles
- The internal and external dashboard APIs validate saved "all" values; the
  external API and MCP accept `allowAll` on static list filters and `all` on
  saved filter values, and MCP tile runs can simulate "All"
- Document the `$__conditionalAll` behaviour for "All" in the SQL editor hint,
  the MCP prompt and the OpenAPI spec
@karl-power
karl-power requested a review from a team as a code owner November 27, 2026 11:51
@vercel

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

Request Review

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff28689

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/api Minor
@hyperdx/app Minor
@hyperdx/common-utils Minor
@hyperdx/otel-collector Minor

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

@karl-power
karl-power added this pull request to stack #3848 November 27, 2026 11:52
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


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 27, 2026 •

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.

3 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 2 P3

1 posted as inline comment(s) on the changed lines. 2 P3 folded at the bottom.

🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/common-utils/src/dashboardFilterValues.ts:238 — dropUnsupportedAllValues repeats the declared/all-capable name logic in validateDashboardSavedFilterValues → Move the shared part into one helper that returns which all entries are unsupported, and use it from both dropUnsupportedAllValues and validateDashboardSavedFilterValues (packages/common-utils/src/dashboardValidation.ts:348). Right now both build the same declaredNames/allCapableNames sets from getFilterVariableName + filterSupportsAllValue and use the same keep rule, so the internal API (which drops the value) and the external API (which rejects it) can disagree if one copy changes. resolveDashboardVariables in packages/api/src/mcp/tools/dashboards/variables.ts:130 builds a third copy of allCapableNames.
  • 🔵 P3 packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:237 — The new data-has-values attribute is never read → Remove data-has-values. No test, page object, stylesheet or selector in packages/app refers to it.

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b319612. Configure here.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 483 passed • 1 skipped • 1098s

Status Count
✅ Passed 483
❌ Failed 0
⚠️ Flaky 10
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Static-list dashboard filters gain an "All" option (allowAll), threaded through the filter form, URL state ({type:'variable', values:[], all:true}), tile-macro expansion, the external API, and MCP. The round-trip is implemented consistently and well-tested; no critical issues surfaced. The findings cluster around validation surfaces that don't fully match the stated reject-vs-drop contract, plus the acknowledged SQL-query follow-up gap.

✅ No critical (P0/P1) issues found.

🟡 P2 — recommended

  • packages/api/src/routers/external-api/v2/utils/dashboards.ts:2016 — validateDashboardSavedFilterValues is called with data.filters ?? [], so a PUT that sends only savedFilterValues (filters omitted, which the schema allows) validates against an empty filter set, short-circuits on the "undeclared name" branch, and persists an unsupported all:true against an existing non-allowAll filter — the exact value the external API documents it rejects; sibling tile validation already falls back to existingDashboard.filters.
    • Fix: Pass the effective filter set (request filters falling back to the existing dashboard's filters) into validateDashboardSavedFilterValues, mirroring the tile-validation fallback.
    • adversarial-reviewer
  • packages/common-utils/src/filters.ts:1143 — filterSupportsAllValue returns true for a multi-select SQL_QUERY filter with allowAll, but every expandAllSelections caller supplies only static-list options (useDashboardFilters.tsx builds its options map with isStaticListFilter(...) ? ... : []), so such a filter's "All" keeps empty values; reachable through the internal /dashboards router, which accepts the full schema and runs neither validateDashboardFilterFieldGating nor validateDashboardSavedFilterValues, making $variable render NULL while $__filter/$__conditionalAll render 1=1.
    • Fix: Until SQL-query option expansion exists, narrow filterSupportsAllValue to STATIC_LIST (or reject allowAll on SQL_QUERY in the internal schema and add field-gating to the internal router) so the capability predicate cannot run ahead of expansion.
    • adversarial-reviewer, correctness-reviewer, julik-frontend-races-reviewer, kieran-typescript-reviewer, maintainability-reviewer, previous-comments-reviewer
  • packages/common-utils/src/dashboardFilterValues.ts:235 — The declaredNames/allCapableNames derivation in dropUnsupportedAllValues is duplicated verbatim in validateDashboardSavedFilterValues (dashboardValidation.ts:358); the two encode the same "declared vs all-capable" rule but diverge on outcome (drop vs reject), so they can drift as filter types that support "All" are added.
    • Fix: Extract a shared helper returning {declaredNames, allCapableNames} and call it from both the dropper and the validator.
    • maintainability-reviewer
  • packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:131 — The new Backspace-clears-"All" branch (if (isAllSelected) { onChange([]) }) has no unit or e2e coverage; VirtualMultiSelect.test.tsx exercises only dropdown-select and pill-remove.
    • Fix: Add a unit test that renders with enableAllOption+isAllOptionSelected, presses Backspace with empty search, and asserts onChange([]).
    • testing-reviewer
🔵 P3 nitpicks (7)
  • packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:22 — The ALL_ROW_VALUE sentinel ('__hdx_all_row__') shares the Combobox value space with user-authored options, so a static-list option literally equal to it is unselectable and toggles "All" instead; nothing enforces the documented invariant.
    • Fix: Route the "All" row through a dedicated mechanism (symbol/data-attribute) or filter the sentinel out of options.
    • adversarial-reviewer, maintainability-reviewer, kieran-typescript-reviewer
  • packages/api/src/routers/api/dashboards.ts:245 — Internal PATCH only runs dropUnsupportedAllValues when the body includes savedFilterValues, so a PATCH that flips allowAll off while omitting savedFilterValues leaves a stale all:true stored (ignored on load, but diverges from POST and silently reactivates if allowAll is re-enabled).
    • Fix: Re-run dropUnsupportedAllValues against updates.savedFilterValues ?? dashboard.savedFilterValues whenever filters change.
    • adversarial-reviewer, correctness-reviewer
  • packages/api/src/mcp/tools/dashboards/patchDashboard.ts:104 — clickstack_patch_dashboard writes savedFilterValues directly and runs only undeclared-name warnings, so it accepts an unsupported all:true that save_dashboard and both HTTP routers reject/drop (harmless at load, but persists dead data with no warning).
    • Fix: Apply dropUnsupportedAllValues (or extend the warning check to cover all-without-allowAll) in patchDashboard.
    • agent-native-reviewer
  • packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:104 — handleAddValue chooses replace-vs-merge from the isAllSelected prop, which lags behind the async nuqs URL round-trip, so two concrete picks in quick succession right after selecting "All" can drop the earlier pick.
    • Fix: Derive the add-vs-replace decision from the committed selection inside the functional updater rather than from the lagging prop.
    • julik-frontend-races-reviewer
  • packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:312 — The file grew from 245 to 312 lines, crossing the project's 300-line component guideline (CLAUDE.md principle 4).
    • Fix: Extract the "All"-row rendering/selection logic into a helper or subcomponent.
    • project-standards-reviewer
  • packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:117 — Deselecting "All" by re-clicking the active All row (onChange(isAllSelected ? [] : {all:true})) is only indirectly covered via the pill-remove path, a different handler.
    • Fix: Add a test clicking the active All row and asserting onChange([]).
    • testing-reviewer
  • packages/api/src/routers/external-api/v2/dashboards.ts:106 — The OpenAPI doc for the saved all value instructs callers to send an empty values, but neither the zod schema nor the spec enforces emptiness; a non-empty values alongside all:true is silently accepted and ignored.
    • Fix: Note in the description that values is ignored when all:true, so a stray value won't error.
    • api-contract-reviewer

Pre-existing (not introduced by this diff)

  • packages/api/src/routers/external-api/v2/utils/dashboards.ts:821 — The SQL_QUERY external-filter translation omits connection/source but not allowAll, while the external SQL_QUERY request shape strictly rejects allowAll; a SQL_QUERY filter carrying allowAll is returned on GET but 400s on verbatim PUT. Adjacent to this PR (which closed the same hole for STATIC_LIST) but independent of it.

Reviewers (10): correctness, adversarial, testing, maintainability, api-contract, kieran-typescript, julik-frontend-races, previous-comments, project-standards, agent-native.

Testing gaps:

  • No test exercises the internal /dashboards API accepting/storing allowAll on a SQL_QUERY or single-select filter (the one reachable surface for the expansion gap).
  • No external-API test for a PUT that sends savedFilterValues with all:true while omitting filters (the validation-bypass path).
  • No test for the full external GET→PUT round-trip of a static-list allowAll + variable all:true saved value.

Residual risks:

  • ALL_SELECTION is an exported mutable singleton returned by reference from resolveVariableSelection; safe only while no consumer mutates a returned selection — consider Object.freeze.
  • Expanded "All" emits a static list's options in sorted order rather than author display order (intended for stable query keys, but a semantic change if order ever matters).

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

@karl-power

Copy link
Copy Markdown
Contributor Author

P1 saved "all" blocking saves: fixed in 379678d. The internal API now drops saved "all" values whose filter no longer offers "All" instead of rejecting the save; the external API still rejects them.

P1 "All" on SQL query filters: known gap, handled in the follow-up PR that adds "All" to SQL query filters. Until then it's only reachable through the internal API directly: the edit form shows the checkbox on static lists only, and the external API and MCP reject allowAll on SQL query filters.

@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Tier 4 — Critical

Touches 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:

  • Critical-path files (2) — tenancy, public API, or shipped database config:
    • packages/api/src/routers/external-api/v2/dashboards.ts
    • packages/api/src/routers/external-api/v2/utils/dashboards.ts
  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Production files changed: 16
  • Production lines changed: 425 (+ 596 in test files, excluded from tier calculation)
  • Critical-path lines changed: 21
  • Branch: claude/sql-filter-all-static-list
  • Author: karl-power

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

Comment thread packages/app/src/DashboardFilters.tsx Resolved

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — ff28689f Deployed Nov 27, 2026 by vercel[bot]
Preview – hyperdx-storybook — ff28689f Deployed Nov 27, 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-4 Critical — deep review + domain expert sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant