Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions static/app/views/dashboards/widgetCard/visualizationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {MISSING_DATA_MESSAGE} from 'sentry/views/dashboards/widgets/common/setti
import type {
TabularColumn,
TimeSeries,
TimeSeriesGroupBy,
} from 'sentry/views/dashboards/widgets/common/types';
import {formatTimeSeriesLabel} from 'sentry/views/dashboards/widgets/timeSeriesWidget/formatters/formatTimeSeriesLabel';
import {formatYAxisValue} from 'sentry/views/dashboards/widgets/timeSeriesWidget/formatters/formatYAxisValue';
Expand All @@ -46,10 +47,12 @@ import {TimeSeriesWidgetVisualization} from 'sentry/views/dashboards/widgets/tim
import {getExploreUrl} from 'sentry/views/explore/utils';
import {TextAlignRight} from 'sentry/views/insights/common/components/textAlign';
import type {LoadableChartWidgetProps} from 'sentry/views/insights/common/components/widgets/types';
import {ModelName} from 'sentry/views/insights/pages/agents/components/modelName';
import {
SeriesColorIndicator,
WidgetFooterTable,
} from 'sentry/views/insights/pages/platform/shared/styles';
import {SpanFields} from 'sentry/views/insights/types';

import {WidgetCardDataLoader} from './widgetCardDataLoader';

Expand Down Expand Up @@ -274,7 +277,13 @@ function VisualizationWidgetContent({
const dataUnit = timeSeries.meta.valueUnit ?? undefined;
const label = plottable?.label ?? timeSeries.yAxis;

let labelContent = <Text>{label}</Text>;
const labelDisplay = renderBreakdownLabel(
firstColumn,
firstColumnGroupByValue,
label
);

let labelContent = <Text>{labelDisplay}</Text>;

// TODO: to simplify things, we only support one widget query for explore urls right now
// Otherwise we have to map the correct widget query to the timeseries result
Expand All @@ -298,7 +307,7 @@ function VisualizationWidgetContent({
widget.widgetType
),
});
labelContent = <Link to={exploreUrl}>{label}</Link>;
labelContent = <Link to={exploreUrl}>{labelDisplay}</Link>;
}

if (
Expand All @@ -317,7 +326,7 @@ function VisualizationWidgetContent({
locationQuery: location.query,
});
if (linkedDashbordUrl) {
labelContent = <Link to={linkedDashbordUrl}>{label}</Link>;
labelContent = <Link to={linkedDashbordUrl}>{labelDisplay}</Link>;
}
}

Expand Down Expand Up @@ -414,3 +423,23 @@ function VisualizationWidgetContent({
</Container>
);
}

/**
* Returns a custom label element for breakdown legend rows that need special rendering
* (e.g., model icons for AI model fields), or falls back to the plain text label.
*/
function renderBreakdownLabel(
column?: string,
groupByValue?: TimeSeriesGroupBy['value'],
fallbackLabel?: string
): React.ReactNode {
if (
typeof groupByValue === 'string' &&
(column === SpanFields.GEN_AI_REQUEST_MODEL ||
column === SpanFields.GEN_AI_RESPONSE_MODEL)
) {
return <ModelName modelId={groupByValue} size={14} />;
}

return fallbackLabel;
}
Loading