Skip to content

Commit 5724162

Browse files
committed
Show Copilot reviewer, but still can't manage copilot reviewer
1 parent 7005774 commit 5724162

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/common/copilot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import { EventType, TimelineEvent } from './timelineEvent';
77

88
export const COPILOT_SWE_AGENT = 'copilot-swe-agent';
9+
export const COPILOT_REVIEWER = 'copilot-pull-request-reviewer';
10+
export const COPILOT_REVIEWER_ID = 'BOT_kgDOCnlnWA';
911

1012
export const COPILOT_LOGINS = [
11-
'copilot-pull-request-reviewer',
13+
COPILOT_REVIEWER,
1214
COPILOT_SWE_AGENT,
1315
'Copilot'
1416
];

src/github/quickPicks.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { Buffer } from 'buffer';
88
import * as vscode from 'vscode';
99
import { COPILOT_ACCOUNTS } from '../common/comment';
10-
import { COPILOT_LOGINS, COPILOT_SWE_AGENT } from '../common/copilot';
10+
import { COPILOT_REVIEWER, COPILOT_REVIEWER_ID, COPILOT_SWE_AGENT } from '../common/copilot';
1111
import { emojify, ensureEmojis } from '../common/emoji';
1212
import Logger from '../common/logger';
1313
import { DataUri } from '../common/uri';
@@ -152,7 +152,6 @@ function userThemeIcon(user: IAccount | ITeam) {
152152
async function getReviewersQuickPickItems(folderRepositoryManager: FolderRepositoryManager, remoteName: string, isInOrganization: boolean, author: IAccount, existingReviewers: ReviewState[],
153153
suggestedReviewers: ISuggestedReviewer[] | undefined, refreshKind: TeamReviewerRefreshKind,
154154
): Promise<(vscode.QuickPickItem & { user?: IAccount | ITeam })[]> {
155-
existingReviewers = existingReviewers.filter(reviewer => isITeam(reviewer.reviewer) || (reviewer.reviewer.accountType !== AccountType.Bot));
156155
if (!suggestedReviewers) {
157156
return [];
158157
}
@@ -164,26 +163,19 @@ async function getReviewersQuickPickItems(folderRepositoryManager: FolderReposit
164163

165164
// Remove the swe agent as it can't do reviews, but add the reviewer instead
166165
const originalAssignableUsers = allAssignableUsers[remoteName] ?? [];
167-
const hasCopilotSweAgent = originalAssignableUsers.some(user => user.login === COPILOT_SWE_AGENT);
168-
const assignableUsersForRemote = originalAssignableUsers.filter(user => user.login !== COPILOT_SWE_AGENT);
166+
let hasCopilotSweAgent: boolean = false;
167+
const assignableUsersForRemote = originalAssignableUsers.filter(user => {
168+
if (user.login === COPILOT_SWE_AGENT) {
169+
hasCopilotSweAgent = true;
170+
return false;
171+
}
172+
return true;
173+
});
169174

170175
if (assignableUsersForRemote) {
171176
assignableUsers.push(...assignableUsersForRemote);
172177
}
173178

174-
// If we removed the coding agent, add the Copilot reviewer instead
175-
if (hasCopilotSweAgent) {
176-
const copilotReviewer: IAccount = {
177-
login: COPILOT_LOGINS[0], // copilot-pull-request-reviewer
178-
id: '0',
179-
url: '',
180-
avatarUrl: '',
181-
name: COPILOT_ACCOUNTS[COPILOT_LOGINS[0]]?.name ?? 'Copilot',
182-
accountType: AccountType.User
183-
};
184-
assignableUsers.push(copilotReviewer);
185-
}
186-
187179
// used to track logins that shouldn't be added to pick list
188180
// e.g. author, existing and already added reviewers
189181
const skipList: Set<string> = new Set([
@@ -197,6 +189,19 @@ async function getReviewersQuickPickItems(folderRepositoryManager: FolderReposit
197189
reviewersPromises.push(getItems<IAccount | ITeam>(folderRepositoryManager.context, skipList, existingReviewers.map(reviewer => reviewer.reviewer), true));
198190
}
199191

192+
// If we removed the coding agent, add the Copilot reviewer instead
193+
if (hasCopilotSweAgent && !existingReviewers.find(user => (user.reviewer as IAccount).login === COPILOT_REVIEWER)) {
194+
const copilotReviewer: IAccount = {
195+
login: COPILOT_REVIEWER,
196+
id: COPILOT_REVIEWER_ID,
197+
url: '',
198+
avatarUrl: '',
199+
name: COPILOT_ACCOUNTS[COPILOT_REVIEWER]?.name ?? 'Copilot',
200+
accountType: AccountType.Bot
201+
};
202+
assignableUsers.push(copilotReviewer);
203+
}
204+
200205
// Suggested reviewers
201206
reviewersPromises.push(getItems<ISuggestedReviewer>(folderRepositoryManager.context, skipList, suggestedReviewers, false));
202207

0 commit comments

Comments
 (0)