Skip to content

Commit f3efa97

Browse files
committed
feat(seer): Redesign Seer Projects settings page to be easier to follow
1 parent 7e3a022 commit f3efa97

11 files changed

Lines changed: 362 additions & 331 deletions
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
2+
import BooleanField from 'sentry/components/forms/fields/booleanField';
3+
import {t} from 'sentry/locale';
4+
import type {Project} from 'sentry/types/project';
5+
import {useUpdateProject} from 'sentry/utils/project/useUpdateProject';
6+
7+
interface Props {
8+
canWrite: boolean;
9+
project: Project;
10+
}
11+
12+
/**
13+
* Master toggle for auto-triggered fixes.
14+
* This should be placed at the top of the unified settings container.
15+
*/
16+
export default function AutoTriggeredFixesToggle({canWrite, project}: Props) {
17+
const {mutate: updateProject} = useUpdateProject(project);
18+
19+
const isEnabled = Boolean(
20+
project.autofixAutomationTuning && project.autofixAutomationTuning !== 'off'
21+
);
22+
23+
return (
24+
<BooleanField
25+
disabled={!canWrite}
26+
name="autofixAutomationTuning"
27+
label={t('Auto-Triggered Fixes')}
28+
help={t(
29+
'Automatically analyze highly actionable issues, and create a root cause analysis without a user needing to prompt it.'
30+
)}
31+
value={isEnabled}
32+
onChange={value => {
33+
const newValue: Project['autofixAutomationTuning'] = value ? 'medium' : 'off';
34+
updateProject(
35+
{autofixAutomationTuning: newValue},
36+
{
37+
onSuccess: () =>
38+
addSuccessMessage(
39+
value
40+
? t('Enabled auto-triggered fixes')
41+
: t('Disabled auto-triggered fixes')
42+
),
43+
onError: () =>
44+
addErrorMessage(t('Failed to update auto-triggered fixes setting')),
45+
}
46+
);
47+
}}
48+
/>
49+
);
50+
}

static/gsApp/views/seerAutomation/components/projectDetails/backgroundAgentFields.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,25 @@ function CursorIntegrationFields({
4848
}: Props) {
4949
const {mutate: updateProjectSeerPreferences} = useUpdateProjectSeerPreferences(project);
5050

51+
const isBackgroundAgentEnabled = Boolean(preference?.automation_handoff);
52+
const isAutoTriggeredFixesEnabled = Boolean(
53+
project.autofixAutomationTuning && project.autofixAutomationTuning !== 'off'
54+
);
55+
56+
const isDisabled =
57+
!canWrite || !isAutoTriggeredFixesEnabled || !isBackgroundAgentEnabled;
58+
59+
let disabledReason: string | null = null;
60+
if (!isAutoTriggeredFixesEnabled) {
61+
disabledReason = t('Turn on Auto-Triggered Fixes to use this feature.');
62+
} else if (isBackgroundAgentEnabled) {
63+
disabledReason = t('This setting is not available when using background agents.');
64+
}
65+
5166
return (
5267
<BooleanField
53-
disabled={
54-
!canWrite || preference?.automation_handoff?.target !== 'cursor_background_agent'
55-
}
68+
disabled={isDisabled}
69+
disabledReason={disabledReason}
5670
name="cursorAutoCreatePullRequests"
5771
label={t('Auto-Create Pull Requests')}
5872
help={t(

static/gsApp/views/seerAutomation/components/projectDetails/backgroundAgentForm.tsx

Lines changed: 0 additions & 103 deletions
This file was deleted.

static/gsApp/views/seerAutomation/components/projectDetails/backgroundAgentPicker.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export default function BackgroundAgentPicker({
2929
}: Props) {
3030
const {mutate: updateProjectSeerPreferences} = useUpdateProjectSeerPreferences(project);
3131

32+
const isAutoTriggeredFixesEnabled = Boolean(
33+
project.autofixAutomationTuning && project.autofixAutomationTuning !== 'off'
34+
);
35+
36+
const isDisabled = !canWrite || !isAutoTriggeredFixesEnabled;
37+
38+
let disabledReason: string | null = null;
39+
if (!isAutoTriggeredFixesEnabled) {
40+
disabledReason = t('Turn on Auto-Triggered Fixes to use this feature.');
41+
}
42+
3243
if (supportedIntegrations.length === 0) {
3344
// There are no supported integrations, so we don't need to show anything
3445
// Users will need to add an integration first (See <BackgroundAgentSetup />)
@@ -43,7 +54,8 @@ export default function BackgroundAgentPicker({
4354
case 'cursor':
4455
return (
4556
<BooleanField
46-
disabled={!canWrite}
57+
disabled={isDisabled}
58+
disabledReason={disabledReason ?? undefined}
4759
name="connectCursorIntegration"
4860
label={
4961
<Flex align="center" gap="sm">
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {Fragment} from 'react';
2+
3+
import {Flex} from '@sentry/scraps/layout';
4+
5+
import type {ProjectSeerPreferences} from 'sentry/components/events/autofix/types';
6+
import {useCodingAgentIntegrations} from 'sentry/components/events/autofix/useAutofix';
7+
import Placeholder from 'sentry/components/placeholder';
8+
import type {Project} from 'sentry/types/project';
9+
10+
import BackgroundAgentFields from 'getsentry/views/seerAutomation/components/projectDetails/backgroundAgentFields';
11+
import BackgroundAgentSetup from 'getsentry/views/seerAutomation/components/projectDetails/backgroundAgentSetup';
12+
13+
interface Props {
14+
canWrite: boolean;
15+
isLoadingIntegrations: boolean;
16+
preference: ProjectSeerPreferences;
17+
project: Project;
18+
selectedIntegration: ReturnType<typeof useCodingAgentIntegrations>['data'] extends
19+
| {integrations: Array<infer T>}
20+
| undefined
21+
? T | undefined
22+
: never;
23+
supportedIntegrations: NonNullable<
24+
ReturnType<typeof useCodingAgentIntegrations>['data']
25+
>['integrations'];
26+
}
27+
28+
export default function BackgroundAgentSection({
29+
canWrite,
30+
project,
31+
preference,
32+
supportedIntegrations,
33+
selectedIntegration,
34+
isLoadingIntegrations,
35+
}: Props) {
36+
if (isLoadingIntegrations) {
37+
return (
38+
<Flex justify="center" align="center" padding="xl">
39+
<Placeholder height="52px" />
40+
</Flex>
41+
);
42+
}
43+
44+
return (
45+
<Fragment>
46+
{selectedIntegration ? (
47+
<BackgroundAgentFields
48+
canWrite={canWrite}
49+
project={project}
50+
preference={preference}
51+
selectedIntegration={selectedIntegration}
52+
/>
53+
) : null}
54+
<BackgroundAgentSetup supportedIntegrations={supportedIntegrations} />
55+
</Fragment>
56+
);
57+
}

static/gsApp/views/seerAutomation/components/projectDetails/projectDetailsForm.spec.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)