-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(issues): collapse repetitive issue activity #121488
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
3 commits
Select commit
Hold shift + click to select a range
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
178 changes: 178 additions & 0 deletions
178
static/app/views/issueDetails/activitySection/activityLineItem/activityFeedItem.spec.ts
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 |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| import {ActivityFeedFixture} from 'sentry-fixture/activityFeed'; | ||
| import {UserFixture} from 'sentry-fixture/user'; | ||
|
|
||
| import {GroupActivityType, PriorityLevel} from 'sentry/types/group'; | ||
|
|
||
| import { | ||
| type ActivityFeedItem, | ||
| collapseFlappingStatusActivities, | ||
| type DisplayedActivityFeedItem, | ||
| } from './activityFeedItem'; | ||
|
|
||
| type ActivityFixtureParams = NonNullable<Parameters<typeof ActivityFeedFixture>[0]>; | ||
|
|
||
| function activity(params: ActivityFixtureParams): ActivityFeedItem { | ||
| return { | ||
| type: 'activity', | ||
| activity: {...ActivityFeedFixture(params), user: params.user ?? null}, | ||
| }; | ||
| } | ||
|
|
||
| function regression(): ActivityFeedItem { | ||
| return activity({type: GroupActivityType.SET_REGRESSION, data: {}}); | ||
| } | ||
|
|
||
| function resolved(): ActivityFeedItem { | ||
| return activity({type: GroupActivityType.SET_RESOLVED, data: {}}); | ||
| } | ||
|
|
||
| function ongoing(): ActivityFeedItem { | ||
| return activity({ | ||
| type: GroupActivityType.AUTO_SET_ONGOING, | ||
| data: {after_days: 7}, | ||
| }); | ||
| } | ||
|
|
||
| function resolvedByAge(): ActivityFeedItem { | ||
| return activity({type: GroupActivityType.SET_RESOLVED_BY_AGE, data: {age: 7}}); | ||
| } | ||
|
|
||
| function expectCollapsedActivities( | ||
| item: DisplayedActivityFeedItem | undefined, | ||
| expectedActivities: ActivityFeedItem[] | ||
| ) { | ||
| expect(item).toMatchObject({ | ||
| type: 'collapsed_status_activities', | ||
| activities: expectedActivities, | ||
| }); | ||
| } | ||
|
|
||
| describe('collapseFlappingStatusActivities', () => { | ||
| it('keeps the newest pair visible and merges adjacent older pairs into one rollup', () => { | ||
| const newestRegression = regression(); | ||
| const newestResolution = resolved(); | ||
| const olderRun = [ | ||
| activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.HIGH, reason: 'issue_platform'}, | ||
| }), | ||
| regression(), | ||
| resolved(), | ||
| ongoing(), | ||
| regression(), | ||
| resolved(), | ||
| ]; | ||
| const result = collapseFlappingStatusActivities([ | ||
| newestRegression, | ||
| newestResolution, | ||
| ...olderRun, | ||
| ]); | ||
|
|
||
| expect(result.slice(0, 2)).toEqual([newestRegression, newestResolution]); | ||
| expect(result).toHaveLength(3); | ||
| expectCollapsedActivities(result[2], olderRun); | ||
| }); | ||
|
|
||
| it('keeps the newest pair visible when newer user activity exists', () => { | ||
| const manualReopen = activity({ | ||
| type: GroupActivityType.SET_UNRESOLVED, | ||
| data: {}, | ||
| user: UserFixture(), | ||
| }); | ||
| const newestRun = [ongoing(), regression(), resolvedByAge()]; | ||
| const olderRun = [ongoing(), regression(), resolvedByAge()]; | ||
| const result = collapseFlappingStatusActivities([ | ||
| manualReopen, | ||
| ...newestRun, | ||
| ...olderRun, | ||
| ]); | ||
|
|
||
| expect(result.slice(0, 4)).toEqual([manualReopen, ...newestRun]); | ||
| expect(result).toHaveLength(5); | ||
| expectCollapsedActivities(result[4], olderRun); | ||
| }); | ||
|
|
||
| it('recognizes a resolved status transition', () => { | ||
| const newestPair = [regression(), resolved()]; | ||
| const flappingPair = [ | ||
| regression(), | ||
| activity({ | ||
| type: GroupActivityType.SET_RESOLVED_IN_RELEASE, | ||
| data: {version: '1.0.0'}, | ||
| }), | ||
| ]; | ||
| const result = collapseFlappingStatusActivities([...newestPair, ...flappingPair]); | ||
|
|
||
| expectCollapsedActivities(result[2], flappingPair); | ||
| }); | ||
|
|
||
| it('absorbs automatic lifecycle and priority activity into a flapping run', () => { | ||
| const automaticRun = [ | ||
| resolved(), | ||
| activity({type: GroupActivityType.SET_UNRESOLVED, data: {}}), | ||
| activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.HIGH, reason: 'issue_platform'}, | ||
| }), | ||
| ongoing(), | ||
| activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.MEDIUM, reason: 'ongoing'}, | ||
| }), | ||
| activity({type: GroupActivityType.SET_ESCALATING, data: {}}), | ||
| activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.HIGH, reason: 'escalating'}, | ||
| }), | ||
| regression(), | ||
| ]; | ||
| const result = collapseFlappingStatusActivities([ | ||
| activity({ | ||
| type: GroupActivityType.SET_UNRESOLVED, | ||
| data: {}, | ||
| user: UserFixture(), | ||
| }), | ||
| ...automaticRun, | ||
| ]); | ||
|
|
||
| expectCollapsedActivities(result[1], automaticRun); | ||
| }); | ||
|
|
||
| it('does not hide an incomplete automatic run', () => { | ||
| const activities = [ | ||
| resolved(), | ||
| ongoing(), | ||
| activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.MEDIUM, reason: 'ongoing'}, | ||
| }), | ||
| ]; | ||
|
|
||
| expect(collapseFlappingStatusActivities(activities)).toEqual(activities); | ||
| }); | ||
|
|
||
| it('keeps other priority activity as a boundary before an older rollup', () => { | ||
| const manualReopen = activity({ | ||
| type: GroupActivityType.SET_UNRESOLVED, | ||
| data: {}, | ||
| user: UserFixture(), | ||
| }); | ||
| const otherPriority = activity({ | ||
| type: GroupActivityType.SET_PRIORITY, | ||
| data: {priority: PriorityLevel.LOW, reason: 'other'}, | ||
| }); | ||
| const newerRun = [regression(), resolved()]; | ||
| const olderRun = [regression(), resolved()]; | ||
| const result = collapseFlappingStatusActivities([ | ||
| manualReopen, | ||
| ...newerRun, | ||
| otherPriority, | ||
| ...olderRun, | ||
| ]); | ||
|
|
||
| expect(result.slice(0, 3)).toEqual([manualReopen, ...newerRun]); | ||
| expect(result).toHaveLength(5); | ||
| expect(result[3]).toBe(otherPriority); | ||
| expectCollapsedActivities(result[4], olderRun); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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: The
collapseSeerActivityPairsfunction can insert aCollapsedSeerActivitybetween a regression/resolution pair, breaking the adjacency check incollapseFlappingStatusActivitiesand preventing flapping detection.Severity: MEDIUM
Suggested Fix
Modify
collapseFlappingStatusActivitiesto be robust against intervening activities. Instead of checking the immediately adjacent elementactivities[index+1], the logic should scan forward from aSET_REGRESSIONactivity to find the next relevant activity, skipping over others likeCollapsedSeerActivity, to see if it is aSET_RESOLVEDactivity.Prompt for AI Agent