Skip to content

refac: unified expression filter component across explore, canvas, alerts and reports - #9746

Open
AdityaHegde wants to merge 34 commits into
mainfrom
refac/unified-filter-component
Open

refac: unified expression filter component across explore, canvas, alerts and reports#9746
AdityaHegde wants to merge 34 commits into
mainfrom
refac/unified-filter-component

Conversation

@AdityaHegde

@AdityaHegde AdityaHegde commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

We have 3 different filter implementation across explore, canvas, alerts and reports with action code like toggling dimension value duplicated. This PR unifies expression filters components.

The goal of this refactor was also to ensure the state matches UI controls 1-1. Earlier we have V1Expression that doesnt map 1-1, especially with Select vs In-List modes.

  1. ExpressionFilter.svelte acts as the unified filter component that takes a ExpressionFilterManager.
  2. ExpressionFilterManager contains MetricsViewFilterManager per configured metrics views. It also has the full list of DimensionFilterManager/MeasureFilterManager across metrics views, deduped by name. Takes all the filters from MetricsViewFilterManager and creates a sorted list for default filters bar, required first, followed by pinned, followed by dimension and finally measure filters.
  3. JoinerFilterManager is a wrapper per joiner. For existing filter bar it is always an AND joiner. Future PR will support more advanced editing like OR filter and nested AND/OR. Ensures pinned/required filters have an entry. Also handles adding new dimension/measure filter.
  4. DimensionFilterManager encapsulates all actions for a dimension filter. This code was spread out in different places. Along with DimensionFilter.svelte it handles everything for a dimension filter.
  5. Similarly, MeasureFilterManager encapsulates all actions for a measure filter. Along with MeasureFilter.svelte it handles everything for a measure filter.
  6. All of this depends on MetricsViewsProvider. All dimension and measure selectors are come from here.
  7. It also depends on YAMLConfigProvider that provide config that is yaml only and not maintained as a state while rendering dashboard. Currently this has required/pinned filters.
  8. Adds a DashboardConfigProvider for quickly building ExploreDashboardConfigProvider or CanvasDashboardConfigProvider.

For explore,

  1. Adds ExpressionFilterManager to StateManagers.
  2. Replaces the old filter component with the new ExpressionFilter.svelte passing it the ExpressionFilterManager from StateManagers.
  3. Replaces actions/selectors references in leaderbord, dimension table and other places to using ExpressionFilterManager directly.

For canvas,

  1. Adds ExpressionFilterManager to CanvasEntity.
  2. Replaces the old actions with calls to this ExpressionFilterManager.
  3. Still used the old timeAndFilterStore but uses data from parent's ExpressionFilterManager for expression related fields.

There will be a follow up to move time controls as well.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@nishantmonu51 nishantmonu51 added Type:Improvement Area:Dashboard Size:XL Very large change: 2,000+ lines labels Aug 4, 2026
@AdityaHegde AdityaHegde changed the title refac: unified filter component across explore, canvas, alerts and reports refac: unified expression filter component across explore, canvas, alerts and reports Aug 6, 2026
@AdityaHegde
AdityaHegde force-pushed the refac/unified-filter-component branch from fb87403 to 0e9eb72 Compare August 10, 2026 14:20
@AdityaHegde
AdityaHegde force-pushed the refac/unified-filter-component branch from 21c97f9 to cc9c8e9 Compare August 11, 2026 12:57
@AdityaHegde
AdityaHegde marked this pull request as ready for review August 19, 2026 06:18

Copilot AI 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.

Pull request overview

Unifies filter state, UI, persistence, exports, alerts, reports, and canvas interactions around ExpressionFilterManager.

Changes:

  • Introduces shared dimension/measure filter managers and providers.
  • Migrates explore, canvas, alerts, reports, bookmarks, and public URLs.
  • Updates serialization, query construction, tests, and read-only filter displays.

Reviewed changes

