Skip to content

feat(app): reorder dashboard filters with up/down controls - #3876

Merged
pulpdrew merged 2 commits into
mainfrom
cursor/dashboard-filter-reorder-af40
Dec 1, 2026
Merged

pulpdrew merged 2 commits into
mainfrom
cursor/dashboard-filter-reorder-af40

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Dashboard filters and variables are stored as an ordered list, and that order drives both the edit-filters modal list and the on-page filter bar — but until now there was no way to change it. This adds up/down controls to each row in the "Filters and Variables" modal so a user can move a filter earlier or later. The control at an end (up on the first, down on the last) is disabled.

Reordering permutes the dashboard's existing filters array, so no schema change is needed and the new order is persisted and reflected everywhere the filters render.

Scope: the main dashboard (DBDashboardPage), where variables live. The controls are gated behind an optional onReorder prop, so the Services preset dashboard — whose filters are persisted individually server-side with no array order, and which renders with showVariableOptions=false — simply doesn't show them.

Screenshots or video

Before After
Filters modal: Alpha, Bravo, Charlie with up/down controls Filters modal after moving Alpha down: Bravo, Alpha, Charlie

How to reproduce

Starting point: full-stack yarn dev (the reorder saves through the dashboard update API).

On main:

  1. Open a dashboard and click "Edit filters".
  2. Add two or more filters.
  3. Observe there is no way to change their order.

On this branch:

  1. Open a dashboard and click "Edit filters".
  2. Add two or more filters.
  3. Use the up/down chevrons on a row to move it; the list and the filter bar reflect the new order, which persists across a reload.

How to test on Vercel preview

N/A — the reorder persists through the dashboard update API, which the LOCAL_MODE preview does not run.

References

  • Linear Issue: HDX-6240

Resolves HDX-6240

Testing

  • New unit tests in DashboardFiltersModal.test.tsx (move up/down by index, ends disabled, controls hidden without a handler).
  • New E2E dashboard-filter-reorder.spec.ts (full-stack): creates three filters, moves one down and another up, confirms the order persists across a reload.
  • yarn lint:fix and yarn tsc --noEmit clean.
Open in Web Open in Cursor 

Fixes HDX-6240


Note

Low Risk
UI-only reorder of the existing filters array with no auth, schema, or query-logic changes; gated behind an optional callback for surfaces that don’t support ordered filter lists.

Reviewed by Cursor Bugbot for commit 79a5540. 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 16:46
@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 4:59pm UTC
hyperdx-storybook Ready Ready Preview Dec 1, 2026 4:59pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 79a5540

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: 4
  • Production lines changed: 62 (+ 224 in test files, excluded from tier calculation)
  • Branch: cursor/dashboard-filter-reorder-af40
  • 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.

});
};

const handleReorderFilter = (fromIndex: number, toIndex: number) => {

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 — Reorder is computed from stale dashboard data, so quick repeated clicks overwrite each other on saved dashboards

On a saved dashboard, setDashboard sends a PATCH and only updates the list when the ['dashboards'] refetch comes back (packages/app/src/dashboard.ts:159-187, 279-319). Nothing updates the list in the meantime, so the rows keep their old order and the chevrons stay clickable. Each click builds a full filters array from the old order and replaces the saved one. Example: starting from [A,B,C], clicking 'down' on A twice quickly sends [B,A,C] both times, so A moves one place instead of two. Clicking A down and then C up quickly sends [A,C,B] last, which throws away A's move. The PATCHes can also arrive out of order. The E2E spec works around this by polling between moves. Fix: disable the reorder buttons while isLoading (which already reflects isSavingDashboard || isFetchingDashboard), or update the ['dashboards'] cache optimistically in onMutate.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed in 79a5540. The reorder chevrons are now disabled while a save is in flight (isLoading = isSavingDashboard || isFetchingDashboard), so a second click can't fire until the list reflects the first move's new order. Added a unit test for the disabled-while-saving state. I went with disabling rather than an optimistic onMutate to keep the change out of dashboard.ts, which this PR doesn't otherwise touch.

@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): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 2 P3

No inline comments. 2 P3 folded at the bottom.

🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/DashboardFiltersModal/DashboardFiltersList.tsx:105 — New icon-only move up/down controls use UnstyledButton plus a hand-rolled disabled class, which breaks the REQUIRED icon-only → ActionIcon rule → Render the chevrons as <ActionIcon variant="subtle" disabled={upDisabled} aria-label=…>. ActionIcon already provides disabled styling, so .filterActionButtonDisabled in DashboardFiltersModal.module.scss can be dropped. This breaks the 'Icon-Only Buttons → ActionIcon' and 'Prefer Mantine components over custom-styled elements' conventions.
  • 🔵 P3 packages/app/src/DBDashboardPage.tsx:2141 — Inner if (draft.filters) can never be false: the early return above already guarantees dashboard.filters is set → Drop the inner guard and write setDashboard({ ...dashboard, filters: arrayMove(dashboard.filters, fromIndex, toIndex) }). This matches the shape of handleRemoveFilter just above, and produce is not needed for a whole-array replacement.

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.

The change is a well-contained, UI-only reorder affordance gated behind an optional onReorder prop. The prior Cursor Bugbot findings are confirmed resolved in the current diff: handleReorderFilter now uses arrayMove, and the reorder chevrons are disabled while a save is in flight (isLoading = isSavingDashboard || isFetchingDashboard). Tracing dashboard.ts, the remote-path race is effectively closed — setIsSetting(true) runs synchronously in the click handler, and on success invalidateQueries(['dashboards']) keeps isFetchingDashboard true across the refetch until dashboard reflects the new order.

🟡 P2 -- recommended

  • packages/app/src/components/DashboardFiltersModal/DashboardFiltersList.tsx:254 -- The reorder chevrons lock during an in-flight save, but the Edit, Remove, and Add-new controls in the same modal do not, so clicking Remove during the reorder's PATCH+refetch window runs off the stale pre-reorder dashboard closure (there is no optimistic cache write) and issues a second concurrent PATCH that silently drops the move.
    • Fix: Gate the Edit, Remove, and Add-new controls on the same isLoading flag, or add an optimistic onMutate update in useUpdateDashboard so no handler ever reads a stale filter order.
    • julik-frontend-races
🔵 P3 nitpicks (7)
  • packages/app/src/DBDashboardPage.tsx:2136 -- handleReorderFilter has no internal re-entrancy guard; correctness relies entirely on the disabled prop re-rendering before the next interaction.
    • Fix: Add a one-line if (isSavingDashboard || isFetchingDashboard) return; self-guard at the top of the handler.
    • julik-frontend-races
  • packages/app/src/DBDashboardPage.tsx:2136 -- handleReorderFilter duplicates the produce + arrayMove logic of the sibling handleReorderContainers but lives inline and is not wrapped in useCallback.
    • Fix: Colocate it with the other dashboard mutation helpers and memoize it so the two reorder handlers evolve together.
    • maintainability
  • packages/app/src/components/DashboardFiltersModal/index.tsx:107 -- The callback is named onReorderFilter at the page and modal layers but renamed to onReorder when passed to DashboardFiltersList, adding a translation step readers must track.
    • Fix: Thread a single name unchanged through every layer, matching the stable onReorderContainers convention.
    • maintainability
  • packages/app/src/components/DashboardFiltersModal/DashboardFiltersList.tsx:228 -- The reorder data-testid and aria-label are keyed on filter.name, which is not guaranteed unique, so two filters with the same display name produce colliding test ids and ambiguous labels.
    • Fix: Key the data-testid on filter.id; this extends a pre-existing name-based convention, so align the whole row if changed.
    • kieran-typescript, correctness, maintainability
  • packages/app/src/components/DashboardFiltersModal/DashboardFiltersList.tsx:222 -- The disabled state is encoded in two places: the native disabled attribute and the filterActionButtonDisabled class that re-adds pointer-events: none on top of it.
    • Fix: Drive the disabled visual off the :disabled pseudo-class so the state has a single source of truth.
    • maintainability, kieran-typescript
  • packages/app/src/components/DashboardFiltersModal/DashboardFiltersList.tsx:290 -- The file reached ~290 lines with this change, approaching the project's 300-line component guideline.
    • Fix: Extract the per-row action cluster into a small FilterRowActions subcomponent before the next addition crosses the limit.
    • project-standards
  • packages/api/src/mcp/tools/dashboards/schemas.ts:2117 -- The MCP filters param description does not state that the array order is now user-visible as the dashboard filter-bar order, so an agent could reorder filters during an unrelated edit without realizing it changes the display.
    • Fix: Add a one-line note to the filters param description that array order determines the left-to-right order of filters in the dashboard filter bar.
    • ce-agent-native-reviewer

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

Prior comments: The three earlier Bugbot comments (arrayMove adoption, disable-while-saving race, ActionIcon vs UnstyledButton) are confirmed addressed or explicitly declined; no prior feedback is left unresolved.

Testing gaps:

  • The disabled-while-saving test asserts only the disabled attribute; no test clicks a control during isLoading and asserts onReorderFilter is not invoked, nor exercises the remote save → invalidate → refetch window where the original race lived.
  • No test covers the local (URL-state) dashboard reorder path, where isLoading stays false and the controls never lock.
  • No test asserts the controls re-enable on the save onError path (a failed reorder PATCH should not leave them permanently disabled).
  • handleReorderFilter's arrayMove wiring and !dashboard?.filters guard have no direct unit coverage; the array mutation is validated only through the full-stack E2E spec.

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

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

Comment thread packages/app/src/DBDashboardPage.tsx Resolved
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 488 passed • 1 skipped • 1105s

Status Count
✅ Passed 488
❌ Failed 0
⚠️ Flaky 9
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@cursor

cursor Bot commented Dec 1, 2026

Copy link
Copy Markdown

Re the P3s:

  • arrayMove + fromIndex bounds — adopted in 79a5540. handleReorderFilter now uses arrayMove from @dnd-kit/sortable, matching handleReorderContainers, which removes the hand-rolled splice and the unchecked-fromIndex concern.
  • Reorder logic coverage — now routed through the shared, library-tested arrayMove; the unit tests assert the modal wiring (callback args + disabled states) and the full-stack E2E asserts the resulting order and its persistence, so I didn't extract a separate helper to unit-test.
  • ActionIcon vs UnstyledButton — kept UnstyledButton so the up/down chevrons match the edit/delete controls in the same row; mixing ActionIcon (own hover bg/sizing) into that row would look inconsistent. Happy to switch the whole row if a maintainer prefers.

@pulpdrew
pulpdrew merged commit db34d79 into main Dec 1, 2026
34 of 35 checks passed

This branch was successfully deployed

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

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