Skip to content

feat: Add button to remove stale dashboard URL filter params - #3874

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
cursor/remove-stale-dashboard-url-filters-a110
Dec 1, 2026
Merged

kodiakhq[bot] merged 4 commits into
mainfrom
cursor/remove-stale-dashboard-url-filters-a110

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a dashboard URL carries filters= entries that match no declared dashboard
filter, we show a "Some filters could not be applied" warning banner. The banner
explained the problem but left the stale state in the URL, so the only way to
clear it was to hand-edit the address bar.

This PR adds a button to the banner that strips exactly the mismatched expressions and variable
names in one click and dismisses the banner, leaving valid selections untouched.

Screenshots or video

Screen.Recording.2026-12-01.at.1.11.31.PM.mov

How to reproduce

Starting point: full-stack yarn dev (dashboards need the API).

On main:

  1. Create a dashboard with a variable-enabled filter named Service (variable svc).
  2. Open it with a URL that also carries unmatched state, e.g.
    ?filters=[{"type":"variable","name":"groupBy","values":["ServiceName"]},{"type":"sql","condition":"team IN ('platform')"},{"type":"variable","name":"svc","values":["accounting"]}].
  3. The "Some filters could not be applied" banner shows; the only way to clear the stale groupBy/team state is to edit the URL by hand.

On this branch:

  1. Same steps 1–2.
  2. Click Remove filters from URL on the banner.
  3. The banner clears, the stale groupBy/team entries are gone from the URL, and the valid Service = accounting selection stays. It stays gone after a reload.

How to test on Vercel preview

N/A — the repro needs the API to persist a dashboard, so it can't run in LOCAL_MODE preview.

References

  • Linear Issue: HDX-6239

Note

Low Risk
URL filter cleanup is scoped to already-ignored entries; valid selections are preserved and the change is covered by unit and e2e tests.

Overview
When the "Some filters could not be applied" banner appears for stale filters= URL params, users can click Remove ignored values from URL to strip unmatched SQL expressions and orphaned variable entries in one action, dismiss the banner, and keep valid filter selections unchanged.

useDashboardFilters exposes new removeIgnoredFilterState, which updates the URL filters= param by deleting only ignoredFilterExpressions and ignoredVariableNames while preserving declared selections and passthrough entries (no-op when nothing is stale). Unit, preset-hook mock, and e2e coverage accompany the dashboard UI button (data-testid="remove-ignored-url-filters-button").

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

Co-authored-by: Drew Davis <pulpdrew@gmail.com>
@pulpdrew
pulpdrew requested a review from a team as a code owner December 1, 2026 14:12
@vercel

vercel Bot commented Dec 1, 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 1, 2026 8:32pm UTC
hyperdx-storybook Ready Ready Preview Dec 1, 2026 8:32pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d5dcd69

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

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 45 (+ 165 in test files, excluded from tier calculation)
  • Branch: cursor/remove-stale-dashboard-url-filters-a110
  • Author: pulpdrew

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

@github-actions

github-actions Bot commented Dec 1, 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 Dec 1, 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.

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

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

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/hooks/__tests__/useDashboardFilters.test.tsx:52 — New tests never check the 'passthrough and ad hoc entries stay' promise → Add a case with a lucene/sql_ast passthrough entry and a declared ad hoc filter's {type:'adhoc'} entry next to the stale ones, and assert both are still in mockState after removeIgnoredFilterState(). Right now a regression that dropped passthrough or ad hoc state would still pass every test.

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.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a tightly scoped, well-tested change. The core logic (removeIgnoredFilterState) was independently traced by the correctness, adversarial, kieran-typescript, and frontend-races reviewers, and all four confirmed it cannot delete a declared selection: ignoredExpressions/ignoredVariableNames are derived from the declared filters set, so a declared expression or variable name is by construction never in the ignored lists, and the deletes target unique keys. The stale-closure path can only under-remove (banner lingers), never over-delete. The explicit setShouldShowIgnoredFiltersBanner(false) is correct and necessary because the banner's re-show effect is latched per dashboard id.

