-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(cursor-agent): add frontend toggle for whether to create pr #103730
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
247c56c
feat(cursor-agent): add frontend toggle for whether to create pr
jennmueng 9c3bf8c
type, fields, test
jennmueng b14ef12
fix this test
jennmueng 7486920
need to update the key to stop spinning state
jennmueng 99df847
fix condition
jennmueng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import {Link} from 'sentry/components/core/link'; | |
| import {CursorIntegrationCta} from 'sentry/components/events/autofix/cursorIntegrationCta'; | ||
| import {useProjectSeerPreferences} from 'sentry/components/events/autofix/preferences/hooks/useProjectSeerPreferences'; | ||
| import {useUpdateProjectSeerPreferences} from 'sentry/components/events/autofix/preferences/hooks/useUpdateProjectSeerPreferences'; | ||
| import type {ProjectSeerPreferences} from 'sentry/components/events/autofix/types'; | ||
| import {useCodingAgentIntegrations} from 'sentry/components/events/autofix/useAutofix'; | ||
| import {useOrganizationSeerSetup} from 'sentry/components/events/autofix/useOrganizationSeerSetup'; | ||
| import Form from 'sentry/components/forms/form'; | ||
|
|
@@ -100,6 +101,58 @@ const autofixAutomationToggleField = { | |
| }), | ||
| } satisfies FieldObject; | ||
|
|
||
| function CodingAgentSettings({ | ||
| preference, | ||
| handleAutoCreatePrChange, | ||
| canWriteProject, | ||
| isAutomationOn, | ||
| }: { | ||
| canWriteProject: boolean; | ||
| handleAutoCreatePrChange: (value: boolean) => void; | ||
| preference: ProjectSeerPreferences | null | undefined; | ||
| isAutomationOn?: boolean; | ||
| }) { | ||
| if (!preference?.automation_handoff || !isAutomationOn) { | ||
| return null; | ||
| } | ||
|
|
||
| const initialValue = preference?.automation_handoff?.auto_create_pr ?? false; | ||
|
|
||
| return ( | ||
| <Form | ||
| key={`coding-agent-settings-${initialValue}`} | ||
| apiMethod="POST" | ||
| saveOnBlur | ||
| initialData={{ | ||
| auto_create_pr: initialValue, | ||
| }} | ||
| > | ||
| <JsonForm | ||
| forms={[ | ||
| { | ||
| title: t('Cursor Agent Settings'), | ||
| fields: [ | ||
| { | ||
| name: 'auto_create_pr', | ||
| label: t('Auto-Create Pull Requests'), | ||
| help: t( | ||
| 'When enabled, Cursor Cloud Agents will automatically create pull requests after hand off.' | ||
| ), | ||
| saveOnBlur: true, | ||
| type: 'boolean', | ||
| getData: () => ({}), | ||
| getValue: () => initialValue, | ||
|
Comment on lines
+143
to
+144
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to stop the request from actually happening --- in tests at least |
||
| disabled: !canWriteProject, | ||
| onChange: handleAutoCreatePrChange, | ||
| } satisfies FieldObject, | ||
| ], | ||
| }, | ||
| ]} | ||
| /> | ||
| </Form> | ||
jennmueng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
|
|
||
| function ProjectSeerGeneralForm({project}: {project: Project}) { | ||
| const organization = useOrganization(); | ||
| const queryClient = useQueryClient(); | ||
|
|
@@ -146,6 +199,7 @@ function ProjectSeerGeneralForm({project}: {project: Project}) { | |
| handoff_point: 'root_cause', | ||
| target: 'cursor_background_agent', | ||
| integration_id: parseInt(cursorIntegration.id, 10), | ||
| auto_create_pr: false, | ||
| }, | ||
| }); | ||
| } else { | ||
|
|
@@ -159,6 +213,23 @@ function ProjectSeerGeneralForm({project}: {project: Project}) { | |
| [updateProjectSeerPreferences, preference?.repositories, cursorIntegration] | ||
| ); | ||
|
|
||
| const handleAutoCreatePrChange = useCallback( | ||
| (value: boolean) => { | ||
| if (!preference?.automation_handoff) { | ||
| return; | ||
| } | ||
| updateProjectSeerPreferences({ | ||
| repositories: preference?.repositories || [], | ||
| automated_run_stopping_point: preference?.automated_run_stopping_point, | ||
| automation_handoff: { | ||
| ...preference.automation_handoff, | ||
| auto_create_pr: value, | ||
| }, | ||
| }); | ||
| }, | ||
| [preference, updateProjectSeerPreferences] | ||
| ); | ||
|
|
||
| const automatedRunStoppingPointField = { | ||
| name: 'automated_run_stopping_point', | ||
| label: t('Where should Seer stop?'), | ||
|
|
@@ -256,6 +327,10 @@ function ProjectSeerGeneralForm({project}: {project: Project}) { | |
| }, | ||
| ]; | ||
|
|
||
| const automationTuning = isTriageSignalsFeatureOn | ||
| ? (project.autofixAutomationTuning ?? 'off') !== 'off' | ||
| : (project.autofixAutomationTuning ?? 'off'); | ||
|
|
||
| return ( | ||
| <Fragment> | ||
| <Form | ||
|
|
@@ -271,9 +346,7 @@ function ProjectSeerGeneralForm({project}: {project: Project}) { | |
| initialData={{ | ||
| seerScannerAutomation: project.seerScannerAutomation ?? false, | ||
| // Same DB field, different UI: toggle (boolean) vs dropdown (string) | ||
| autofixAutomationTuning: isTriageSignalsFeatureOn | ||
| ? (project.autofixAutomationTuning ?? 'off') !== 'off' | ||
| : (project.autofixAutomationTuning ?? 'off'), | ||
| autofixAutomationTuning: automationTuning, | ||
| automated_run_stopping_point: preference?.automation_handoff | ||
| ? 'cursor_handoff' | ||
| : (preference?.automated_run_stopping_point ?? 'root_cause'), | ||
|
|
@@ -291,6 +364,12 @@ function ProjectSeerGeneralForm({project}: {project: Project}) { | |
| )} | ||
| /> | ||
| </Form> | ||
| <CodingAgentSettings | ||
| preference={preference} | ||
| handleAutoCreatePrChange={handleAutoCreatePrChange} | ||
| isAutomationOn={automationTuning && automationTuning !== 'off'} | ||
| canWriteProject={canWriteProject} | ||
| /> | ||
| </Fragment> | ||
| ); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Form makes API requests to empty endpoint
The
CodingAgentSettingsForm is missing anapiEndpointprop but hassaveOnBlurenabled. When theauto_create_prfield is blurred, the form attempts to POST to an empty endpoint. WhilegetData: () => ({})on line 143 prevents data from being sent, the API request still fires to an empty URL, which interferes with the intendedonChangehandler on line 146 that actually updates preferences. This explains why "the request stops happening in tests" as noted in the PR discussion.