1
1
import { Alert } from 'sentry/components/core/alert' ;
2
2
import { Button } from 'sentry/components/core/button' ;
3
+ import { CompactSelect } from 'sentry/components/core/compactSelect' ;
3
4
import { Flex } from 'sentry/components/core/layout' ;
4
5
import { ExternalLink } from 'sentry/components/core/link' ;
5
6
import { Switch } from 'sentry/components/core/switch' ;
@@ -9,7 +10,7 @@ import SlideOverPanel from 'sentry/components/slideOverPanel';
9
10
import { IconClose } from 'sentry/icons' ;
10
11
import { t , tct } from 'sentry/locale' ;
11
12
import { type PreventAIOrgConfig } from 'sentry/types/prevent' ;
12
- import type { PreventAIFeatureConfigsByName } from 'sentry/types/prevent' ;
13
+ import type { PreventAIFeatureConfigsByName , Sensitivity } from 'sentry/types/prevent' ;
13
14
import useOrganization from 'sentry/utils/useOrganization' ;
14
15
import { useUpdatePreventAIFeature } from 'sentry/views/prevent/preventAI/hooks/useUpdatePreventAIFeature' ;
15
16
@@ -20,6 +21,31 @@ interface ManageReposPanelProps {
20
21
repoName : string ;
21
22
}
22
23
24
+ interface SensitivityOption {
25
+ details : string ;
26
+ label : string ;
27
+ value : Sensitivity ;
28
+ }
29
+
30
+ const sensitivityOptions : SensitivityOption [ ] = [
31
+ { value : 'low' , label : 'Low' , details : 'Post all potential issues for maximum breadth.' } ,
32
+ {
33
+ value : 'medium' ,
34
+ label : 'Medium' ,
35
+ details : 'Post likely issues for a balance of thoroughness and noise.' ,
36
+ } ,
37
+ {
38
+ value : 'high' ,
39
+ label : 'High' ,
40
+ details : 'Post only major issues to highlight most impactful findings.' ,
41
+ } ,
42
+ {
43
+ value : 'critical' ,
44
+ label : 'Critical' ,
45
+ details : 'Post only high-impact, high-sensitivity issues for maximum focus.' ,
46
+ } ,
47
+ ] ;
48
+
23
49
function ManageReposPanel ( {
24
50
collapsed,
25
51
onClose,
@@ -111,9 +137,9 @@ function ManageReposPanel({
111
137
justify = "between"
112
138
>
113
139
< Flex direction = "column" gap = "sm" >
114
- < Text size = "md" > Enable PR Review</ Text >
140
+ < Text size = "md" > { t ( ' Enable PR Review' ) } </ Text >
115
141
< Text variant = "muted" size = "sm" >
116
- Run when @sentry review is commented on a PR.
142
+ { t ( ' Run when @sentry review is commented on a PR.' ) }
117
143
</ Text >
118
144
</ Flex >
119
145
< Switch
@@ -132,6 +158,41 @@ function ManageReposPanel({
132
158
aria-label = "Enable PR Review"
133
159
/>
134
160
</ Flex >
161
+ { repoConfig . vanilla . enabled && (
162
+ < Flex paddingLeft = "xl" direction = "column" >
163
+ < Flex direction = "column" borderLeft = "muted" paddingLeft = "md" >
164
+ < FieldGroup
165
+ label = { < Text size = "md" > { t ( 'Sensitivity' ) } </ Text > }
166
+ help = {
167
+ < Text size = "xs" variant = "muted" >
168
+ { t ( 'Set the sensitivity level for PR review analysis.' ) }
169
+ </ Text >
170
+ }
171
+ alignRight
172
+ flexibleControlStateSize
173
+ >
174
+ < CompactSelect
175
+ value = { repoConfig . vanilla . sensitivity ?? 'medium' }
176
+ options = { sensitivityOptions }
177
+ disabled = { isLoading || ! canEditSettings }
178
+ onChange = { async option =>
179
+ await enableFeature ( {
180
+ feature : 'vanilla' ,
181
+ enabled : true ,
182
+ orgName,
183
+ repoName,
184
+ sensitivity : option . value ,
185
+ } )
186
+ }
187
+ aria-label = "PR Review Sensitivity"
188
+ menuWidth = { 350 }
189
+ maxMenuWidth = { 500 }
190
+ data-test-id = "pr-review-sensitivity-dropdown"
191
+ />
192
+ </ FieldGroup >
193
+ </ Flex >
194
+ </ Flex >
195
+ ) }
135
196
</ Flex >
136
197
137
198
{ /* Test Generation Feature */ }
@@ -145,9 +206,9 @@ function ManageReposPanel({
145
206
justify = "between"
146
207
>
147
208
< Flex direction = "column" gap = "sm" >
148
- < Text size = "md" > Enable Test Generation</ Text >
209
+ < Text size = "md" > { t ( ' Enable Test Generation' ) } </ Text >
149
210
< Text variant = "muted" size = "sm" >
150
- Run when @sentry generate-test is commented on a PR.
211
+ { t ( ' Run when @sentry generate-test is commented on a PR.' ) }
151
212
</ Text >
152
213
</ Flex >
153
214
< Switch
@@ -179,9 +240,9 @@ function ManageReposPanel({
179
240
justify = "between"
180
241
>
181
242
< Flex direction = "column" gap = "sm" >
182
- < Text size = "md" > Enable Error Prediction</ Text >
243
+ < Text size = "md" > { t ( ' Enable Error Prediction' ) } </ Text >
183
244
< Text variant = "muted" size = "sm" >
184
- Allow organization members to review potential bugs.
245
+ { t ( ' Allow organization members to review potential bugs.' ) }
185
246
</ Text >
186
247
</ Flex >
187
248
< Switch
@@ -190,7 +251,6 @@ function ManageReposPanel({
190
251
disabled = { isLoading || ! canEditSettings }
191
252
onChange = { async ( ) => {
192
253
const newValue = ! repoConfig . bug_prediction . enabled ;
193
- // Enable/disable the main bug prediction feature
194
254
await enableFeature ( {
195
255
feature : 'bug_prediction' ,
196
256
enabled : newValue ,
@@ -202,23 +262,45 @@ function ManageReposPanel({
202
262
/>
203
263
</ Flex >
204
264
{ repoConfig . bug_prediction . enabled && (
205
- // width 150% because FieldGroup > FieldDescription has fixed width 50%
206
- < Flex paddingLeft = "xl" width = "150%" >
207
- < Flex
208
- direction = "column"
209
- borderLeft = "muted"
210
- radius = "md"
211
- paddingLeft = "md"
212
- width = "100%"
213
- >
265
+ < Flex paddingLeft = "xl" direction = "column" >
266
+ < Flex direction = "column" borderLeft = "muted" paddingLeft = "md" >
267
+ < FieldGroup
268
+ label = { < Text size = "md" > { t ( 'Sensitivity' ) } </ Text > }
269
+ help = {
270
+ < Text size = "xs" variant = "muted" >
271
+ { t ( 'Set the sensitivity level for error prediction.' ) }
272
+ </ Text >
273
+ }
274
+ alignRight
275
+ flexibleControlStateSize
276
+ >
277
+ < CompactSelect
278
+ value = { repoConfig . bug_prediction . sensitivity ?? 'medium' }
279
+ options = { sensitivityOptions }
280
+ disabled = { isLoading || ! canEditSettings }
281
+ onChange = { async option =>
282
+ await enableFeature ( {
283
+ feature : 'bug_prediction' ,
284
+ enabled : true ,
285
+ orgName,
286
+ repoName,
287
+ sensitivity : option . value ,
288
+ } )
289
+ }
290
+ aria-label = "Error Prediction Sensitivity"
291
+ menuWidth = { 350 }
292
+ maxMenuWidth = { 500 }
293
+ data-test-id = "error-prediction-sensitivity-dropdown"
294
+ />
295
+ </ FieldGroup >
214
296
< FieldGroup
215
297
label = { < Text size = "md" > { t ( 'Auto Run on Opened Pull Requests' ) } </ Text > }
216
298
help = {
217
299
< Text size = "xs" variant = "muted" >
218
300
{ t ( 'Run when a PR is published, ignoring new pushes.' ) }
219
301
</ Text >
220
302
}
221
- inline
303
+ alignRight
222
304
flexibleControlStateSize
223
305
>
224
306
< Switch
@@ -243,10 +325,10 @@ function ManageReposPanel({
243
325
label = { < Text size = "md" > { t ( 'Run When Mentioned' ) } </ Text > }
244
326
help = {
245
327
< Text size = "xs" variant = "muted" >
246
- { t ( 'Run when @sentry review is commented on a PR' ) }
328
+ { t ( 'Run when @sentry review is commented on a PR. ' ) }
247
329
</ Text >
248
330
}
249
- inline
331
+ alignRight
250
332
flexibleControlStateSize
251
333
>
252
334
< Switch
0 commit comments