Copilot reviewed 149 out of 163 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
web-local/tests/explores/explores.spec.ts Adjusts explore E2E timing.
web-local/tests/canvas/filters.spec.ts Cleans canvas filter test.
web-common/src/lib/test/mock-animations.ts Mocks Web Animations.
web-common/src/lib/svelte-query/reactive-queries.svelte.ts Adds reactive multi-query helper.
web-common/src/lib/i18n/messages/es.json Adds required-filter copy.
web-common/src/lib/i18n/messages/en.json Adds required-filter copy.
web-common/src/lib/arrayUtils.ts Generalizes collection helpers.
web-common/src/features/scheduled-reports/utils.ts Migrates report filters.
web-common/src/features/scheduled-reports/ScheduledReportDialog.svelte Uses unified filter manager.
web-common/src/features/scheduled-reports/BaseScheduledReportForm.svelte Passes unified filter context.
web-common/src/features/metrics-views/providers/test/RuntimeContextHarness.svelte Adds provider test harness.
web-common/src/features/metrics-views/providers/test/metrics-views-test-utils.svelte.ts Adds provider test utilities.
web-common/src/features/metrics-views/providers/MetricsViewsProvider.spec.ts Tests metrics-view aggregation.
web-common/src/features/exports/pdf/CanvasPdfExportHeader.svelte Uses unified read-only filters.
web-common/src/features/exports/export-filters.ts Exports unified expressions.
web-common/src/features/exports/export-filters.spec.ts Updates export tests.
web-common/src/features/explores/explore-link/explore-state-transformer.ts Keeps filters collapsed.
web-common/src/features/explore-mappers/get-dashboard-from-aggregation-request.ts Maps measure filters to subqueries.
web-common/src/features/dashboards/workspace/Dashboard.svelte Connects dashboard to filter manager.
web-common/src/features/dashboards/url-state/test/url-state-test-utils.ts Adds filter-manager URL helpers.
web-common/src/features/dashboards/url-state/convertURLSearchParamsToExploreState.spec.ts Updates URL-state tests.
web-common/src/features/dashboards/url-state/convertPresetToExploreState.ts Preserves unified expressions.
web-common/src/features/dashboards/url-state/convert-partial-explore-state-to-url-params.ts Serializes unified expressions.
web-common/src/features/dashboards/time-series/totals-data-store.ts Queries with unified filters.
web-common/src/features/dashboards/time-series/timeseries-data-store.ts Queries with unified filters.
web-common/src/features/dashboards/time-series/ScreenshotContainer.svelte Uses read-only expression filters.
web-common/src/features/dashboards/time-series/multiple-dimension-queries.ts Preserves measure subqueries.
web-common/src/features/dashboards/time-dimension-details/TDDHeader.svelte Migrates filter actions.
web-common/src/features/dashboards/time-dimension-details/tdd-export.ts Exports unified filters.
web-common/src/features/dashboards/time-controls/time-control-store.ts Adds dimension-only expressions.
web-common/src/features/dashboards/time-controls/time-control-store.spec.ts Cleans test managers.
web-common/src/features/dashboards/stores/test-data/helpers.ts Initializes managers in context.
web-common/src/features/dashboards/stores/filter-utils.ts Adds expression utilities.
web-common/src/features/dashboards/stores/dashboard-stores.ts Mirrors managed filters into state.
web-common/src/features/dashboards/stores/correct-explore-state.spec.ts Removes legacy filter assertions.
web-common/src/features/dashboards/stores/AdvancedMeasureCorrector.ts Delegates filter correction.
web-common/src/features/dashboards/stores/AdvancedMeasureCorrector.spec.ts Updates correction tests.
web-common/src/features/dashboards/state-managers/StateManagersProvider.svelte Cleans up state managers.
web-common/src/features/dashboards/state-managers/state-managers.ts Adds expression filter manager.
web-common/src/features/dashboards/state-managers/selectors/measures.ts Extracts measure filtering helper.
web-common/src/features/dashboards/state-managers/selectors/measure-filters.ts Retires legacy selectors.
web-common/src/features/dashboards/state-managers/selectors/dashboard-queries.ts Reads measures from expressions.
web-common/src/features/dashboards/state-managers/most-recent-explore-state.spec.ts Updates persisted-state tests.
web-common/src/features/dashboards/state-managers/loaders/test/PageMockForExploreTests.ts Mocks form actions.
web-common/src/features/dashboards/state-managers/loaders/test/DashboardStateManagerTest.svelte Adds manager provider context.
web-common/src/features/dashboards/state-managers/loaders/explore-web-view-store.spec.ts Updates web-view tests.
web-common/src/features/dashboards/state-managers/loaders/DashboardStateSync.ts Synchronizes managed filters.
web-common/src/features/dashboards/state-managers/loaders/DashboardStateManager.svelte Supplies filter manager to sync.
web-common/src/features/dashboards/state-managers/loaders/DashboardStateManager.spec.ts Updates imports.
web-common/src/features/dashboards/state-managers/actions/measure-filters.ts Retires legacy actions.
web-common/src/features/dashboards/state-managers/actions/filters.ts Retires legacy actions.
web-common/src/features/dashboards/selectors.ts Handles unified subquery filters.
web-common/src/features/dashboards/rows-viewer/RowsViewerAccordion.svelte Uses unified expressions.
web-common/src/features/dashboards/providers/YAMLConfigProvider.svelte.ts Provides YAML filter configuration.
web-common/src/features/dashboards/providers/DashboardConfigProvider.svelte.ts Builds dashboard-specific providers.
web-common/src/features/dashboards/proto-state/toProto.ts Serializes filter subqueries.
web-common/src/features/dashboards/proto-state/sparse-proto.spec.ts Updates proto tests.
web-common/src/features/dashboards/proto-state/fromProto.ts Restores unified subqueries.
web-common/src/features/dashboards/pivot/pivot-export.ts Exports unified filters.
web-common/src/features/dashboards/pivot/pivot-data-config.ts Configures unified pivot filters.
web-common/src/features/dashboards/leaderboard/LeaderboardDisplay.svelte Migrates leaderboard actions.
web-common/src/features/dashboards/leaderboard/Leaderboard.svelte Queries unified expressions.
web-common/src/features/dashboards/filters/ExpressionFilterManager.svelte.ts Centralizes expression filter state.
web-common/src/features/dashboards/filters/VerticalExpressionFilters.svelte Adds vertical filter editor.
web-common/src/features/dashboards/filters/utils.ts Detects missing required filters.
web-common/src/features/dashboards/filters/test/render-filter-component.ts Removes legacy test helper.
web-common/src/features/dashboards/filters/test/ExpressionFiltersTest.svelte Adds unified filter harness.
web-common/src/features/dashboards/filters/ReadonlyExpressionFilters.svelte Adds shared read-only filters.
web-common/src/features/dashboards/filters/MissingRequiredFiltersMessage.svelte Displays required-filter warnings.
web-common/src/features/dashboards/filters/measure-filters/ReadonlyMeasureFilter.svelte Adds read-only measure chip.
web-common/src/features/dashboards/filters/measure-filters/MeasureFilterReadOnlyChip.svelte Removes legacy measure chip.
web-common/src/features/dashboards/filters/measure-filters/MeasureFilterManager.svelte.ts Encapsulates measure filter state.
web-common/src/features/dashboards/filters/measure-filters/MeasureFilterForm.svelte Removes duplicate popover ID.
web-common/src/features/dashboards/filters/measure-filters/measure-filter-utils.ts Removes split/merge utilities.
web-common/src/features/dashboards/filters/FilterChipsReadOnly.svelte Removes legacy read-only filters.
web-common/src/features/dashboards/filters/FilterButton.svelte Removes legacy add button.
web-common/src/features/dashboards/filters/filter-events.ts Defines filter events.
web-common/src/features/dashboards/filters/ExploreFilterChipsReadOnly.svelte Removes explore-specific chips.
web-common/src/features/dashboards/filters/dimension-filters/ReadonlyDimensionFilter.svelte Adds read-only dimension chip.
web-common/src/features/dashboards/filters/dimension-filters/DimensionFilterReadOnlyChip.svelte Removes legacy dimension chip.
web-common/src/features/dashboards/filters/dimension-filters/DimensionFilterFooter.svelte Simplifies exclude callback.
web-common/src/features/dashboards/filters/dimension-filters/dimension-filter-values.ts Queries unified filters.
web-common/src/features/dashboards/filters/CanvasFilterChipsReadOnly.svelte Removes canvas-specific chips.
web-common/src/features/dashboards/filters/AddExpressionFilterButton.svelte Uses shared filter metadata.
web-common/src/features/dashboards/dimension-table/DimensionHeader.svelte Migrates dimension actions.
web-common/src/features/dashboards/dimension-table/DimensionDisplay.svelte Migrates selection and queries.
web-common/src/features/dashboards/dimension-table/dimension-table-utils.ts Preserves measure subqueries.
web-common/src/features/dashboards/dimension-table/dimension-table-export.ts Exports unified filters.
web-common/src/features/dashboards/dimension-search/GlobalDimensionSearchResults.svelte Migrates search selection.
web-common/src/features/dashboards/dashboard-fetch-mocks.ts Mocks resource listings.
web-common/src/features/dashboards/big-number/MeasuresContainer.svelte Receives unified filters.
web-common/src/features/dashboards/aggregation-request-utils.ts Removes legacy filter builder.
web-common/src/features/canvas/LocalFiltersHeader.svelte Displays unified local filters.
web-common/src/features/canvas/inspector/filters/FiltersMapper.svelte Passes local filter managers.
web-common/src/features/canvas/inspector/DefaultFilterDisplay.svelte Displays managed defaults.
web-common/src/features/canvas/filters/canvas-filter-expressions.ts Extracts managed canvas filters.
web-common/src/features/canvas/components/SaveDefaultsButton.svelte Compares default URL state.
web-common/src/features/canvas/components/pivot/pivot-test-data.ts Adds pivot test metadata.
web-common/src/features/canvas/components/pivot/pivot-click-to-filter.ts Migrates pivot interactions.
web-common/src/features/canvas/components/pivot/CanvasPivotRenderer.svelte Connects pivot filter manager.
web-common/src/features/canvas/components/markdown/util.ts Supplies unified template filters.
web-common/src/features/canvas/components/kpi-grid/KPIGrid.svelte Guards unavailable filter state.
web-common/src/features/canvas/components/charts/variants/ComboChart.ts Preserves unified link filters.
web-common/src/features/canvas/components/charts/custom-chart/index.ts Creates local expression filters.
web-common/src/features/canvas/components/charts/BaseChart.ts Preserves unified chart filters.
web-common/src/features/canvas/chat-context.ts Supplies canvas filters to chat.
web-common/src/features/canvas/CanvasBuilder.svelte Initializes canvas width.
web-common/src/features/alerts/form-utils.ts Builds alert queries from expressions.
web-common/src/features/alerts/data-tab/DataPreview.svelte Uses managed alert filters.
web-common/src/features/alerts/data-tab/AlertDialogDataTab.svelte Passes unified filter context.
web-common/src/features/alerts/criteria-tab/AlertPreview.svelte Uses managed criteria filters.
web-common/src/features/alerts/criteria-tab/AlertDialogCriteriaTab.svelte Migrates criteria filter type.
web-common/src/features/alerts/create-alert-utils.ts Initializes alert filter manager.
web-common/src/features/alerts/AlertPreviewTable.svelte Updates sizing call.
web-common/src/features/alerts/AlertForm.svelte Manages filter lifecycle.
web-common/src/features/alerts/alert-preview-data.ts Queries alert expressions.
web-common/src/components/virtualized-table/sections/TableCells.svelte Guards stale virtual items.
web-common/src/components/virtualized-table/sections/ColumnHeaders.svelte Guards stale headers.
web-admin/tests/bookmarks.spec.ts Re-enables bookmark E2E tests.
web-admin/src/features/public-urls/ExploreFiltersSection.svelte Removes explore-specific section.
web-admin/src/features/public-urls/CanvasFiltersSection.svelte Removes canvas-specific section.
web-admin/src/features/public-urls/canvas-form-utils.ts Removes legacy canvas utilities.
web-admin/src/features/projects/header/ProjectHeader.svelte Simplifies bookmark props.
web-admin/src/features/dashboards/share/ShareDashboardPopover.svelte Keys public URL forms by resource.
web-admin/src/features/dashboards/listing/DashboardsTable.svelte Uses default deduplication.
web-admin/src/features/bookmarks/ExploreBookmarks.svelte Removes metrics-view prop.
web-admin/src/features/bookmarks/CanvasBookmarks.svelte Removes metrics-view lookup.
web-admin/src/features/bookmarks/Bookmarks.svelte Keys dialogs by resource.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread web-common/src/lib/arrayUtils.ts Outdated
Comment thread web-common/src/features/canvas/chat-context.ts Outdated
Comment thread web-common/src/features/canvas/components/charts/custom-chart/index.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area:Dashboard Size:XL Very large change: 2,000+ lines Type:Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants