Skip to content

feat(seer): Add widget-level LLM context to dashboard widgets#112267

Merged
Mihir-Mavalankar merged 8 commits intomasterfrom
mihir-mavalankar/feat/widget-llm-context-registration
Apr 7, 2026
Merged

feat(seer): Add widget-level LLM context to dashboard widgets#112267
Mihir-Mavalankar merged 8 commits intomasterfrom
mihir-mavalankar/feat/widget-llm-context-registration

Conversation

@Mihir-Mavalankar
Copy link
Copy Markdown
Contributor

@Mihir-Mavalankar Mihir-Mavalankar commented Apr 6, 2026

  • Register each dashboard widget as a child node in the LLM context tree so the Seer Explorer agent gets per-widget metadata: title, display type, widget type, query config, and tool-use hints that map directly to Seer's telemetry_live_search parameters.
  • Add page-level filters (date range, environments, projects) and edit mode to the dashboard context node so the agent knows the scope and timeframe the user is viewing.
  • For BigNumber widgets, the visualization component registers as a chart child node and pushes parsed display values (field, value, type, unit, thresholds) — no raw data, just what's rendered on screen.

Register each dashboard widget as a child node in the LLM context
tree so the Seer Explorer agent gets per-widget metadata: title,
display type, widget type, query config, and tool-use hints that
map directly to Seer's telemetry_live_search parameters. Big number
widgets also include their fetched data value. Capitalize node type
headings in the backend markdown renderer for readability.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@Mihir-Mavalankar Mihir-Mavalankar self-assigned this Apr 6, 2026
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Apr 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Mihir-Mavalankar and others added 2 commits April 6, 2026 10:24
Include date range, environments, projects, and edit mode in the
dashboard context node so the Seer Explorer agent knows the scope
and timeframe the user is viewing.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Tell the Seer agent that dateRange/environments/projects are global
page filters scoping every widget, and that child widget nodes have
query config usable with telemetry_live_search.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@Mihir-Mavalankar Mihir-Mavalankar marked this pull request as ready for review April 6, 2026 17:25
@Mihir-Mavalankar Mihir-Mavalankar requested review from a team as code owners April 6, 2026 17:25
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: LLM context captures pre-mutation TOP_N display type
    • Normalized TOP_N to AREA in the LLM context inputs so initial context and query hint now match the rendered timeseries widget.

Create PR

Or push these changes by commenting:

@cursor push c66ab33a1a
Preview (c66ab33a1a)
diff --git a/static/app/views/dashboards/widgetCard/index.tsx b/static/app/views/dashboards/widgetCard/index.tsx
--- a/static/app/views/dashboards/widgetCard/index.tsx
+++ b/static/app/views/dashboards/widgetCard/index.tsx
@@ -177,13 +177,17 @@
   const navigate = useNavigate();
   const {dashboardId: currentDashboardId} = useParams<{dashboardId: string}>();
   const timeoutRef = useRef<NodeJS.Timeout | null>(null);
+  const llmDisplayType =
+    props.widget.displayType === DisplayType.TOP_N
+      ? DisplayType.AREA
+      : props.widget.displayType;
 
   // Push widget metadata into the LLM context tree for Seer Explorer.
   useLLMContext({
     title: props.widget.title,
-    displayType: props.widget.displayType,
+    displayType: llmDisplayType,
     widgetType: props.widget.widgetType,
-    queryHint: getQueryHint(props.widget.displayType),
+    queryHint: getQueryHint(llmDisplayType),
     queries: props.widget.queries.map(q => ({
       name: q.name,
       conditions: q.conditions,
@@ -191,7 +195,7 @@
       columns: q.columns,
       orderby: q.orderby,
     })),
-    ...getWidgetData(props.widget.displayType, data),
+    ...getWidgetData(llmDisplayType, data),
   });
 
   const onDataFetched = (newData: Data) => {

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1bbe4ed. Configure here.

Comment thread static/app/views/dashboards/widgetCard/index.tsx
TOP_N widgets are mutated to AREA later in the render body, but
useLLMContext read the pre-mutation value on first render, producing
a misleading table query hint instead of the correct timeseries hint.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Missed this assertion when capitalizing nodeType in _render_node.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Copy link
Copy Markdown
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

Makes sense overall, just one nit and one suggestion. In the future please split up PRs that contain unrelated changes, regardless of whether it's safe to deploy them together!

Comment thread static/app/views/dashboards/widgetCard/index.tsx Outdated
Comment on lines +164 to +172
export function getWidgetData(
displayType: DisplayType,
data: Data | undefined
): Record<string, unknown> {
if (displayType === DisplayType.BIG_NUMBER && data?.tableResults?.[0]) {
return {data: data.tableResults[0].data};
}
return {};
}
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.

Each widget already has code that takes the fetched data and parses out the visible value (or values). Maybe it would be wise to call useLLMContext from there? e.g., BigNumberWidgetVisualization figures out the correct type, units, thresholds, and so on, all of which is valuable context, you could lean on that, and you won't need getWidgetData at all

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed the approach for Big number. If this looks good, I'll use the something similar for Table and time series data.

Capitalization of nodeType headings in _render_node will be done
in a separate PR.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
…lues

Move getWidgetQueryLLMHint into widgetLLMContext.tsx and remove
getWidgetLLMData — visualization components now push their own
parsed display values instead of extracting raw data at the
WidgetCard level.

Register BigNumberWidgetVisualization as a 'chart' child node
under the widget and push field, value, type, unit, and thresholds
into the LLM context tree.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Change BigNumberWidgetVisualizationProps from interface to type so
it satisfies the Record<string, unknown> constraint in
registerLLMContext. Structurally identical, no behavior change.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@Mihir-Mavalankar Mihir-Mavalankar merged commit 0514751 into master Apr 7, 2026
68 checks passed
@Mihir-Mavalankar Mihir-Mavalankar deleted the mihir-mavalankar/feat/widget-llm-context-registration branch April 7, 2026 19:11
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
+ Register each dashboard widget as a child node in the LLM context tree
so the Seer Explorer agent gets per-widget metadata: title, display
type, widget type, query config, and tool-use hints that map directly to
Seer's telemetry_live_search parameters.
+ Add page-level filters (date range, environments, projects) and edit
mode to the dashboard context node so the agent knows the scope and
timeframe the user is viewing.
+ For BigNumber widgets, the visualization component registers as a
chart child node and pushes parsed display values (field, value, type,
unit, thresholds) — no raw data, just what's rendered on screen.

---------

Co-authored-by: Claude Opus 4.6 <noreply@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components 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