Skip to content

Introduce required/mandatory filters#9493

Open
nishantmonu51 wants to merge 3 commits into
mainfrom
Nishant-Bangarwa/required-filters
Open

Introduce required/mandatory filters#9493
nishantmonu51 wants to merge 3 commits into
mainfrom
Nishant-Bangarwa/required-filters

Conversation

@nishantmonu51
Copy link
Copy Markdown
Collaborator

There is no way to mark a filter as mandatory: a canvas always renders, even if a critical filter (e.g. region, customer_id) has been left empty. Mandatory/Required ensures that a user always filters on one or more dimension values.

This PR adds support for declaring required filters on canvas dashboards, alongside the existing pinned filters.

  • New filters.required YAML field on canvas dashboards
  • Required filters are implicitly pinned and cannot be removed from the filter row.
  • If any required filter has no value (from defaults.filters or the user), the canvas body is replaced with an inline panel listing the missing filters; the filter row stays interactive so the user can set values.
  • Filter pills for unsatisfied required filters render in a red error state with a tooltip explaining the requirement.
  • Enforcement applies in view, embed, and editor modes — authors see the same blocked state their viewers will see.
  • runtime/ai/instructions/data/resources/canvas.md updated so the analyst and developer agents know about the new field.
Screenshot 2026-05-23 at 2 52 02 AM

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 requested a review from AdityaHegde May 22, 2026 21:26
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@AdityaHegde AdityaHegde left a comment

Choose a reason for hiding this comment

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

Is a UI toggle for required filter a future thing? We have one for pin in the filter dropdown.

r.CanvasSpec.Rows = rows
r.CanvasSpec.SecurityRules = rules
r.CanvasSpec.PinnedFilters = tmp.Filters.Pinned
r.CanvasSpec.RequiredFilters = tmp.Filters.Required
Copy link
Copy Markdown
Collaborator

@AdityaHegde AdityaHegde May 25, 2026

Choose a reason for hiding this comment

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

We should have validation for this to ensure it is defined in metrics view's measure/dimensions. Since there is no no-code way to set it a validation will help with issues.

{#if missingRequired}
This filter is required. Select a value to load the dashboard.
{:else}
Click to edit the the filters in this dimension
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: remove doubled the

);
// Required filters are implicitly pinned at runtime; persist them only under
// `filters.required` to avoid duplicating them in `filters.pinned`.
const genericPinnedKeys = Array.from(pinnedFilters)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should do this dedupe render time instead. When we add a toggle for required switching it on and off will removed the pinned filter.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants