rill icon indicating copy to clipboard operation
rill copied to clipboard

[APP-538] feat: canvas default filter support

Open briangregoryholmes opened this issue 1 month ago • 6 comments

This PR adds support for specifying default time, dimension and measure filters to apply when loading a Canvas dashboard for the first time. When using the builder surface in Rill Developer, the workspace provides a quick way to save the currently selected filters as default, which would propagate to the YAML as metrics SQL statements:

type: canvas
defaults:
  time_range: 6h as of latest/m+1m
  filters:
    AdBids_metrics: (publisher IN ('Facebook', 'Google')) AND (publisher IN (SELECT publisher
      FROM metrics_view HAVING total_records > 200))

To support the use of multiple metrics views across a single canvas, these metrics SQL filters are keyed with the name of the underlying metrics view.

  • Filters are handled on a per-metrics-view basis via instances of the new FilterState class
  • Filter consolidation and rendering across multiple FilterState classes happens through the new FilterManager
  • URL filters are keyed with a string that takes the form f.{{metrics_view_name}}
  • Each FilterState class has actions on it that allow for filter state manipulation
  • The FilterManager class has proxies for these functions to call them across multiple FilterState classes
  • Consolidation of the namespace across multiple metrics views currently assumes that all dimensions/measures with equivalent identifiers are the same
  • Canvas initialization now happens through the CanvasProvider component no matter where a Canvas is rendered
  • When adding a filter for a measure/dimension that exists across multiple metrics views, it is added to each FilterState class (and to the URL) independently, though the actual URL navigation is batched for each user action
  • Canvas loading, url param syncing and redirecting happens through the onUrlChange function as well as updated getters and setters in canvas/state-managers.ts
  • Removes use of RuntimeProvider for embeds, sets the runtime in the topmost layout load function instead
  • A new "save defaults" button is added to update the YAML defaults with the current filter state
  • Refactors canvas time state management to use TimeManager and TimeState classes

Outstanding items:

  • [x] Update designs (and implementation) to reflect "pin" behavior rather than lock @Di7design
  • [x] Remove old Filter class if possible
  • [x] Ensure changes did not break Explore
  • [x] Ensure prior filter strings (without scoped metrics view) work as intended
  • [x] Fix tests
  • [x] Abstract UI filter parsing method and apply to defaults
  • [x] Fix issue with measure filter pills not updating on first apply
  • [x] Update CanvasFilterButton to display labels rather than unique ids
  • [x] Match sidebar design to Figma
  • [x] Add pinning capability to measures
  • [x] Resolve issue where unpinning does not immediately reflect in pill
  • [x] Add "saved as default" state to button when viewing defaults
  • [x] Resolve issue where filter dropdown reopens after applying selections
  • [ ] Bring back measure-specific dimension lists

Checklist:

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

[!NOTE] Adds per-metrics-view canvas filtering with pinning and saved defaults, updates URL/schema and parser, refactors initialization/embeds, and introduces new UI to manage and display default/pinned filters.

  • Canvas filtering overhaul:
    • Introduces per-metrics-view filtering via FilterManager and MetricsViewFilter with consolidated UI/state.
    • Adds default filters and pinning (save/clear defaults; pinned chips), new inspector tabs, and read-only chips.
    • Updates URL schema to scoped filters (f.{metrics_view}) and batching of navigation.
  • Protocol & API:
    • Extends CanvasSpec with pinned_filters; CanvasPreset with filter_expr; updates Swagger/TS/Go protobufs.
    • Parser reads filters.pinned and defaults.filters from YAML.
  • Runtime/initialization:
    • New handleCanvasStoreInitialization and onUrlChange; removes RuntimeProvider for embeds; sets runtime in layout.
  • UI components:
    • New SaveDefaultsButton, default filters display; enhanced Chip (pin/gray), filter buttons/chips; time/comparison tweaks.
  • Embeds/routes:
    • Canvas embed and app routes refactored to initialize/store canvas and sync URL.
  • Cleanup & tests:
    • Removes old Filters class; updates bookmark handling and tests to new comparison/filters.

Written by Cursor Bugbot for commit defa8bf68d2e389b012d9127dd20306612789ee5. This will update automatically on new commits. Configure here.

briangregoryholmes avatar Nov 25 '25 04:11 briangregoryholmes

See Figma here. Screenshot 2025-11-26 at 9 48 23 AM

Di7design avatar Nov 26 '25 17:11 Di7design

@briangregoryholmes : Is this ready for review ? Still on track for the release next week?

nishantmonu51 avatar Nov 28 '25 20:11 nishantmonu51

@briangregoryholmes Some issues with the latest build:

https://www.loom.com/share/47fd9eba4acc4cf9babd3c314e3d1663

ericokuma avatar Dec 10 '25 07:12 ericokuma

@ericokuma Should be fixed as soon as this lands: https://github.com/rilldata/rill/pull/8472

briangregoryholmes avatar Dec 10 '25 11:12 briangregoryholmes

UX looks good to me

@Di7design

This branch is functional, but we might need further iteration.

Di7design avatar Dec 10 '25 21:12 Di7design

Looks good @briangregoryholmes

ericokuma avatar Dec 11 '25 00:12 ericokuma

Great job everyone!

ericokuma avatar Dec 11 '25 21:12 ericokuma