diff --git a/src/sentry/seer/entrypoints/operator.py b/src/sentry/seer/entrypoints/operator.py index 1207db184111..74a4d14272e9 100644 --- a/src/sentry/seer/entrypoints/operator.py +++ b/src/sentry/seer/entrypoints/operator.py @@ -56,11 +56,7 @@ SentryAppEventType.SEER_SOLUTION_COMPLETED: ActivityType.SEER_SOLUTION_COMPLETED, SentryAppEventType.SEER_CODING_STARTED: ActivityType.SEER_CODING_STARTED, SentryAppEventType.SEER_CODING_COMPLETED: ActivityType.SEER_CODING_COMPLETED, -} - -SEER_OPERATOR_AUTOFIX_UPDATE_EVENTS: set[SentryAppEventType] = { - *SEER_EVENT_TO_ACTIVITY_TYPE.keys(), - SentryAppEventType.SEER_PR_CREATED, + SentryAppEventType.SEER_PR_CREATED: ActivityType.SEER_PR_CREATED, } logger = logging.getLogger(__name__) @@ -774,6 +770,10 @@ def _create_seer_activity( solution = event_payload.get("solution") if solution: activity_data["summary"] = solution.get("one_line_summary") + elif event_type == SentryAppEventType.SEER_PR_CREATED: + pull_requests = event_payload.get("pull_requests", []) + if pull_requests: + activity_data["pull_requests"] = pull_requests Activity.objects.create_group_activity( group, @@ -817,7 +817,7 @@ def process_autofix_updates( lifecycle.record_failure(failure_reason="missing_identifiers") return - if event_type not in SEER_OPERATOR_AUTOFIX_UPDATE_EVENTS: + if event_type not in SEER_EVENT_TO_ACTIVITY_TYPE: lifecycle.record_halt(halt_reason="skipped") return diff --git a/static/app/types/group.tsx b/static/app/types/group.tsx index 7a37423d011c..d2c2c27444e2 100644 --- a/static/app/types/group.tsx +++ b/static/app/types/group.tsx @@ -629,6 +629,7 @@ export const SEER_ACTIVITY_TYPES = new Set([ GroupActivityType.SEER_SOLUTION_COMPLETED, GroupActivityType.SEER_CODING_STARTED, GroupActivityType.SEER_CODING_COMPLETED, + GroupActivityType.SEER_PR_CREATED, ]); interface GroupActivityBase { diff --git a/static/app/views/issueDetails/activitySection/index.spec.tsx b/static/app/views/issueDetails/activitySection/index.spec.tsx index 7f062890f338..88111caf156c 100644 --- a/static/app/views/issueDetails/activitySection/index.spec.tsx +++ b/static/app/views/issueDetails/activitySection/index.spec.tsx @@ -597,7 +597,7 @@ describe('ActivitySection', () => { ).not.toBeInTheDocument(); }); - it('renders Seer PR created activity with link', async () => { + it('does not render Seer PR created activity in timeline', () => { const seerPrGroup = GroupFixture({ id: '1344', activity: [ @@ -627,11 +627,6 @@ describe('ActivitySection', () => { const org = OrganizationFixture({features: ['seer-activity-timeline']}); render(, {organization: org}); - expect(await screen.findByText('Pull Request Created')).toBeInTheDocument(); - expect(screen.getByRole('link', {name: 'pull request'})).toHaveAttribute( - 'href', - 'https://github.com/org/repo/pull/42' - ); - expect(screen.getByText(/org\/repo/)).toBeInTheDocument(); + expect(screen.queryByText('Pull Request Created')).not.toBeInTheDocument(); }); }); diff --git a/static/app/views/issueDetails/activitySection/index.tsx b/static/app/views/issueDetails/activitySection/index.tsx index d20de74b4544..2841bd368d19 100644 --- a/static/app/views/issueDetails/activitySection/index.tsx +++ b/static/app/views/issueDetails/activitySection/index.tsx @@ -373,7 +373,7 @@ export function ActivitySection({ const showSeerActivities = organization.features.includes('seer-activity-timeline'); const visibleActivities = showSeerActivities - ? group.activity + ? group.activity.filter(item => item.type !== GroupActivityType.SEER_PR_CREATED) : group.activity.filter(item => !SEER_ACTIVITY_TYPES.has(item.type)); const filteredActivities = visibleActivities.filter( diff --git a/tests/sentry/seer/entrypoints/test_operator.py b/tests/sentry/seer/entrypoints/test_operator.py index 6781a1ee95dc..7993c641a41c 100644 --- a/tests/sentry/seer/entrypoints/test_operator.py +++ b/tests/sentry/seer/entrypoints/test_operator.py @@ -935,6 +935,37 @@ def test_create_seer_activity_feature_flag_disabled(self, _mock_has_access): seer_type_values = [t.value for t in SEER_EVENT_TO_ACTIVITY_TYPE.values()] assert not Activity.objects.filter(group=self.group, type__in=seer_type_values).exists() + @patch.object(SeerAutofixOperator, "has_access", return_value=True) + def test_create_seer_activity_pr_created_with_pull_requests(self, _mock_has_access): + event_payload = { + "run_id": MOCK_RUN_ID, + "group_id": self.group.id, + "pull_requests": [ + { + "pull_request": { + "pr_number": 42, + "pr_url": "https://github.com/owner/repo/pull/42", + }, + "repo_name": "owner/repo", + "provider": "github", + } + ], + } + + with self.feature("organizations:seer-activity-timeline"): + process_autofix_updates( + event_type=SentryAppEventType.SEER_PR_CREATED, + event_payload=event_payload, + organization_id=self.organization.id, + ) + + activity = Activity.objects.get(group=self.group, type=ActivityType.SEER_PR_CREATED.value) + assert activity.data["pull_requests"][0]["repo_name"] == "owner/repo" + assert ( + activity.data["pull_requests"][0]["pull_request"]["pr_url"] + == "https://github.com/owner/repo/pull/42" + ) + class TestGetAutofixExplorerStatus(TestCase): @staticmethod