Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/sentry/seer/entrypoints/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions static/app/types/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ export const SEER_ACTIVITY_TYPES = new Set<GroupActivityType>([
GroupActivityType.SEER_SOLUTION_COMPLETED,
GroupActivityType.SEER_CODING_STARTED,
GroupActivityType.SEER_CODING_COMPLETED,
GroupActivityType.SEER_PR_CREATED,
]);

interface GroupActivityBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -627,11 +627,6 @@ describe('ActivitySection', () => {
const org = OrganizationFixture({features: ['seer-activity-timeline']});

render(<ActivitySection group={seerPrGroup} />, {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();
});
});
2 changes: 1 addition & 1 deletion static/app/views/issueDetails/activitySection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filter out SEER_PR_CREATED from the issue details activity timeline - show SET_RESOLVED_IN_PULL_REQUEST only instead

: group.activity.filter(item => !SEER_ACTIVITY_TYPES.has(item.type));

const filteredActivities = visibleActivities.filter(
Expand Down
31 changes: 31 additions & 0 deletions tests/sentry/seer/entrypoints/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading