Skip to content

fix(replays): Clear stale filters when changing replay tabs#116768

Merged
nsdeschenes merged 8 commits into
masterfrom
nd/fix-replays-resolve-werid-searching-issue-on-tabs
Jun 3, 2026
Merged

fix(replays): Clear stale filters when changing replay tabs#116768
nsdeschenes merged 8 commits into
masterfrom
nd/fix-replays-resolve-werid-searching-issue-on-tabs

Conversation

@nsdeschenes
Copy link
Copy Markdown
Contributor

Replay detail filters now use typed nuqs query state and are cleared when users switch replay tabs. This prevents stale pane-specific filters or selected network details from carrying into another replay tab.

Replay Detail Filters

The shared replay filter hook now owns the known detail query parsers, and tests exercise real router query updates instead of mocked navigation.

Network Filter Defaults

The network filter menu keeps fetch and 200 available even when the current replay frames do not include those values.

Move replay detail filter URL state to typed nuqs parsers so tests exercise the router query behavior instead of mocked navigation.
Remove replay detail filter query parameters when the active replay tab changes so stale pane state does not carry into the next tab.
Include fetch and 200 as network filter options even when the loaded replay frames do not contain those values.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 3, 2026
@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@sentry review

@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@cursor review

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7d628c3. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

📊 Type Coverage Diff

✅ no issues found

Make replay detail filter field types module-local after tests stopped importing them. This keeps knip from reporting unused exported types.
Use the nuqs parser map as the source of truth for replay detail filter query updates. This removes the generic Query path that introduced new any-typed symbols and a query type assertion.
Replace the per-key object spread update with a typed helper that normalizes provided replay detail filters to nullable nuqs values.
@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@sentry review

@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@cursor review

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit dfeec90. Configure here.

Split replay detail filter keys by value type so the nullable update helper stays typed without a one-use generic parameter.
@nsdeschenes nsdeschenes marked this pull request as ready for review June 3, 2026 16:25
@nsdeschenes nsdeschenes requested a review from a team as a code owner June 3, 2026 16:25
Comment thread static/app/utils/replays/hooks/useFiltersInLocationQuery.tsx
Ensure replay detail location query filters cannot drift from the parser map. Adding a parser without adding it to a handled key group now fails typechecking instead of silently dropping URL state updates.

Co-Authored-By: Codex <codex@openai.com>
@nsdeschenes nsdeschenes merged commit 94eb8f5 into master Jun 3, 2026
70 checks passed
@nsdeschenes nsdeschenes deleted the nd/fix-replays-resolve-werid-searching-issue-on-tabs branch June 3, 2026 17:41
NicoHinderling added a commit that referenced this pull request Jun 3, 2026
The nuqs testing adapter (`tests/js/sentry-test/nuqsTestingAdapter.tsx`)
captured `location` from `useLocation()` inside its `updateUrl` and
`getSearchParamsSnapshot` closures. Because nuqs flushes updates on a
deferred tick (always at least `setTimeout(0)`), two setter calls fired
back-to-back composed onto a **stale** render snapshot — so the second
update dropped query params set by the first.

This surfaced after the `useFiltersInLocationQuery` migration to nuqs
`useQueryStates` (#116768). The old code merged manually (`{...query,
...updatedQuery}`) and always preserved prior params; the new code
delegates preservation to nuqs reading the live URL.
`useErrorFilters.spec` then failed because calling `setSearchTerm` after
a project filter dropped `f_e_project`.

This reads `location` through a ref that's updated every render, so the
deferred flush composes onto the live URL — matching the real
react-router v6 adapter, which reads `window.location`/`history` fresh
at flush time. It's a test-harness correction: production was never
affected, since the production adapter already reads live location and
composes sequential setters correctly.

Considered making the adapter read `window.location` directly like
production, but Sentry's TestRouter is in-memory, so a latest-ref over
`useLocation` is the correct source.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants