Skip to content

feat: update facet selectors based on current selection - #182

Open
fuchsi-huber wants to merge 3 commits into
mainfrom
feat/facet-selectors
Open

fuchsi-huber wants to merge 3 commits into
mainfrom
feat/facet-selectors

Conversation

@fuchsi-huber

@fuchsi-huber fuchsi-huber commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Filter menus on the diagnostics catalog, figure gallery and explorer now only offer values that still return results given the filters already applied, and figure-gallery and explorer filter choices are kept in the URL so the view can be shared as a link. The figure gallery can also filter by the dimensions each figure is tagged with, such as the region and variable of the Regional Historical Timeseries plots.

Summary by CodeRabbit

  • New Features

    • Filter menus now show option counts and prioritise choices that return results with the other active filters applied.
    • Figure galleries support text and dimension-based filters, including an “Unknown” option for missing dimensions. Filter choices can persist in the URL.
    • Explorer filters now cascade based on earlier selections and persist in the URL.
    • Execution results now include their dimensions.
    • Scalar and series filters accept multiple values, matching any selected value. Repeated query parameters support filtering values that contain commas.
  • Bug Fixes

    • Changing filters clears invalid selections and resets gallery pagination when the filter changes.
    • Selected options remain removable even when unavailable under the current filters.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3eb49cf0-c76a-42c1-9b01-cdfeb3068976
Walkthrough

The API and frontend now support repeated dimension filters, counted facet options, and figure filtering by output dimensions. Figure gallery and explorer filters can persist in URL search parameters.

Changes: Faceted filtering and URL state

