feat: preserve compatible filters when switching sources#2314
feat: preserve compatible filters when switching sources#2314karl-power wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 27f5bd8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
PR Review✅ No critical issues found. A few minor observations (non-blocking):
Implementation looks well-scoped, with thorough unit coverage (including passthrough preservation) and three E2E scenarios. Direct-trace flow correctly left untouched. |
E2E Test Results❌ 1 test failed • 180 passed • 3 skipped • 1223s
Tests ran across 4 shards in parallel. |
Deep ReviewReviewed against base 🔴 P0/P1 -- must fix
🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Reviewers (10): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, reliability, adversarial, agent-native, learnings-researcher. Testing gaps:
|
d71e1d9 to
27f5bd8
Compare
Summary
Switching the active source on the
/searchpage used to clear all sidebar filters unconditionally. This was added (HDX-1176, HDX-1258, HDX-2545) to prevent broken queries when columns from the old source didn't exist on the new one, but users keep asking for filters to survive across compatible sources.This PR revisits that tradeoff with a per-filter rule: when the source changes, keep filters whose root column exists on the new source's schema, drop the rest, and surface a yellow toast naming the count of dropped filters.
searchFilters.tsx— newretainFiltersByColumns(allowed: Set<string>)helper onuseSearchPageFilterState. Returns the keys of dropped filters and syncs URL state viaupdateFilterQueryonly when something actually changed. Root-column extraction handles both top-level columns (ServiceName) and nested JSON/Map keys (LogAttributes.user.id→ rootLogAttributes), with an exact-match fallback for the rare case of a column whose name contains dots.DBSearchPage.tsx— replaced the unconditionalclearAllFilters()call in the source-change effect with apendingFilterReconcileRef. A follow-up effect runs onceuseColumnsfor the new source resolves and callsretainFiltersByColumns. The deep-link "open this trace by ID" path (onDirectTraceSourceChange) is intentionally untouched — it builds a fresh SQL where clause from scratch and is a different flow.notifications.show({ color: 'yellow', message: 'N filter(s) didn't apply to this source and were removed.' })fires only when at least one filter was dropped.Coverage: 6 unit tests for
retainFiltersByColumns(empty, all-kept, nested keys, all-dropped, mixed, passthrough preservation) and 3 Playwright E2E tests (compatible → preserved + no toast, mixed → toast + URL keeps shared filter, all-dropped → toast). Existing mocks inActiveFilterPills.test.tsxandDBSearchPage.directTrace.test.tsxwere updated for the new hook return shape.Screenshots or video
Screen.Recording.2026-05-20.at.16.14.59.mov
How to test on Vercel preview
Preview routes: /search
Steps:
/searchand select a logs source from the source dropdown.ServiceNamefilter group and check any value.SeverityTextfilter group and checkinfo.1 filter didn't apply to this source and was removed.(theSeverityTextfilter is dropped because traces lack that column).ServiceNamefilter group and confirm the URL'sfilters=param still contains theServiceNamefilter.ServiceNamefilter is still compatible) and the URL retains the filter.References