@@ -16,9 +16,6 @@ import {type ApiQueryKey, useApiQuery, useQueryClient} from 'sentry/utils/queryC
16
16
import useOrganization from 'sentry/utils/useOrganization' ;
17
17
import { useAiConfig } from 'sentry/views/issueDetails/streamline/hooks/useAiConfig' ;
18
18
19
- const POSSIBLE_CAUSE_CONFIDENCE_THRESHOLD = 0.0 ;
20
- const POSSIBLE_CAUSE_NOVELTY_THRESHOLD = 0.0 ;
21
-
22
19
export interface GroupSummaryData {
23
20
groupId : string ;
24
21
headline : string ;
@@ -113,7 +110,6 @@ export function GroupSummary({
113
110
project : Project ;
114
111
preview ?: boolean ;
115
112
} ) {
116
- const config = getConfigForIssueType ( group , project ) ;
117
113
const queryClient = useQueryClient ( ) ;
118
114
const organization = useOrganization ( ) ;
119
115
const [ forceEvent , setForceEvent ] = useState ( false ) ;
@@ -150,18 +146,108 @@ export function GroupSummary({
150
146
organization . slug ,
151
147
] ) ;
152
148
153
- const shouldShowPossibleCause =
154
- ! data ?. scores ||
155
- ( data . scores . possibleCauseConfidence &&
156
- data . scores . possibleCauseConfidence >= POSSIBLE_CAUSE_CONFIDENCE_THRESHOLD &&
157
- data . scores . possibleCauseNovelty &&
158
- data . scores . possibleCauseNovelty >= POSSIBLE_CAUSE_NOVELTY_THRESHOLD ) ;
149
+ if ( preview ) {
150
+ return < GroupSummaryPreview data = { data } isPending = { isPending } isError = { isError } /> ;
151
+ }
152
+ return (
153
+ < GroupSummaryFull
154
+ group = { group }
155
+ project = { project }
156
+ data = { data }
157
+ isPending = { isPending }
158
+ isError = { isError }
159
+ setForceEvent = { setForceEvent }
160
+ preview = { preview }
161
+ event = { event }
162
+ />
163
+ ) ;
164
+ }
165
+
166
+ function GroupSummaryPreview ( {
167
+ data,
168
+ isPending,
169
+ isError,
170
+ } : {
171
+ data : GroupSummaryData | undefined ;
172
+ isError : boolean ;
173
+ isPending : boolean ;
174
+ } ) {
175
+ const insightCards = [
176
+ {
177
+ id : 'possible_cause' ,
178
+ title : t ( 'Initial Guess' ) ,
179
+ insight : data ?. possibleCause ,
180
+ icon : < IconFocus size = "sm" /> ,
181
+ showWhenLoading : true ,
182
+ } ,
183
+ ] ;
184
+
185
+ return (
186
+ < div data-testid = "group-summary-preview" >
187
+ { isError ? < div > { t ( 'Error loading summary' ) } </ div > : null }
188
+ < Content >
189
+ < InsightGrid >
190
+ { insightCards . map ( card => {
191
+ if ( ( ! isPending && ! card . insight ) || ( isPending && ! card . showWhenLoading ) ) {
192
+ return null ;
193
+ }
194
+ return (
195
+ < InsightCard key = { card . id } >
196
+ < CardTitle >
197
+ < CardTitleIcon > { card . icon } </ CardTitleIcon >
198
+ < CardTitleText > { card . title } </ CardTitleText >
199
+ </ CardTitle >
200
+ < CardContentContainer >
201
+ < CardLineDecorationWrapper >
202
+ < CardLineDecoration />
203
+ </ CardLineDecorationWrapper >
204
+ { isPending ? (
205
+ < CardContent >
206
+ < Placeholder height = "1.5rem" />
207
+ </ CardContent >
208
+ ) : (
209
+ < CardContent >
210
+ { card . insight && (
211
+ < MarkedText text = { card . insight . replace ( / \* \* / g, '' ) } />
212
+ ) }
213
+ </ CardContent >
214
+ ) }
215
+ </ CardContentContainer >
216
+ </ InsightCard >
217
+ ) ;
218
+ } ) }
219
+ </ InsightGrid >
220
+ </ Content >
221
+ </ div >
222
+ ) ;
223
+ }
224
+
225
+ function GroupSummaryFull ( {
226
+ group,
227
+ project,
228
+ data,
229
+ isPending,
230
+ isError,
231
+ setForceEvent,
232
+ preview,
233
+ event,
234
+ } : {
235
+ data : GroupSummaryData | undefined ;
236
+ event : Event | null | undefined ;
237
+ group : Group ;
238
+ isError : boolean ;
239
+ isPending : boolean ;
240
+ preview : boolean ;
241
+ project : Project ;
242
+ setForceEvent : ( v : boolean ) => void ;
243
+ } ) {
244
+ const config = getConfigForIssueType ( group , project ) ;
159
245
const shouldShowResources = config . resources && ! preview ;
160
246
161
247
const insightCards = [
162
248
{
163
249
id : 'whats_wrong' ,
164
- title : t ( "What's Wrong" ) ,
250
+ title : t ( 'What Happened' ) ,
165
251
insight : data ?. whatsWrong ,
166
252
icon : < IconFatal size = "sm" /> ,
167
253
showWhenLoading : true ,
@@ -173,23 +259,19 @@ export function GroupSummary({
173
259
icon : < IconSpan size = "sm" /> ,
174
260
showWhenLoading : false ,
175
261
} ,
176
- ...( shouldShowPossibleCause
177
- ? [
178
- {
179
- id : 'possible_cause' ,
180
- title : t ( 'Possible Cause' ) ,
181
- insight : data ?. possibleCause ,
182
- icon : < IconFocus size = "sm" /> ,
183
- showWhenLoading : true ,
184
- } ,
185
- ]
186
- : [ ] ) ,
262
+ {
263
+ id : 'possible_cause' ,
264
+ title : t ( 'Initial Guess' ) ,
265
+ insight : data ?. possibleCause ,
266
+ icon : < IconFocus size = "sm" /> ,
267
+ showWhenLoading : true ,
268
+ } ,
269
+
187
270
...( shouldShowResources
188
271
? [
189
272
{
190
273
id : 'resources' ,
191
274
title : t ( 'Resources' ) ,
192
-
193
275
// eslint-disable-next-line @typescript-eslint/no-base-to-string
194
276
insight : `${ isValidElement ( config . resources ?. description ) ? '' : ( config . resources ?. description ?? '' ) } \n\n${ config . resources ?. links ?. map ( link => `[${ link . text } ](${ link . link } )` ) . join ( ' • ' ) ?? '' } ` ,
195
277
insightElement : isValidElement ( config . resources ?. description )
@@ -211,13 +293,10 @@ export function GroupSummary({
211
293
if ( ( ! isPending && ! card . insight ) || ( isPending && ! card . showWhenLoading ) ) {
212
294
return null ;
213
295
}
214
-
215
296
return (
216
297
< InsightCard key = { card . id } >
217
- < CardTitle preview = { preview } cardId = { card . id } >
218
- < CardTitleIcon cardId = { card . id } preview = { preview } >
219
- { card . icon }
220
- </ CardTitleIcon >
298
+ < CardTitle >
299
+ < CardTitleIcon > { card . icon } </ CardTitleIcon >
221
300
< CardTitleText > { card . title } </ CardTitleText >
222
301
</ CardTitle >
223
302
< CardContentContainer >
@@ -241,7 +320,7 @@ export function GroupSummary({
241
320
) ;
242
321
} ) }
243
322
</ InsightGrid >
244
- { data ?. eventId && ! isPending && ! preview && event ? .id !== data ?. eventId && (
323
+ { data ?. eventId && ! isPending && event && event . id !== data ?. eventId && (
245
324
< ResummarizeWrapper >
246
325
< Button
247
326
onClick = { ( ) => setForceEvent ( true ) }
@@ -279,14 +358,11 @@ const InsightCard = styled('div')`
279
358
min-height: 0;
280
359
` ;
281
360
282
- const CardTitle = styled ( 'div' ) < { cardId ?: string ; preview ?: boolean } > `
361
+ const CardTitle = styled ( 'div' ) `
283
362
display: flex;
284
363
align-items: center;
285
364
gap: ${ space ( 1 ) } ;
286
- color: ${ p =>
287
- p . preview === false && p . cardId === 'whats_wrong'
288
- ? p . theme . textColor
289
- : p . theme . subText } ;
365
+ color: ${ p => p . theme . subText } ;
290
366
padding-bottom: ${ space ( 0.5 ) } ;
291
367
` ;
292
368
@@ -296,13 +372,10 @@ const CardTitleText = styled('p')`
296
372
font-weight: ${ p => p . theme . fontWeightBold } ;
297
373
` ;
298
374
299
- const CardTitleIcon = styled ( 'div' ) < { cardId ?: string ; preview ?: boolean } > `
375
+ const CardTitleIcon = styled ( 'div' ) `
300
376
display: flex;
301
377
align-items: center;
302
- color: ${ p =>
303
- p . preview === false && p . cardId === 'whats_wrong'
304
- ? p . theme . pink400
305
- : p . theme . subText } ;
378
+ color: ${ p => p . theme . subText } ;
306
379
` ;
307
380
308
381
const CardContentContainer = styled ( 'div' ) `
0 commit comments