Skip to content

feat(explore): Add search filters to equation _if aggregates - #122912

Open
wmak wants to merge 12 commits into
masterfrom
wmak/feat/explore-equation-conditional-filters
Open

feat(explore): Add search filters to equation _if aggregates#122912
wmak wants to merge 12 commits into
masterfrom
wmak/feat/explore-equation-conditional-filters

Conversation

@wmak

@wmak wmak commented Aug 27, 2026

Copy link
Copy Markdown
Member
  • Adds conditional aggregates to the equation builder in explore
  • Changes are behind the same feature flag as the conditionals on functions

Wire EAP conditional aggregates into the Explore equation builder with search-style filter autocomplete for the first argument (avg_if(`span.op:db`,span.duration)).

Co-authored-by: Cursor <cursoragent@cursor.com>
@wmak
wmak requested review from a team as code owners August 27, 2026 19:23
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-kmayaxx8d.sentry.dev

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

Metric Before After Delta
Coverage 95.46% 95.47% 🟢 +0.01%
Typed 138,875 139,197 🟢 +322
Untyped 6,598 6,607 🔴 +9
🔍 9 new type safety issues introduced

any-typed symbols (3 new)

File Line Detail
static/app/components/arithmeticBuilder/token/useFunctionArgumentInput.tsx 171 selectionStart (var)
static/app/components/arithmeticBuilder/token/useFunctionArgumentInput.tsx 172 selectionEnd (var)
static/app/components/arithmeticBuilder/token/useFunctionArgumentInput.tsx 173 valueLength (var)

Non-null assertions (!) (5 new)

File Line Detail
static/app/components/arithmeticBuilder/conditionalFilter/conditionalFilter.ts 109 value[i]!
static/app/components/arithmeticBuilder/conditionalFilter/conditionalFilter.ts 146 value[index]!
static/app/components/arithmeticBuilder/conditionalFilter/conditionalFilter.ts 398 completedValue!
static/app/components/arithmeticBuilder/conditionalFilter/conditionalFilter.ts 398 spaces!
static/app/utils/fields/index.ts 3972 attributeTexts[0]!

Type assertions (as) (1 new)

File Line Detail
static/app/views/explore/utils/conditionalAggregate.tsx 174 as AggregationKeyaggregateName as AggregationKey

This is informational only and does not block the PR.

Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/conditionalFilter.ts Outdated
Comment thread static/app/utils/fields/index.ts
Flush pending argument edits when leaving the args grid, bound compound-filter clauses at boolean operators, and keep Discover-style avg_if/count_if editable when the EAP flag is on.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated
Comment thread static/app/utils/fields/index.ts
wmak and others added 3 commits August 28, 2026 12:36
…plete

Master removed sentry/utils/useDebouncedValue; switch the new autocomplete hook to @tanstack/react-pacer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clear emptied filters on blur, keep EAP-only _if definitions when args lack backticks, and place the caret after key select once React commits the value.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread static/app/components/arithmeticBuilder/conditionalFilterAutocomplete.tsx Outdated
Comment thread static/app/views/explore/hooks/useExploreEquationBuilderConfig.ts
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated

@narsaynorath narsaynorath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still reviewing, but leaving two possibly larger comments here to think about before I get to the other files

Comment thread static/app/views/explore/hooks/useExploreEquationBuilderConfig.ts Outdated
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/token/grid.tsx
Drop unused exports, cast combobox selection in tests, avoid stale value suggestions across keys, include boolean filter keys, and allow Enter to clear an _if filter.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated

@narsaynorath narsaynorath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My last comments on the first run-through of the PR 👍

The changes are a little complicated but I think due to the manual manipulation of the text fields, the editor code was always kind of tricky to make changes with since there are so many states.

One other thing I didn't comment on is that it seems like there isn't really support for key:[value1, value2] autocomplete. Maybe we can consider that as an improvement later on?

Another thing is, it did feel kind of cramped editing the filter in this case. I don't know if we'd want to consider expanding out the equation builder like we do when you select the conditional filter on an aggregation (introduced in your last PR) but I feel like the width just isn't enough to use comfortably

Comment thread static/app/components/arithmeticBuilder/token/styles.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/token/index.spec.tsx
Comment thread static/app/components/arithmeticBuilder/token/index.spec.tsx
Comment thread static/app/components/arithmeticBuilder/conditionalFilter.ts Outdated
Comment thread static/app/components/arithmeticBuilder/conditionalFilter.ts Outdated
Function tokens are keyed by position, so deleting one reused the next function's draft arguments. Remount the arguments grid on token identity and extract filter/argument input into dedicated modules. Expand the equation builder while focused like the series filter bar.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread static/app/views/explore/hooks/useExploreEquationBuilderConfig.ts
Clear skipBlurFlush on the next focus so later edits still commit, and only delete a function token when the caret is collapsed. Drop unused re-exports and align getFieldDefinition types.

Co-authored-by: Cursor <cursoragent@cursor.com>

@narsaynorath narsaynorath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some final comments. I also wanted to suggest maybe it's possible to add another directory to colocate more of the conditional function argument code so the files have a clearer relationship. Stuff like useFunctionArgumentInput.tsx, conditionalFilterInput.tsx, etc

Comment thread static/app/components/arithmeticBuilder/token/useFunctionArgumentInput.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/token/useFunctionArgumentInput.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated
Comment thread static/app/components/arithmeticBuilder/token/function.tsx Outdated
@narsaynorath

Copy link
Copy Markdown
Member

One more thing I'd like to fix in this PR if possible, the equation input height has changed and it's inconsistent with the other input fields around it, can we fix it so it goes back to the same height?

Screenshot 2026-09-02 at 12 22 05 PM

Keep filter suggestions working inside grouping parentheses, dismiss the
expandable equation on Enter unless a suggestion is highlighted, colocate
conditional-filter helpers, and align equation field height with the
aggregate filter.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread static/app/components/arithmeticBuilder/conditionalFilter/conditionalFilter.ts Outdated
…arens

Preserve trailing grouping parentheses when replacing the next filter key,
and let ComboBox commit on Enter before the expandable equation bar collapses.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore selection after suggestion re-renders and wire native keyup so
moving the caret into a filter key reliably shows key suggestions.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b621123. Configure here.

Keep spaces inside [a, b] in value mode so autocomplete does not split the
list, and skip caret realignment when the filter input has a text range.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants