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".

How to test

On this branch, import this dashboard to ClickStack and follow the instructions:
{"version":"0.1.0","name":"TEST: static filters \"all\"","tiles":[{"id":"6b096a1f51746a33febcf914","x":0,"y":0,"w":24,"h":6,"config":{"name":"How to use this demo","source":"","displayType":"markdown","markdown":"**Try it:** in the `region` filter, pick nothing, then one region, then **All**.\n\nSelected regions: [$region]\n\n`eu-west-1` is in the sample data but is not a filter option. Expected row counts (bare variable / filter macro / conditionalAll macro):\n\n- **Nothing:** 0 / 5 / 5. The bare variable renders NULL; both macros become 1=1.\n- **One region:** 1 / 1 / 1.\n- **All:** 4 / 4 / 5. The bare variable and filter macro get the 4 options; conditionalAll becomes 1=1, so `eu-west-1` stays.","select":[],"where":""}},{"id":"6b096a1f51746a33febcf915","x":0,"y":6,"w":8,"h":3,"config":{"displayType":"number","configType":"sql","sqlTemplate":"SELECT count() AS rows\nFROM (SELECT arrayJoin(['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'eu-west-1']) AS region)\nWHERE region IN ($region)","connection":"Local ClickHouse","name":"Bare variable: region IN (...)"}},{"id":"6b096a1f51746a33febcf916","x":8,"y":6,"w":8,"h":3,"config":{"displayType":"number","configType":"sql","sqlTemplate":"SELECT count() AS rows\nFROM (SELECT arrayJoin(['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'eu-west-1']) AS region)\nWHERE $__filter(region, $region)","connection":"Local ClickHouse","name":"Filter macro"}},{"id":"6b096a1f51746a33febcf917","x":16,"y":6,"w":8,"h":3,"config":{"displayType":"number","configType":"sql","sqlTemplate":"SELECT count() AS rows\nFROM (SELECT arrayJoin(['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'eu-west-1']) AS region)\nWHERE $__conditionalAll(region IN ($region), $region)","connection":"Local ClickHouse","name":"conditionalAll macro"}},{"id":"6b096a1f51746a33febcf918","x":0,"y":9,"w":24,"h":6,"config":{"displayType":"table","configType":"sql","sqlTemplate":"WITH data AS (SELECT arrayJoin(['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'eu-west-1']) AS region)\nSELECT\n  region,\n  if(region IN ($region), 'kept', 'dropped') AS bare_variable,\n  if($__filter(region, $region), 'kept', 'dropped') AS filter_macro,\n  if($__conditionalAll(region IN ($region), $region), 'kept', 'dropped') AS conditional_all_macro\nFROM data\nORDER BY region\nLIMIT 10","connection":"Local ClickHouse","name":"Which rows each one keeps"}}],"filters":[{"id":"aa0dacf9-a3de-440d-92aa-1c5097b17f2c","name":"region","variableName":"region","type":"STATIC_LIST","options":["us-east-1","us-east-2","us-west-1","us-west-2"],"allowAll":true,"isBroadcastEnabled":false,"isVariableEnabled":true}],"containers":[]}

Screenshots or video

Screenshot 2026-11-27 at 12 24 58 Screenshot 2026-11-27 at 12 24 48

References


Note

Medium Risk
Changes variable resolution, macros, and persisted filter state across UI and APIs; incorrect expansion could affect dashboard query results, though scope is limited to optional static-list multi-select filters with heavy test coverage.

Overview
Multi-select static list dashboard filters can now expose an "All" choice via a new allowAll setting (Include "All" option in the filter editor; hidden for single-select).

Selecting All persists as { values: [], all: true } in dashboard filter state and saved defaults. VirtualMultiSelect and useDashboardFilters carry that selection through the UI and URL; required filters treat All as satisfied. Query variables expand to every declared option for $variable and $__filter, and $__conditionalAll becomes 1=1, aligned with Grafana-style behavior.

OpenAPI, external API, and MCP accept allowAll and saved all: true (with validation: no allowAll on single-select or SQL query filters yet). The internal dashboard API drops stale all values when allowAll is removed so saves are not blocked; the external API rejects invalid combinations. MCP tile runs can simulate All via variableValues: { all: true }.

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

@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 Dec 2, 2026 10:31am UTC
hyperdx-storybook Ready Ready Preview Dec 2, 2026 10:31am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: efb84d8

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 109 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.

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

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

🔵 3 P3 — no action needed before merge
  • 🔵 P3 packages/common-utils/src/dashboardFilterValues.ts:242 — dropUnsupportedAllValues repeats the logic of validateDashboardSavedFilterValues → Move the declared-name and all-capable-name set building into one shared helper and call it from dropUnsupportedAllValues, from validateDashboardSavedFilterValues (packages/common-utils/src/dashboardValidation.ts:358-376) and from the allCapableNames set in packages/api/src/mcp/tools/dashboards/variables.ts:129. Right now three hand-kept copies decide which saved "all" values are supported, and they can drift apart.
  • 🔵 P3 packages/app/src/components/VirtualMultiSelect/VirtualMultiSelect.tsx:237 — New data-has-values attribute is never read → Remove the data-has-values attribute. A search of packages/app finds no selector, test or CSS that uses it, so it is dead output on the input.
  • 🔵 P3 packages/app/src/DashboardFilters.tsx:253 — "All" state is worked out a second time from variables by name, though the hook already has it by filter ID → Return variableSelectionByFilterId from useDashboardFilters and pass it down, or put it into selectionByFilterId. Then DashboardFilterSelect can read the "All" state by filter.id, and there is no need to rebuild a name-keyed set from variables. As written, there are two sources of truth for the same selection, keyed differently (variable name vs. filter ID).

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.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 494 passed • 1 skipped • 1134s

Status Count
✅ Passed 494
❌ 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

Scope: PR #3847 — "All" option for static-list dashboard filters, across packages/app, packages/api (external REST + MCP + internal), and packages/common-utils. Base f8f36ed5.

🟡 P2 — recommended

  • packages/api/src/routers/external-api/v2/utils/dashboards.ts:2131 — Partial updates bypass the new saved-"all" validation: validateDashboardSavedFilterValues(data.filters ?? [], …) sees an empty filter list when a request omits filters, so an all: true value looks addressed to an undeclared name and is kept instead of rejected; the external PUT /:id handler then persists savedFilterValues while leaving the stored filters untouched (packages/api/src/routers/external-api/v2/dashboards.ts:4068), and MCP patchDashboard sets savedFilterValues with no all-capability check at all (packages/api/src/mcp/tools/dashboards/patchDashboard.ts:104). The stale value is inert on load, so this is a contract leak rather than corruption, but it contradicts the stated "external API rejects" behavior.
    • Fix: Validate saved filter values against the effective filter set (request filters merged with the persisted dashboard's filters), or drop unsupported all values on these paths as the internal API already does.
    • correctness, api-contract, previous-comments, adversarial
🔵 P3 nitpicks (1)
  • packages/common-utils/src/dashboardFilterValues.ts:238 — dropUnsupportedAllValues and validateDashboardSavedFilterValues (packages/common-utils/src/dashboardValidation.ts:348) independently reimplement the same declaredNames / allCapableNames derivation, so the "which filters offer All" rule can drift between the drop path and the reject path.
    • Fix: Extract a shared helper that returns the declared and all-capable name sets and call it from both.
    • maintainability

Prior review items confirmed resolved in this diff: the "SQL query All stays unexpanded" concern (filterFormState.ts destructures allowAll out of ...rest and re-adds it only on the static-list branch, so switching a filter to SQL query drops it), and the internal-API "saved all blocks saves" concern (handled by dropUnsupportedAllValues on both POST and PATCH). The "All on SQL query filters" item is an acknowledged deferred follow-up.


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

Testing gaps:

  • No test covers the partial-update bypass (external PUT / MCP patchDashboard sending all: true saved values without filters); the added API tests send all alongside filters.
  • No regression test for a stale all: true persisting after allowAll is turned off or the filter is made single-select via the external/MCP partial-update path.

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

@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 c9cd0d6. Configure here.

data.filters ?? [],
data.savedFilterValues ?? [],
ctx,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Partial updates skip All-value checks

Medium Severity

validateDashboardSavedFilterValues only sees the request body's filters, and an omitted field is treated as an empty list. Names then look undeclared, so all: true is kept. External PUT and MCP save/patch can persist that default on a filter that does not set allowAll, which this change is meant to reject.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c9cd0d6. 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 force-pushed the claude/sql-filter-all-static-list branch from c9cd0d6 to efb84d8 Compare December 2, 2026 10:28
placeholder={value.length === 0 ? filter.name : undefined}
placeholder={hasSelection ? undefined : filter.name}
values={value}
enableAllOption={filterSupportsAllValue(filter)}

ghost Dec 2, 2026

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 — SQL query filters with allowAll now show an "All" option that gives tiles no values

Restrict filterSupportsAllValue (packages/common-utils/src/filters.ts:1143) to STATIC_LIST until SQL query filters can expand "All". The alternative is to reject allowAll on SQL_QUERY in the internal API's addFilterIssues. Today the internal POST/PATCH /dashboards (packages/api/src/routers/api/dashboards.ts:53) accepts allowAll on SQL_QUERY, because SqlQueryDashboardFilterSchema in types.ts:2571 allows it and only the external API omits it. The predicate returns true for such a filter, so this dropdown offers "All". But expandAllSelections in useDashboardFilters only gets static-list options, so the variable keeps values: []. The result is that $var renders NULL and $__filter becomes 1=1, which contradicts the hint text. MCP resolveDashboardVariables does the same: it accepts all: true for these filters and returns empty 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


<Combobox.Dropdown>
<Combobox.Options>
{showAllOption && (

ghost Dec 2, 2026

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 — A real option named "All" looks the same as the synthetic "All" row and pill

Hide or rename the synthetic row, or reject an "All" option when allowAll is set. Consider a static list that already has an option literally called All, which is a common workaround before this feature. If it turns on allowAll, the dropdown shows two identical "All" rows, and the selected pill reads "All" in both cases. The user cannot tell "every option" apart from the single value 'All'.

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

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — efb84d8e Deployed Dec 2, 2026 by vercel[bot]
Preview – hyperdx-storybook — efb84d8e Deployed Dec 2, 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