Layer / File(s) Summary
API dimensions and multi-value filters
backend/openapi.json, backend/src/ref_backend/core/reader_values.py, backend/src/ref_backend/models/executions.py, frontend/src/client/types.gen.ts, backend/tests/*, changelog/182.fix.md
Execution outputs include tagged dimensions. The backend parser accepts repeated dimension parameters, removes duplicate values, and returns multiple distinct values as a tuple.
Shared facet and URL filter primitives
frontend/src/lib/facetedFilter*, frontend/src/lib/metricFilters*, frontend/src/lib/valuesSearch*, frontend/hooks/useFacetedFilter.ts, frontend/src/hooks/useMetricValues.ts, frontend/src/lib/failures*, changelog/182.improvement.md
Shared helpers match facet selections, count available values, preserve unavailable selections, and encode comma-containing values. URL helpers parse and write namespaced filters and convert facet parameters for API queries.
Counted diagnostic filter options
frontend/src/lib/diagnosticFilters*, frontend/src/components/diagnostics/diagnosticsFilter*, frontend/src/components/app/checkboxCommandList*, frontend/src/routes/_app/diagnostics.index.tsx
Diagnostic filter options now include counts based on the active filters and search. The filter UI displays counts and retains selected values that are no longer available.
Figure gallery dimension facets
frontend/src/components/diagnostics/figureGallery*, frontend/src/components/diagnostics/figureGalleryData*, frontend/src/components/diagnostics/selectorFilterPanel*, frontend/src/routes/_app/diagnostics.$providerSlug.$diagnosticSlug/figures.tsx
The gallery filters figures by tagged dimensions and group selectors. Missing values appear as “Unknown”. Text filtering is debounced, and controlled filter state is supported.
Explorer URL filter cascade
frontend/src/components/explorer/*, frontend/src/routes/_app/diagnostics.$providerSlug.$diagnosticSlug/explorer.tsx, frontend/src/routes/_app/explorer/themes.tsx, frontend/src/components/explorer/thematicContent.tsx
Explorer cards receive unique URL namespaces. Their controls resolve sequentially using facet options, and filter selections persist in route search parameters. Theme changes remove card- search parameters.
Filter selection controls
frontend/src/components/datasets/filterAddPopover*, frontend/src/components/execution/values/filterControls.test.tsx
The dataset filter popover validates the selected facet and value before enabling Add, then clears the value after adding or changing facets. Execution filter tests cover availability of additional facets.

Sequence Diagram(s)

sequenceDiagram
  participant ExplorerThemeLayout
  participant ExplorerCardContent
  participant useFilterControls
  participant useFacetedFilter
  participant QueryClient
  ExplorerThemeLayout->>ExplorerCardContent: Passes each card content search namespace
  ExplorerCardContent->>useFilterControls: Passes the namespace to metric-value controls
  useFilterControls->>useFacetedFilter: Reads and updates namespaced URL selections
  useFilterControls->>QueryClient: Fetches facets for resolved preceding control values
  QueryClient-->>useFilterControls: Returns facet options
Loading

Change: Feature

Merge Risk: Low · previous review b4b2a

Filter and facet changes work as described. In the figure gallery, switching filters and then going back can land on an old page instead of the first page. This is a minor annoyance that does not block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names a feature that is present in the changeset. The raw summary shows facet selectors that offer only values with results under the current filters, computed through the new facet helpers …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names a feature that is present in the changeset. The raw summary shows facet selectors that offer only values with results under the current filters, computed through the new facet helpers in the frontend and the diagnostics filter options. The title is short and specific enough to convey the primary change, though it does not mention the URL persistence, dimension filtering, or the API changes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Nitpick comments: 1

backend/tests/test_api/test_routes/test_diagnostics.py: 1

600-601: Trivial · Maintainability & Code Quality · Quick win

Make the union test reject ignored filters.

If the route ignores the dimension filter, all three requests return the same non-empty ID set. Both assertions then pass.

Assert that first_ids and second_ids are disjoint. Also check that the combined response excludes records with a third dimension value.

Based on learnings, filter tests must check that similar-but-distinct records remain excluded.

Source: Learnings

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3722d687-6ce6-421e-94d8-4f1d50e7c59f
Commits

Reviewing files that changed from the base of the PR and between 13b31fe and b4b2af2.

Files selected for processing: 51

  • backend/openapi.json
  • backend/src/ref_backend/core/reader_values.py
  • backend/src/ref_backend/models/executions.py
  • backend/tests/test_api/test_routes/test_diagnostics.py
  • backend/tests/test_api/test_routes/test_results.py
  • backend/tests/test_core/test_reader_values.py
  • changelog/182.fix.md
  • changelog/182.improvement.md
  • frontend/src/client/types.gen.ts
  • frontend/src/components/app/checkboxCommandList.test.tsx
  • frontend/src/components/app/checkboxCommandList.tsx
  • frontend/src/components/datasets/filterAddPopover.test.tsx
  • frontend/src/components/datasets/filterAddPopover.tsx
  • frontend/src/components/diagnostics/diagnosticsFilter.test.tsx
  • frontend/src/components/diagnostics/diagnosticsFilter.tsx
  • frontend/src/components/diagnostics/figureGallery.test.tsx
  • frontend/src/components/diagnostics/figureGallery.tsx
  • frontend/src/components/diagnostics/figureGalleryData.test.ts
  • frontend/src/components/diagnostics/figureGalleryData.ts
  • frontend/src/components/diagnostics/selectorFilterPanel.test.ts
  • frontend/src/components/diagnostics/selectorFilterPanel.tsx
  • frontend/src/components/execution/values/filterControls.test.tsx
  • frontend/src/components/explorer/content/ensembleChartContent.tsx
  • frontend/src/components/explorer/content/figureGalleryContent.tsx
  • frontend/src/components/explorer/content/filterControls.test.ts
  • frontend/src/components/explorer/content/filterControls.tsx
  • frontend/src/components/explorer/content/seriesChartContent.tsx
  • frontend/src/components/explorer/content/taylorDiagramContentWrapper.tsx
  • frontend/src/components/explorer/content/useExplorerMetricValues.ts
  • frontend/src/components/explorer/explorerCardContent.tsx
  • frontend/src/components/explorer/explorerCardGroup.tsx
  • frontend/src/components/explorer/explorerThemeLayout.tsx
  • frontend/src/components/explorer/thematicContent.tsx
  • frontend/src/hooks/useFacetedFilter.ts
  • frontend/src/hooks/useMetricValues.ts
  • frontend/src/lib/diagnosticFilters.test.ts
  • frontend/src/lib/diagnosticFilters.ts
  • frontend/src/lib/facetedFilter.test.ts
  • frontend/src/lib/facetedFilter.ts
  • frontend/src/lib/facetedFilterSearch.test.ts
  • frontend/src/lib/facetedFilterSearch.ts
  • frontend/src/lib/failures.test.ts
  • frontend/src/lib/failures.ts
  • frontend/src/lib/metricFilters.test.ts
  • frontend/src/lib/metricFilters.ts
  • frontend/src/lib/valuesSearch.test.ts
  • frontend/src/lib/valuesSearch.ts
  • frontend/src/routes/_app/diagnostics.$providerSlug.$diagnosticSlug/explorer.tsx
  • frontend/src/routes/_app/diagnostics.$providerSlug.$diagnosticSlug/figures.tsx
  • frontend/src/routes/_app/diagnostics.index.tsx
  • frontend/src/routes/_app/explorer/themes.tsx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant