Skip to content

fix: persist filter expand state upon scrolling - #3377

Merged
knudtty merged 3 commits into
mainfrom
aaron/filter-expand-fix
Oct 15, 2026
Merged

knudtty merged 3 commits into
mainfrom
aaron/filter-expand-fix

Conversation

@knudtty

@knudtty knudtty commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Persists filter expand state upon a scroll in and out of view.

Screenshots or video

Before

export-1792073549803.mp4

After

export-1792073420807.mp4

How to test on Vercel preview

Steps:

  1. Expand a filter
  2. Scroll
  3. Scroll back

References

  • Linear Issue: Closes HDX-5723

@changeset-bot

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e451b2

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

@vercel

vercel Bot commented Oct 15, 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 Oct 15, 2026 3:00pm UTC
hyperdx-storybook Ready Ready Preview Oct 15, 2026 3:00pm UTC

Request Review

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

github-actions Bot commented Oct 15, 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: 110 (+ 187 in test files, excluded from tier calculation)
  • Branch: aaron/filter-expand-fix
  • Author: knudtty

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

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 125 in total (1.71%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Oct 15, 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:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • 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
    severity. Reply with one sentence; if it is critical, 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 critical · 🟠 0 major · 🔵 2 minor

2 posted as inline comment(s) on 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.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Keeps nested filters expanded or collapsed after their rows leave the screen and return.

  • Nested filter keys keep their settings when they leave and return to the list.

Reviews (3) · Last reviewed commit: "persist distributions" · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Persisting child filter expand/showDistributions state across virtualized row unmount/remount. The core state-lifting and the render-phase derived-state sync are correct and converge (no render loop), useEffectEvent is an established React 19.2 pattern in this repo, and the new tests assert real behavior. Findings below are reliability and maintainability refinements, none blocking.

✅ No critical issues found.

🟡 P2 — recommended

  • packages/app/src/components/DBSearchPageFilters.tsx:533 — Because expanded state now persists in childState, scrolling an errored-distribution row out of view and back remounts FilterGroupBody (mounted on isExpanded); its error effect re-runs on mount and the staleTime: Infinity cached distributionError re-fires the "Error loading filter distribution" toast, so repeated scrolling spams duplicate toasts.
    • Fix: Guard the notification so a given error instance notifies only once across mounts, e.g. track the last-notified error reference instead of firing on every mount that observes a cached error.
    • julik-frontend-races
  • packages/app/src/components/DBSearchPageFilters/NestedFilterGroup.tsx:123 — childState is keyed by child.key and only ever added to, never pruned, so it grows unbounded over a session and a stale expanded/showDistributions entry can leak onto a same-named key after the source or childFilters changes while the group stays mounted.
    • Fix: Prune childState to the live childFilters key set (or qualify keys by source) when childFilters identity changes.
    • maintainability, julik-frontend-races
  • packages/app/src/components/DBSearchPageFilters/NestedFilterGroup.tsx:1 — The file grows from 294 to 336 lines, crossing the AGENTS.md 300-line component limit that it previously satisfied; this was also raised in prior review and remains unaddressed.
    • Fix: Extract the expand/distribution state logic (childState, updateChildState, keyHasSelections, and the render-phase sync) into a small hook to bring the file back under 300 lines.
    • maintainability, previous-comments
  • packages/app/src/components/DBSearchPageFilters/NestedFilterGroup.tsx:126 — The render-phase auto-expand reducer is the subtlest new logic but each direction is only tested once in isolation; the lose-then-regain cycle (manually collapse a selected child, remove its filter, re-add it) and simultaneous multi-key changes are untested, so a per-key merge regression would pass silently.
    • Fix: Add tests for the lose-then-regain re-expansion and for a multi-key simultaneous selection change through the changedKeys reducer.
    • testing, correctness
🔵 P3 nitpicks (3)
  • packages/app/src/components/DBSearchPageFilters/NestedFilterGroup.tsx:120 — The comment describes the user-facing behavior but not that this is intentional render-phase setState (not an effect) and that it terminates because each pass sets hadSelections equal to keyHasSelections, risking a future "fix" into a useEffect or a feared infinite loop.
    • Fix: Add a one-line note naming the render-phase pattern and its termination invariant.
  • packages/app/src/components/DBSearchPageFilters/NestedFilterGroup.tsx:51 — ChildState marks expanded and hadSelections as required, but { ...prev[key], ...patch } spreads can build objects missing those fields when prev[key] is undefined; noUncheckedIndexedAccess is off so TS accepts it, making the required-ness misleading for any future reader who drops the optional chaining.
    • Fix: Make the fields optional (or seed defaults in updateChildState) so the type reflects runtime reality.
  • packages/app/src/components/DBSearchPageFilters.tsx:951 — setExpanded/setShowDistributions always write the uncontrolled state and fire the callback even when controlled, producing a dead local write, and the isDefaultExpanded effect is silently ignored whenever expanded is controlled.
    • Fix: Guard the local write behind an is-uncontrolled check (if (expanded === undefined) setUncontrolledExpanded(v)) to keep a single source of truth.

Reviewers (6): correctness, testing, maintainability, kieran-typescript, julik-frontend-races, previous-comments.

Testing gaps:

  • No test drives the real useVirtualizer scroll path (unmount is proxied via the search filter); acceptable in jsdom but the genuine scroll mechanism is unexercised.
  • The new controlled expanded/showDistributions props on FilterGroup are covered only transitively through NestedFilterGroup, not in isolation.
  • No test asserts the distribution-error toast fires at most once across a row remount (the behavior the useEffectEvent change guards).
  • Combined collapse + showDistributions persistence across a single unmount/remount is untested.

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 Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 415 passed • 1 skipped • 1734s

Status Count
✅ Passed 415
❌ Failed 0
⚠️ Flaky 2
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew left a comment

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.

LGTM

@knudtty
knudtty merged commit f21bdb8 into main Oct 15, 2026
30 checks passed

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 8e451b2a Deployed Oct 15, 2026 by vercel[bot]
Preview – hyperdx-storybook — 8e451b2a Deployed Oct 15, 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.

2 participants