diff --git a/static/app/components/group/groupSummary.spec.tsx b/static/app/components/group/groupSummary.spec.tsx index ce57ddae2bd181..8a54fad7b97b76 100644 --- a/static/app/components/group/groupSummary.spec.tsx +++ b/static/app/components/group/groupSummary.spec.tsx @@ -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(() => { @@ -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(, { + 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/`, @@ -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 () { diff --git a/static/app/components/group/groupSummary.tsx b/static/app/components/group/groupSummary.tsx index c42752f7374510..bfe873a91a687f 100644 --- a/static/app/components/group/groupSummary.tsx +++ b/static/app/components/group/groupSummary.tsx @@ -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; } @@ -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', @@ -167,13 +179,17 @@ export function GroupSummary({ icon: , showWhenLoading: false, }, - { - id: 'possible_cause', - title: t('Possible cause'), - insight: data?.possibleCause, - icon: , - showWhenLoading: true, - }, + ...(shouldShowPossibleCause + ? [ + { + id: 'possible_cause', + title: t('Possible cause'), + insight: data?.possibleCause, + icon: , + showWhenLoading: false, + }, + ] + : []), ]; return ( diff --git a/static/app/views/issueDetails/streamline/sidebar/solutionsSection.spec.tsx b/static/app/views/issueDetails/streamline/sidebar/solutionsSection.spec.tsx index 18f4b690a98097..9a508e70f95e19 100644 --- a/static/app/views/issueDetails/streamline/sidebar/solutionsSection.spec.tsx +++ b/static/app/views/issueDetails/streamline/sidebar/solutionsSection.spec.tsx @@ -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 () => {