Skip to content

Commit f4cb0b9

Browse files
timrogersalexr00
andauthored
When copilot-swe-agent is the author of a comment, render with the Copilot identity (#6794)
* When `copilot-swe-agent` is the author of a comment, render with the Copilot identity With Project Padawan ([internal GitHub link](github/copilot#16237 blog link](https://github.blog/news-insights/product-news/github-copilot-the-agent-awakens/)) we're building an autonomous, asynchronous SWE agent integrated into issues and PRs on GitHub.com. You give Copilot a task by assigning an issue to Copilot via the normal issues UI - and under the hood, this is an assignment to a bot called `copilot-swe-agent`. You can then interact with the agent using pull request reviews - including the ability to `@mention` it as you can a human. As part of this, Copilot leaves comments. This shows comments from Copilot under the `Copilot` identity, rather than `copilot-swe-agent`, piggy-backing on logic built for Copilot code review (`copilot-pull-request-reviewer`). Relates to #6793. * Add Actor in all the queries --------- Co-authored-by: Alex Ross <[email protected]>
1 parent 36c1ec2 commit f4cb0b9

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

src/common/comment.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ export interface IComment {
7474
isResolved?: boolean;
7575
}
7676

77+
const COPILOT_AUTHOR = {
78+
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.
79+
postComment: vscode.l10n.t('Copilot is powered by AI, so mistakes are possible. Review output carefully before use.')
80+
};
81+
7782
export const SPECIAL_COMMENT_AUTHORS: { [key: string]: { postComment: string, name: string } } = {
78-
'copilot-pull-request-reviewer': {
79-
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.')
81-
}
83+
'copilot-pull-request-reviewer': COPILOT_AUTHOR,
84+
'copilot-swe-agent': COPILOT_AUTHOR,
85+
'Copilot': COPILOT_AUTHOR
8286
};

src/github/queries.gql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fragment IssueBase on Issue {
5252
title
5353
titleHTML
5454
author {
55+
...Actor
5556
...User
5657
...Organization
5758
}
@@ -66,6 +67,7 @@ fragment IssueBase on Issue {
6667
}
6768
assignees(first: 10) {
6869
nodes {
70+
...Actor
6971
...User
7072
}
7173
}
@@ -125,6 +127,7 @@ fragment PullRequestFragment on PullRequest {
125127
title
126128
titleHTML
127129
author {
130+
...Actor
128131
...User
129132
...Organization
130133
}
@@ -139,6 +142,7 @@ fragment PullRequestFragment on PullRequest {
139142
}
140143
assignees(first: 10) {
141144
nodes {
145+
...Actor
142146
...User
143147
}
144148
}
@@ -217,8 +221,8 @@ fragment PullRequestFragment on PullRequest {
217221
isAuthor
218222
isCommenter
219223
reviewer {
220-
...User
221224
...Actor
225+
...User
222226
...Node
223227
}
224228
}

src/github/queriesExtra.gql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fragment IssueBase on Issue {
5252
title
5353
titleHTML
5454
author {
55+
...Actor
5556
...User
5657
...Organization
5758
}
@@ -66,6 +67,7 @@ fragment IssueBase on Issue {
6667
}
6768
assignees(first: 10) {
6869
nodes {
70+
...Actor
6971
...User
7072
}
7173
}
@@ -134,6 +136,7 @@ fragment PullRequestFragment on PullRequest {
134136
title
135137
titleHTML
136138
author {
139+
...Actor
137140
...User
138141
...Organization
139142
}
@@ -148,6 +151,7 @@ fragment PullRequestFragment on PullRequest {
148151
}
149152
assignees(first: 10) {
150153
nodes {
154+
...Actor
151155
...User
152156
}
153157
}
@@ -235,8 +239,8 @@ fragment PullRequestFragment on PullRequest {
235239
isAuthor
236240
isCommenter
237241
reviewer {
238-
...User
239242
...Actor
243+
...User
240244
...Node
241245
}
242246
}

src/github/queriesLimited.gql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fragment IssueBase on Issue {
4141
title
4242
titleHTML
4343
author {
44+
...Actor
4445
...User
4546
...Organization
4647
}
@@ -55,6 +56,7 @@ fragment IssueBase on Issue {
5556
}
5657
assignees(first: 10) {
5758
nodes {
59+
...Actor
5860
...User
5961
}
6062
}
@@ -114,6 +116,7 @@ fragment PullRequestFragment on PullRequest {
114116
title
115117
titleHTML
116118
author {
119+
...Actor
117120
...User
118121
...Organization
119122
}
@@ -128,6 +131,7 @@ fragment PullRequestFragment on PullRequest {
128131
}
129132
assignees(first: 10) {
130133
nodes {
134+
...Actor
131135
...User
132136
}
133137
}
@@ -195,8 +199,8 @@ fragment PullRequestFragment on PullRequest {
195199
isAuthor
196200
isCommenter
197201
reviewer {
198-
...User
199202
...Actor
203+
...User
200204
...Node
201205
}
202206
}

src/github/queriesShared.gql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fragment Comment on IssueComment {
9090
databaseId
9191
authorAssociation
9292
author {
93+
...Actor
9394
...User
9495
...Organization
9596
}
@@ -108,6 +109,7 @@ fragment Commit on PullRequestCommit {
108109
commit {
109110
author {
110111
user {
112+
...Actor
111113
...User
112114
}
113115
}
@@ -129,6 +131,7 @@ fragment AssignedEvent on AssignedEvent {
129131
...Actor
130132
}
131133
user {
134+
...Actor
132135
...User
133136
}
134137
}
@@ -749,6 +752,7 @@ query GetMentionableUsers($owner: String!, $name: String!, $first: Int!, $after:
749752
repository(owner: $owner, name: $name) {
750753
mentionableUsers(first: $first, after: $after) {
751754
nodes {
755+
...Actor
752756
...User
753757
}
754758
pageInfo {
@@ -766,6 +770,7 @@ query GetAssignableUsers($owner: String!, $name: String!, $first: Int!, $after:
766770
repository(owner: $owner, name: $name) {
767771
assignableUsers(first: $first, after: $after) {
768772
nodes {
773+
...Actor
769774
...User
770775
}
771776
pageInfo {

src/github/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export function parseAccount(
589589
avatarUrl: githubRepository ? getAvatarWithEnterpriseFallback(avatarUrl, undefined, githubRepository.remote.isEnterprise) : avatarUrl,
590590
email: author.email ?? undefined,
591591
id: id,
592-
name: author.name ?? undefined,
592+
name: author.name ?? SPECIAL_COMMENT_AUTHORS[author.login]?.name ?? undefined,
593593
specialDisplayName: SPECIAL_COMMENT_AUTHORS[author.login] ? (author.name ?? SPECIAL_COMMENT_AUTHORS[author.login].name) : undefined,
594594
accountType: toAccountType('__typename' in author ? author.__typename : author.type),
595595
};

0 commit comments

Comments
 (0)