Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(issue summary) Only show possible cause if confident and novel #84349

Merged
Merged
Show file tree
Hide file tree
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
41 changes: 39 additions & 2 deletions static/app/components/group/groupSummary.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ describe('GroupSummary', function () {
trace: 'Test trace',
possibleCause: 'Test possible cause',
headline: 'Test headline',
scores: {
possibleCauseConfidence: 0.9,
possibleCauseNovelty: 0.8,
},
};

const mockSummaryDataWithLowScores = {
groupId: '1',
whatsWrong: 'Test whats wrong',
trace: 'Test trace',
possibleCause: 'Test possible cause',
headline: 'Test headline',
scores: {
possibleCauseConfidence: 0.5,
possibleCauseNovelty: 0.0,
},
};

beforeEach(() => {
Expand Down Expand Up @@ -62,6 +78,27 @@ describe('GroupSummary', function () {
expect(screen.getByText('Test possible cause')).toBeInTheDocument();
});

it('renders the summary without possible cause', async function () {
MockApiClient.addMockResponse({
url: `/organizations/${mockProject.organization.slug}/issues/${mockGroup.id}/summarize/`,
method: 'POST',
body: mockSummaryDataWithLowScores,
});

render(<GroupSummary event={mockEvent} group={mockGroup} project={mockProject} />, {
organization,
});

await waitFor(() => {
expect(screen.getByText("What's wrong")).toBeInTheDocument();
});
expect(screen.getByText('Test whats wrong')).toBeInTheDocument();
expect(screen.getByText('In the trace')).toBeInTheDocument();
expect(screen.getByText('Test trace')).toBeInTheDocument();
expect(screen.queryByText('Possible cause')).not.toBeInTheDocument();
expect(screen.queryByText('Test possible cause')).not.toBeInTheDocument();
});

it('shows loading state', function () {
MockApiClient.addMockResponse({
url: `/organizations/${mockProject.organization.slug}/issues/${mockGroup.id}/summarize/`,
Expand All @@ -73,8 +110,8 @@ describe('GroupSummary', function () {
organization,
});

// Should show loading placeholders
expect(screen.getAllByTestId('loading-placeholder')).toHaveLength(2);
// Should show loading placeholders. Currently we load the whatsWrong section
expect(screen.getAllByTestId('loading-placeholder')).toHaveLength(1);
});

it('shows error state', async function () {
Expand Down
30 changes: 23 additions & 7 deletions static/app/components/group/groupSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ import {useFeedbackForm} from 'sentry/utils/useFeedbackForm';
import useOrganization from 'sentry/utils/useOrganization';
import {useAiConfig} from 'sentry/views/issueDetails/streamline/hooks/useAiConfig';

const POSSIBLE_CAUSE_CONFIDENCE_THRESHOLD = 0.468;
const POSSIBLE_CAUSE_NOVELTY_THRESHOLD = 0.419;

interface GroupSummaryData {
groupId: string;
headline: string;
eventId?: string | null;
possibleCause?: string | null;
scores?: {
possibleCauseConfidence: number;
possibleCauseNovelty: number;
} | null;
trace?: string | null;
whatsWrong?: string | null;
}
Expand Down Expand Up @@ -152,6 +159,11 @@ export function GroupSummary({
: []),
];

const shouldShowPossibleCause =
!data?.scores ||
(data.scores.possibleCauseConfidence >= POSSIBLE_CAUSE_CONFIDENCE_THRESHOLD &&
data.scores.possibleCauseNovelty >= POSSIBLE_CAUSE_NOVELTY_THRESHOLD);

const insightCards = [
{
id: 'whats_wrong',
Expand All @@ -167,13 +179,17 @@ export function GroupSummary({
icon: <IconSpan size="sm" />,
showWhenLoading: false,
},
{
id: 'possible_cause',
title: t('Possible cause'),
insight: data?.possibleCause,
icon: <IconFocus size="sm" />,
showWhenLoading: true,
},
...(shouldShowPossibleCause
? [
{
id: 'possible_cause',
title: t('Possible cause'),
insight: data?.possibleCause,
icon: <IconFocus size="sm" />,
showWhenLoading: false,
},
]
: []),
];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('SolutionsSection', () => {
);

expect(screen.getByText('Solutions Hub')).toBeInTheDocument();
expect(screen.getAllByTestId('loading-placeholder')).toHaveLength(3);
expect(screen.getAllByTestId('loading-placeholder')).toHaveLength(2); // whatsWrong and Open Autofix
});

it('renders summary when AI features are enabled and data is available', async () => {
Expand Down
Loading