🟡 P2 -- recommended

  • packages/app/src/hooks/useDashboardFilters.tsx:390 -- removeIgnoredFilterState re-serializes passthrough entries (e.g. lucene / sql_ast) but no unit or e2e test exercises a passthrough entry, so a future refactor that drops passthrough on cleanup would pass CI unnoticed.
    • Fix: Add a unit case where a passthrough entry coexists with a stale expression and assert the passthrough entry survives while the stale one is removed.
    • testing, kieran-typescript, correctness, adversarial
🔵 P3 nitpicks (3)
  • packages/app/src/hooks/__tests__/useDashboardFilters.test.tsx:647 -- Ad hoc entries are deleted/preserved through the same byVariable path as plain variables, but the new describe block has no ad hoc coverage, leaving the orphaned-removed/declared-kept distinction untested.
    • Fix: Add a case with a declared ad hoc filter plus an orphaned ad hoc entry and assert only the orphan is dropped.
    • testing, correctness
  • packages/app/src/hooks/useDashboardFilters.tsx:387 -- Re-serializing the whole parsed state (rather than routing through rebuildEntries) can, under a hand-written URL carrying an explicit empty variable entry plus a legacy expression entry for the same declared filter, drop the empty entry and revive the legacy selection; not reachable via state the app's own serializer emits.
    • Fix: Route removal through rebuildEntries, or preserve present-but-empty variable entries during re-serialization.
    • adversarial
  • packages/app/src/hooks/useDashboardFilters.tsx:380 -- The parse/serialize round-trip only round-trips IN/NOT IN/BETWEEN clauses, so clicking the button rewrites even declared, untouched sql entries and silently discards any non-faceted predicate text they carried; active selections are unaffected and only hand-written conditions hit this.
    • Fix: Only re-serialize when an ignored entry is actually present in prev, or preserve the original condition text for entries that are not being removed.
    • adversarial

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

Testing gaps:

  • No test asserts a passthrough (lucene/sql_ast) entry survives removeIgnoredFilterState.
  • No test for ad hoc orphaned-vs-declared entry removal.
  • No DBDashboardPage-level test exercises the button's onClick wiring (removeIgnoredFilterState + banner hide); only the hook method and an e2e flow cover it.
  • No test for the concurrent-update case where prev differs from the filterValueEntries the memo observed.

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

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

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

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

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew changed the title Add button to remove stale dashboard URL filter params feat: Add button to remove stale dashboard URL filter params Dec 1, 2026
@pulpdrew
pulpdrew requested a review from karl-power December 1, 2026 19:47
return;
}
setFilterValueEntries(prev => {
const parsed = parseDashboardFilterValues(prev ?? []);

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.

🔴 P1 — Cleanup round-trip also silently drops sql URL entries that parseQuery can't parse, which the banner never listed

parseDashboardFilterValues → serializeDashboardFilterValues only keeps sql entries that parseQuery turns into IN/NOT IN/numeric BETWEEN (see packages/common-utils/src/filters.ts:507 and dashboardFilterValues.ts:93). An entry like {type:'sql', condition:"status = 'error'"} never shows up in ignoredFilterExpressions, so the banner doesn't mention it, but clicking the button deletes it anyway. That breaks the doc comment's promise that only the listed values are removed. Fix: when nothing parseable changes, leave the raw sql entries in prev as they are, or report entries that don't parse as ignored so the banner lists them too.

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

@kodiakhq
kodiakhq Bot merged commit 2a5652c into main Dec 1, 2026
29 of 30 checks passed
@kodiakhq
kodiakhq Bot deleted the cursor/remove-stale-dashboard-url-filters-a110 branch December 1, 2026 20:37

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — d5dcd694 Deployed Dec 1, 2026 by vercel[bot]
Preview – hyperdx-storybook — d5dcd694 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants