Skip to content

fix(app): apply the clicked series' WHERE to a chart's Search action - #3174

Draft
MikeShi42 wants to merge 4 commits into
mainfrom
cursor/hdx-5441-chart-search-series-where-9e86
Draft

MikeShi42 wants to merge 4 commits into
mainfrom
cursor/hdx-5441-chart-search-series-where-9e86

Conversation

@MikeShi42

@MikeShi42 MikeShi42 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

On a chart with several series, each series carries its own WHERE. Clicking a line and picking Search opened a search that ignored that series' condition, so the results spanned every series and the numbers didn't reconcile with the chart. (HDX-5441)

The cause: a builder chart doesn't put a series' filter in the statement-level where — the editor clears it and each series keeps its filter in aggCondition, applied inside that series' aggregate. buildEventsSearchUrl only ever read chart-level state, plus one narrow special case (promote the condition of a lone series into where when the chart has no where of its own). Every other shape silently dropped it.

What changed

  • buildEventsSearchUrl takes a seriesCondition filter and ANDs it onto the search. The existing single-series promotion still wins where it applies, so those URLs are unchanged; the condition is no longer dropped when promotion can't happen (several series, or a chart-level where to AND with).
  • resolveSeriesConditionFilter (in DBTimeChart) picks the clicked series' condition. Value columns map positionally onto select — the contract useChartNumberFormats already relies on — so the result column the series was plotted from names its select entry. The pinned tooltip now hands that column name to buildSearchUrl rather than only the series key, which also covers the single-value-column + group-by shape where the key carries no column name.
  • Where no single series can be attributed — a whole-bucket "View all events" click, a merged ratio column, or a formula column — it falls back to the union of every series' condition via the existing aggConditionScopeFilter. That is exactly the scan scope the chart used, and it yields nothing once any series is unfiltered (the chart reads every row anyway). This is what fixes the sibling "View all events" action the issue asked about.

Focus is untouched: it applies group-column filters, and a series distinguished only by its WHERE has no group column to focus on.

Testing

Unit tests (make ci-unit green across all packages, make ci-lint clean):

  • resolveSeriesConditionFilter: clicked series, whole-bucket union, unfiltered series, ratio, formula-with-hidden-operands, formula column, raw SQL select.
  • buildEventsSearchUrl: multi-series condition applied, ANDed with chart where + filters, not duplicated when promoted, kept when promotion is impossible.
  • ChartSeriesTooltip: the clicked series' value column reaches buildSearchUrl.

Manual, against the dev stack with seeded logs (foo 6/min, bar 2/min, baz 1/min) on a two-series tile — series A ServiceName:"foo", series B ServiceName:"bar":

Action Before (main) After
Search on "foo count" filters=[], 18 rows, foo + bar + baz filters=[{"type":"lucene","condition":"ServiceName:\"foo\""}], 12 rows, foo only
Search on "bar count" filters=[], 18 rows, foo + bar + baz filters=[{"type":"lucene","condition":"ServiceName:\"bar\""}], 4 rows, bar only
View all events filters=[], 18 rows, foo + bar + baz filters=[{"type":"lucene","condition":"(ServiceName:\"foo\") OR (ServiceName:\"bar\")"}], 16 rows, foo + bar, no baz

Pinned tooltip with per-series Search actions

Before — Search on the "foo count" series returns foo, bar and baz:

Search from the foo series before the fix

After — the same click is scoped to ServiceName:"foo":

Search from the foo series after the fix

After — "View all events" carries the union of both series, so baz (not on the chart) stays out:

View all events after the fix

Linear Issue: HDX-5441

Open in Web Open in Cursor 

A builder chart keeps each series' filter in its own aggCondition, not in the
statement-level where, so a drill-down built from chart-level state alone spans
every series and its counts don't reconcile with the clicked line.

Resolve the clicked series from the result column it was plotted from (value
columns map positionally onto select) and AND its aggCondition onto the search.
A whole-bucket click, a merged ratio column, or a formula column falls back to
the union of every series' condition, which is the scan scope the chart used.

Co-authored-by: Mike Shi <mike@hyperdx.io>
@changeset-bot

changeset-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2ce2db9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 16, 2026 5:50pm UTC
hyperdx-storybook Ready Ready Preview Oct 16, 2026 5:50pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Fixes drill-down search to include the clicked series' filter.

The mixed-language search issue from the previous review still needs fixing before merge.

Fix All in Claude CodeFindings

  1. P1 Mixed languages lose scope ▶

Summary

Chart Search actions now carry the clicked series' aggCondition.

  • Chart searches now keep the condition for the series you clicked.

Reviews (3) · Last reviewed commit: "docs(app): note mixed-language series fa..." · Reviewed by Greptile

Comment on lines +193 to +195
return aggConditionScopeFilter(
clickedSeries != null ? [clickedSeries] : select,
);

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.

P1 Mixed languages lose scope

When a whole-bucket, ratio, or formula action falls back to all series and those series use different condition languages, aggConditionScopeFilter returns undefined, so the Search URL drops every series condition. The chart query still renders each condition in its own language and ORs them together. The resulting search is therefore broader than the chart, and its results will not reconcile with the chart.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Accurate, but not something this PR introduced or can fix here. On main every drill-down drops all series conditions, so this case is no worse than before. The per-series Search is unaffected: a single clicked series has one language.

The search URL can't express the OR: it carries one where language and ANDs its filters. Turning Lucene into SQL needs async column metadata, and adding an OR mode to the search page's filters would also change how its sidebar filters combine. So the fallback leaves the search unscoped (a superset of the chart's rows) rather than scoped wrongly. I documented that in resolveSeriesConditionFilter and added tests for both the mixed-language fallback and a clicked series in a mixed-language chart (2ce2db9).

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.

Agreed. The mixed-language whole-bucket fallback is a pre-existing limitation of the search URL/filter model, and this change preserves the existing unscoped behavior when the union cannot be represented. The per-series path remains correctly scoped because it resolves a single condition and therefore a single filter language. The documentation and tests cover this tradeoff, so no change is needed for this PR.

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 323 passed • 1 skipped • 1046s

Status Count
✅ Passed 323
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

…casting

Keeps the app 'as any' ratchet at its baseline.

Co-authored-by: Mike Shi <mike@hyperdx.io>
cursoragent and others added 2 commits October 16, 2026 17:42
…-search-series-where-9e86

# Conflicts:
#	packages/app/src/components/__tests__/DBTimeChart.test.tsx

Co-authored-by: Mike Shi <mike@hyperdx.io>
The search URL ANDs its filters and carries a single where language, so it
cannot OR a SQL series condition with a Lucene one; the union fallback leaves
the search unscoped in that case. Pin that, and that a clicked series in such
a chart still resolves to its own condition, with tests.

Co-authored-by: Mike Shi <mike@hyperdx.io>
@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 125 in total (1.69%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 2ce2db9e Deployed Oct 16, 2026 by vercel[bot]
Preview – hyperdx-storybook — 2ce2db9e Deployed Oct 16, 2026 by vercel[bot]
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.

2 participants