Skip to content

Commit d50751a

Browse files
authored
Fix constructed copilot user url in comment links (#6885)
Part of #6868
1 parent c2ca72a commit d50751a

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/common/comment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ export interface IComment {
7777

7878
const COPILOT_AUTHOR = {
7979
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.
80-
postComment: vscode.l10n.t('Copilot is powered by AI, so mistakes are possible. Review output carefully before use.')
80+
postComment: vscode.l10n.t('Copilot is powered by AI, so mistakes are possible. Review output carefully before use.'),
81+
url: 'https://github.com/apps/copilot-swe-agent'
8182
};
8283

83-
export const COPILOT_ACCOUNTS: { [key: string]: { postComment: string, name: string } } =
84+
export const COPILOT_ACCOUNTS: { [key: string]: { postComment: string, name: string, url: string } } =
8485
Object.fromEntries(COPILOT_LOGINS.map(login => [login, COPILOT_AUTHOR]));

src/github/prComment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as path from 'path';
77
import * as vscode from 'vscode';
8-
import { IComment } from '../common/comment';
8+
import { COPILOT_ACCOUNTS, IComment } from '../common/comment';
99
import { emojify, ensureEmojis } from '../common/emoji';
1010
import Logger from '../common/logger';
1111
import { DataUri } from '../common/uri';
@@ -435,7 +435,8 @@ ${lineContents}
435435
|| ((documentLanguage === 'php') && PHPDOC_NON_USERS.includes(username))) {
436436
return substring;
437437
}
438-
return `${substring.startsWith('@') ? '' : substring.charAt(0)}[@${username}](${path.dirname(this.rawComment.user!.url)}/${username})`;
438+
const url = COPILOT_ACCOUNTS[username]?.url ?? `${path.dirname(this.rawComment.user!.url)}/${username}`;
439+
return `${substring.startsWith('@') ? '' : substring.charAt(0)}[@${username}](${url})`;
439440
});
440441

441442
const permalinkReplaced = await this.replacePermalink(linkified);

src/github/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,19 +584,20 @@ function parseRef(refName: string, oid: string, repository?: GraphQL.RefReposito
584584
}
585585

586586
export function parseAccount(
587-
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,
587+
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,
588588
githubRepository?: GitHubRepository,
589589
): IAccount {
590590
if (author) {
591591
const avatarUrl = 'avatarUrl' in author ? author.avatarUrl : author.avatar_url;
592592
const id = 'node_id' in author ? author.node_id : author.id;
593+
const url = 'html_url' in author ? author.html_url : author.url;
593594
// In some places, Copilot comes in as a user, and in others as a bot
594595
return {
595596
login: author.login,
596-
url: author.url,
597+
url,
597598
avatarUrl: githubRepository ? getAvatarWithEnterpriseFallback(avatarUrl, undefined, githubRepository.remote.isEnterprise) : avatarUrl,
598599
email: author.email ?? undefined,
599-
id: id,
600+
id,
600601
name: author.name ?? COPILOT_ACCOUNTS[author.login]?.name ?? undefined,
601602
specialDisplayName: COPILOT_ACCOUNTS[author.login] ? (author.name ?? COPILOT_ACCOUNTS[author.login].name) : undefined,
602603
accountType: toAccountType('__typename' in author ? author.__typename : author.type),

0 commit comments

Comments
 (0)