Skip to content

feat(logs): Wire Seer AI visualization params into logs explore#115585

Merged
isaacwang-sentry merged 13 commits into
masterfrom
codex/logs-ai-visualization-wiring
Jun 10, 2026
Merged

feat(logs): Wire Seer AI visualization params into logs explore#115585
isaacwang-sentry merged 13 commits into
masterfrom
codex/logs-ai-visualization-wiring

Conversation

@isaacwang-sentry

@isaacwang-sentry isaacwang-sentry commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract getLogsSeerLocationQuery and getLogsSeerAggregateFields from the LogsTabSeerComboBox component into testable, reusable helpers
  • Add support for Seer returning visualization payloads (chart type + y-axes) and propagate them into aggregate field and sort query params
  • Add unit tests for the extracted query-building logic

What this enables (UI/UX)

Previously, asking Seer something like "graph p90 latency by endpoint as a bar chart" in logs explore applied the query filter and group-by, but silently kept the page's existing chart and sort: the visualization payload in Seer's response was discarded, and the sort was parsed but never written to the URL. With this change (plus the companion seer PR https://github.com/getsentry/seer/pull/6513), the requested aggregate, chart type, and sort order are actually applied, and pagination cursors reset so results reflect the new query.

User flow via the logs search bar (Ask Seer):

  1. Requested chart is honored — e.g. "graph the p90 of payload size by endpoint as a bar chart": the chart switches to a bar chart with p90(...) as the y-axis, instead of staying on the default count(message) line chart.
  2. Sort applies in aggregate mode — e.g. "what are my top 5 noisiest projects by log volume?": the table is sorted by count descending, instead of the sort being silently dropped.
  3. Sort applies in samples mode — e.g. "show me the most recent error logs": the samples table sorts by -timestamp; sort is routed to the correct query param for the active mode and the stale one is cleared.
  4. No empty charts — if Seer returns an aggregate query without a visualization, the chart falls back to the default count(message) visualize rather than rendering blank.

Test plan

  • Unit tests added for getLogsSeerLocationQuery covering samples mode, aggregate mode, group-by ordering, and fallback when Seer omits visualizations
  • Manually verify Seer AI queries in logs explore still apply correctly (query, sort, groupBys, visualizations, datetime)

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 14, 2026
@isaacwang-sentry isaacwang-sentry force-pushed the codex/logs-ai-visualization-wiring branch from ecd9e6b to c6d8bea Compare May 14, 2026 20:20
@github-actions

github-actions Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ no issues found

Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx Outdated

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

Sorry for the delay - this is new code for me and I wanted to process it for a bit. I think there are some bugs (shoutout Cursor for helping me validate suspicions). And the duplication scares me.

I'm off through EOD Monday but sent this over to the Explore team to see if someone else has more context.

Exciting stuff, really cool to see the visualizations piping through! 🔥

Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx Outdated
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
? existingVisualizes
: defaultVisualizes(true).map(visualize => visualize.serialize());

return [...groupBys.map(groupBy => ({groupBy})), ...visualizes];

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.

[Bug] Is it intentional that you wanted all group-bys before visualizes?

For context, the old applySeerSearchQuery had a groupByAfterVisualizes pass that detected whether the current list had group-bys positioned after visualizes and preserved that relative order when inserting Seer's new group-bys. This replacement unconditionally puts all group-bys first. So for columns where visualize leads (e.g. [count(message), service.name]), Seer will silently flip the order to [service.name, count(message)] every time it applies a result. Bug?

Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx Outdated
@JoshuaKGoldberg

Copy link
Copy Markdown
Member
  • Manually verify Seer AI queries in logs explore still apply correctly (query, sort, groupBys, visualizations, datetime)

Was this meant to be checked? 🙂

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.

[Praise] I really appreciate you adding tests for this! (and, you know, extracting a shared testable helper in general)

I haven't reviewed these tests closely because I separately requested more refactoring. But I can if you want.

Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx Outdated
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx Outdated
@isaacwang-sentry isaacwang-sentry force-pushed the codex/logs-ai-visualization-wiring branch from 9859122 to b8b6a70 Compare May 26, 2026 21:57
@isaacwang-sentry isaacwang-sentry requested review from a team as code owners May 26, 2026 21:57
@isaacwang-sentry isaacwang-sentry changed the base branch from master to isaacwang/ref/deduplicate-seer-combobox-hooks May 26, 2026 21:57
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
Comment thread static/app/views/explore/seerQuery.ts Outdated
Extract duplicated logic from 5 nearly-identical *SeerComboBox components
into reusable hooks in useSeerComboBoxSetup.ts:

- useInitialSeerQuery: query construction with FREE_TEXT token filtering
- useSelectedProjectIds / useSelectedProjectIdsForMutation: project ID computation
- transformSeerResponse: response mapping with snake_case to camelCase conversion
- buildSeerDateTimeSelection: UTC date handling and pageFilters fallback

Add shared SeerRawResponse and SeerRawResponseItem types to types.ts,
replacing per-component response interface declarations.

Each component retains its unique domain logic (navigation, field building,
visualization handling) while shedding ~400 lines of duplicated boilerplate.

Refs #116050
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
When applying a Seer query in samples mode, getLogsSeerLocationQuery
deleted the logsSortBys param whenever Seer returned an empty sort,
wiping the user's existing sort. This diverged from the metrics tab,
which preserves the current sortBys when Seer omits a sort.

Stop deleting logsSortBys in the samples branch so an empty Seer sort
now leaves the existing sort intact. Aggregate-mode behavior is
unchanged (an empty sort still resets to the default aggregate sort).

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
The base branch made the SeerExploreQuery interface non-exported, so
importing it from seerQuery.ts breaks the typecheck once this branch is
merged with its base. Derive the type from getSeerExploreQuery's return
type instead, removing the dependency on the export.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@isaacwang-sentry isaacwang-sentry force-pushed the isaacwang/ref/deduplicate-seer-combobox-hooks branch from f4c4507 to 4cf7867 Compare June 5, 2026 22:11
Base automatically changed from isaacwang/ref/deduplicate-seer-combobox-hooks to master June 8, 2026 17:11
…lization-wiring

# Conflicts:
#	static/app/components/searchQueryBuilder/askSeerCombobox/useSeerComboBoxSetup.spec.tsx
#	static/app/components/searchQueryBuilder/askSeerCombobox/useSeerComboBoxSetup.ts
#	static/app/views/discover/results/issueListSeerComboBox.tsx
#	static/app/views/explore/logs/logsTabSeerComboBox.tsx
#	static/app/views/explore/metrics/metricsTabSeerComboBox.tsx
#	static/app/views/explore/seerQuery.spec.tsx
#	static/app/views/explore/seerQuery.ts
#	static/app/views/explore/spans/spansTabSeerComboBox.tsx
#	static/app/views/issueList/issueListSeerComboBox.tsx
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
Drop the dead getSeerAggregateFields helper, its test, and the orphaned
Visualize import. The function was left unused after the merge with master
reconciled the spans/metrics callers onto the shared helpers, and knip
flags it as an unused export.
Resolve conflict in logsTabSeerComboBox.tsx: keep the PR's Seer
visualization wiring (getLogsSeerLocationQuery / getSeerExploreQuery /
getSeerWritableAggregateFields / mapSeerResponseItem) and layer in
master's project-expansion feature by routing mapSeerResponseItem
through buildSeerMutationResult / transformSeerResponse and applying
expandedProjectIds to the navigation query, matching the spans combobox.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

pr description describes what's being done technically in code, but would be nice to have a description of what this enables at the UI/UX level, walking through a user flow using the searchbar. A few screenshots or screen recording to verify changes can also go a long way

Comment on lines +4 to +6
getSeerExploreQuery,
getSeerSort,
getSeerWritableAggregateFields,

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.

could you add docstrings for these 3 utils?
On input/output fields, different branches/contracts, when to use.. they're hard to review as is

@isaacwang-sentry

Copy link
Copy Markdown
Member Author

pr description describes what's being done technically in code, but would be nice to have a description of what this enables at the UI/UX level, walking through a user flow using the searchbar. A few screenshots or screen recording to verify changes can also go a long way

Description updated and here is a video

Screen.Recording.2026-06-09.at.4.15.37.PM.mov

@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 d47180f. Configure here.

Comment thread static/app/views/explore/logs/logsTabSeerComboBox.tsx
Also un-export getRawSeerInterval now that mapSeerResponseItem is its
only caller, fixing the knip unused-export failure.
@isaacwang-sentry isaacwang-sentry merged commit 5ed4e72 into master Jun 10, 2026
76 checks passed
@isaacwang-sentry isaacwang-sentry deleted the codex/logs-ai-visualization-wiring branch June 10, 2026 19:17
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.

4 participants