Skip to content

Commit f393f24

Browse files
authored
Use new copilot status icons (#7121)
Fixes microsoft/vscode-copilot#18537
1 parent f0e2e51 commit f393f24

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

src/github/githubRepository.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ export interface GraphQLError {
146146
message?: string;
147147
}
148148

149+
export enum CopilotWorkingStatus {
150+
NotCopilotIssue = 'NotCopilotIssue',
151+
InProgress = 'InProgress',
152+
Error = 'Error',
153+
Done = 'Done',
154+
}
155+
149156
export class GitHubRepository extends Disposable {
150157
static ID = 'GitHubRepository';
151158
protected _initialized: boolean = false;
@@ -1527,6 +1534,21 @@ export class GitHubRepository extends Disposable {
15271534
}
15281535
}
15291536

1537+
async copilotWorkingStatus(issueModel: IssueModel): Promise<CopilotWorkingStatus | undefined> {
1538+
const copilotEvents = await this.getCopilotTimelineEvents(issueModel);
1539+
if (copilotEvents.length > 0) {
1540+
const lastEvent = copilotEvents[copilotEvents.length - 1];
1541+
if (lastEvent.event === Common.EventType.CopilotFinished) {
1542+
return CopilotWorkingStatus.Done;
1543+
} else if (lastEvent.event === Common.EventType.CopilotStarted) {
1544+
return CopilotWorkingStatus.InProgress;
1545+
} else if (lastEvent.event === Common.EventType.CopilotFinishedError) {
1546+
return CopilotWorkingStatus.Error;
1547+
}
1548+
}
1549+
return CopilotWorkingStatus.NotCopilotIssue;
1550+
}
1551+
15301552
/**
15311553
* Get the status checks of the pull request, those for the last commit.
15321554
*

src/view/treeNodes/pullRequestNode.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Logger from '../../common/logger';
1111
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE, SHOW_PULL_REQUEST_NUMBER_IN_TREE } from '../../common/settingKeys';
1212
import { createPRNodeUri, DataUri, fromPRUri, Schemes } from '../../common/uri';
1313
import { FolderRepositoryManager } from '../../github/folderRepositoryManager';
14+
import { CopilotWorkingStatus } from '../../github/githubRepository';
1415
import { NotificationProvider } from '../../github/notifications';
1516
import { IResolvedPullRequestModel, PullRequestModel } from '../../github/pullRequestModel';
1617
import { InMemFileChangeModel, RemoteFileChangeModel } from '../fileChangeModel';
@@ -259,6 +260,23 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
259260
});
260261
}
261262

263+
private async _getIcon(): Promise<vscode.Uri | vscode.ThemeIcon> {
264+
const copilotWorkingStatus = await this.pullRequestModel.githubRepository.copilotWorkingStatus(this.pullRequestModel);
265+
switch (copilotWorkingStatus) {
266+
case CopilotWorkingStatus.InProgress:
267+
return new vscode.ThemeIcon('copilot-in-progress');
268+
case CopilotWorkingStatus.Done:
269+
return new vscode.ThemeIcon('copilot-success');
270+
case CopilotWorkingStatus.Error:
271+
return new vscode.ThemeIcon('copilot-error');
272+
case CopilotWorkingStatus.NotCopilotIssue:
273+
default:
274+
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
275+
?? new vscode.ThemeIcon('github');
276+
277+
}
278+
}
279+
262280
async getTreeItem(): Promise<vscode.TreeItem> {
263281
const currentBranchIsForThisPR = this.pullRequestModel.equals(this._folderReposManager.activePullRequest);
264282

@@ -298,8 +316,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
298316
(currentBranchIsForThisPR ? ':active' : ':nonactive') +
299317
(hasNotification ? ':notification' : '') +
300318
(((this.pullRequestModel.item.isRemoteHeadDeleted && !this._isLocal) || !this._folderReposManager.isPullRequestAssociatedWithOpenRepository(this.pullRequestModel)) ? '' : ':hasHeadRef'),
301-
iconPath: (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
302-
?? new vscode.ThemeIcon('github'),
319+
iconPath: await this._getIcon(),
303320
accessibilityInformation: {
304321
label: `${isDraft ? 'Draft ' : ''}Pull request number ${formattedPRNumber}: ${title} by ${login}`
305322
},

0 commit comments

Comments
 (0)