diff --git a/src/common/comment.ts b/src/common/comment.ts index 079fd8791d..0fb87a1185 100644 --- a/src/common/comment.ts +++ b/src/common/comment.ts @@ -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])); \ No newline at end of file diff --git a/src/github/prComment.ts b/src/github/prComment.ts index c31fce3ecf..e68dc840c9 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -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'; @@ -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); diff --git a/src/github/utils.ts b/src/github/utils.ts index c861df7714..ab13ab83b8 100644 --- a/src/github/utils.ts +++ b/src/github/utils.ts @@ -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),