Skip to content

Commit e322622

Browse files
Copilotalexr00
andcommitted
Add support for merged events and bot filtering in notifications
- Add EventType.Merged as a meaningful event in _getMeaningfulEventTime - Filter out bot accounts (AccountType.Bot) from meaningful events - Filter out users with [bot] suffix or vs-code-engineering username - This fixes the issue where merged PRs by the current user don't get marked as done Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent fd1e0dd commit e322622

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

src/notifications/notificationsManager.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { NOTIFICATION_SETTING, NotificationVariants, PR_SETTINGS_NAMESPACE } fro
1313
import { EventType, TimelineEvent } from '../common/timelineEvent';
1414
import { toNotificationUri } from '../common/uri';
1515
import { CredentialStore } from '../github/credentials';
16-
import { NotificationSubjectType } from '../github/interface';
16+
import { AccountType, NotificationSubjectType } from '../github/interface';
1717
import { IssueModel } from '../github/issueModel';
1818
import { issueMarkdown } from '../github/markdownUtils';
1919
import { PullRequestModel } from '../github/pullRequestModel';
@@ -332,21 +332,39 @@ export class NotificationsManager extends Disposable implements vscode.TreeDataP
332332
}
333333
};
334334

335+
// Helper to check if a user is a bot
336+
const isBot = (user: { login: string, accountType?: AccountType }): boolean => {
337+
// Check if accountType indicates this is a bot
338+
if (user.accountType === AccountType.Bot) {
339+
return true;
340+
}
341+
// Check for common bot naming patterns
342+
if (user.login.endsWith('[bot]') || user.login === 'vs-code-engineering') {
343+
return true;
344+
}
345+
return false;
346+
};
347+
335348
if (event.event === EventType.Committed) {
336-
if (userCheck(event.author.login)) {
349+
if (!isBot(event.author) && userCheck(event.author.login)) {
337350
return new Date(event.committedDate);
338351
}
339352
} else if (event.event === EventType.Commented) {
340-
if (userCheck(event.user?.login)) {
353+
if (event.user && !isBot(event.user) && userCheck(event.user.login)) {
341354
return new Date(event.createdAt);
342355
}
343356
} else if (event.event === EventType.Reviewed) {
344357
// We only count empty reviews as meaningful if the user is the current user
345358
if (isCurrentUser || (event.comments.length > 0 || event.body.length > 0)) {
346-
if (userCheck(event.user?.login)) {
359+
if (event.user && !isBot(event.user) && userCheck(event.user.login)) {
347360
return new Date(event.submittedAt);
348361
}
349362
}
363+
} else if (event.event === EventType.Merged) {
364+
// Merging a PR is a meaningful event
365+
if (userCheck(event.user.login)) {
366+
return new Date(event.createdAt);
367+
}
350368
}
351369
}
352370

0 commit comments

Comments
 (0)