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
5 changes: 3 additions & 2 deletions src/common/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export interface IComment {

const COPILOT_AUTHOR = {
name: 'Copilot', // TODO: The copilot reviewer is a Bot, but per the graphQL schema, Bots don't have a name, just a login. We have it hardcoded here for now.
postComment: vscode.l10n.t('Copilot is powered by AI, so mistakes are possible. Review output carefully before use.')
postComment: vscode.l10n.t('Copilot is powered by AI, so mistakes are possible. Review output carefully before use.'),
url: 'https://github.com/apps/copilot-swe-agent'
};

export const COPILOT_ACCOUNTS: { [key: string]: { postComment: string, name: string } } =
export const COPILOT_ACCOUNTS: { [key: string]: { postComment: string, name: string, url: string } } =
Object.fromEntries(COPILOT_LOGINS.map(login => [login, COPILOT_AUTHOR]));
5 changes: 3 additions & 2 deletions src/github/prComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as path from 'path';
import * as vscode from 'vscode';
import { IComment } from '../common/comment';
import { COPILOT_ACCOUNTS, IComment } from '../common/comment';
import { emojify, ensureEmojis } from '../common/emoji';
import Logger from '../common/logger';
import { DataUri } from '../common/uri';
Expand Down Expand Up @@ -435,7 +435,8 @@ ${lineContents}
|| ((documentLanguage === 'php') && PHPDOC_NON_USERS.includes(username))) {
return substring;
}
return `${substring.startsWith('@') ? '' : substring.charAt(0)}[@${username}](${path.dirname(this.rawComment.user!.url)}/${username})`;
const url = COPILOT_ACCOUNTS[username]?.url ?? `${path.dirname(this.rawComment.user!.url)}/${username}`;
return `${substring.startsWith('@') ? '' : substring.charAt(0)}[@${username}](${url})`;
});

const permalinkReplaced = await this.replacePermalink(linkified);
Expand Down
7 changes: 4 additions & 3 deletions src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,19 +584,20 @@ function parseRef(refName: string, oid: string, repository?: GraphQL.RefReposito
}

export function parseAccount(
author: { login: string; url: string; avatarUrl: string; email?: string, id: string, name?: string, __typename: string } | { login: string; url: string; avatar_url: string; email?: string | null, node_id: string, name?: string | null, type: string } | null,
author: { login: string; url: string; avatarUrl: string; email?: string, id: string, name?: string, __typename: string } | { login: string; html_url: string; avatar_url: string; email?: string | null, node_id: string, name?: string | null, type: string } | null,
githubRepository?: GitHubRepository,
): IAccount {
if (author) {
const avatarUrl = 'avatarUrl' in author ? author.avatarUrl : author.avatar_url;
const id = 'node_id' in author ? author.node_id : author.id;
const url = 'html_url' in author ? author.html_url : author.url;
// In some places, Copilot comes in as a user, and in others as a bot
return {
login: author.login,
url: author.url,
url,
avatarUrl: githubRepository ? getAvatarWithEnterpriseFallback(avatarUrl, undefined, githubRepository.remote.isEnterprise) : avatarUrl,
email: author.email ?? undefined,
id: id,
id,
name: author.name ?? COPILOT_ACCOUNTS[author.login]?.name ?? undefined,
specialDisplayName: COPILOT_ACCOUNTS[author.login] ? (author.name ?? COPILOT_ACCOUNTS[author.login].name) : undefined,
accountType: toAccountType('__typename' in author ? author.__typename : author.type),
Expand Down