Skip to content

Commit e48b945

Browse files
Copilotalexr00
andcommitted
Fix avatar display in tree views for GitHub Enterprise
- Add enterprise detection in PR tree views - Use github ThemeIcon placeholder for enterprise instead of fetching avatars - Update pullRequestNode, issuesView, commitNode, and repositoryChangesNode Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent f8e30e6 commit e48b945

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

src/issues/issuesView.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@ export class IssuesTreeData
101101
}
102102

103103
if (avatarUser) {
104-
treeItem.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.context, [avatarUser], 16, 16))[0] ??
105-
(element.isOpen
106-
? new vscode.ThemeIcon('issues', new vscode.ThemeColor('issues.open'))
107-
: new vscode.ThemeIcon('issue-closed', new vscode.ThemeColor('github.issues.closed')));
104+
// For enterprise, use placeholder icon instead of trying to fetch avatar
105+
if (element.githubRepository.remote.isEnterprise) {
106+
treeItem.iconPath = new vscode.ThemeIcon('github');
107+
} else {
108+
treeItem.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.context, [avatarUser], 16, 16))[0] ??
109+
(element.isOpen
110+
? new vscode.ThemeIcon('issues', new vscode.ThemeColor('issues.open'))
111+
: new vscode.ThemeIcon('issue-closed', new vscode.ThemeColor('github.issues.closed')));
112+
}
108113
} else {
109114
// Use GitHub codicon when assignee setting is selected but no assignees exist
110115
treeItem.iconPath = new vscode.ThemeIcon('github');

src/view/treeNodes/commitNode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ export class CommitNode extends TreeNode implements vscode.TreeItem {
4040

4141
async getTreeItem(): Promise<vscode.TreeItem> {
4242
if (this.commit.author) {
43-
const author: IAccount = { id: this.commit.author.node_id, login: this.commit.author.login, url: this.commit.author.url, avatarUrl: this.commit.author.avatar_url, accountType: this.commit.author.type as AccountType };
44-
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.pullRequestManager.context, [author], 16, 16))[0];
43+
// For enterprise, use placeholder icon instead of trying to fetch avatar
44+
if (this.pullRequest.githubRepository.remote.isEnterprise) {
45+
this.iconPath = new vscode.ThemeIcon('github');
46+
} else {
47+
const author: IAccount = { id: this.commit.author.node_id, login: this.commit.author.login, url: this.commit.author.url, avatarUrl: this.commit.author.avatar_url, accountType: this.commit.author.type as AccountType };
48+
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.pullRequestManager.context, [author], 16, 16))[0];
49+
}
4550
}
4651
return this;
4752
}

src/view/treeNodes/pullRequestNode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
274274
const copilotWorkingStatus = await this.pullRequestModel.copilotWorkingStatus();
275275
const theme = this._folderReposManager.themeWatcher.themeData;
276276
if (copilotWorkingStatus === CopilotWorkingStatus.NotCopilotIssue) {
277+
// For enterprise, use placeholder icon instead of trying to fetch avatar
278+
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
279+
return new vscode.ThemeIcon('github');
280+
}
277281
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
278282
?? new vscode.ThemeIcon('github');
279283
}
@@ -294,6 +298,10 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
294298
dark: DataUri.copilotErrorAsImageDataURI(getIconForeground(theme, 'dark'), getListErrorForeground(theme, 'dark'))
295299
};
296300
default:
301+
// For enterprise, use placeholder icon instead of trying to fetch avatar
302+
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
303+
return new vscode.ThemeIcon('github');
304+
}
297305
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
298306
?? new vscode.ThemeIcon('github');
299307
}

src/view/treeNodes/repositoryChangesNode.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ export class RepositoryChangesNode extends TreeNode implements vscode.TreeItem {
111111

112112
override async getTreeItem(): Promise<vscode.TreeItem> {
113113
this.setLabel();
114-
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this.pullRequestModel.author], 16, 16))[0];
114+
// For enterprise, use placeholder icon instead of trying to fetch avatar
115+
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
116+
this.iconPath = new vscode.ThemeIcon('github');
117+
} else {
118+
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this.pullRequestModel.author], 16, 16))[0];
119+
}
115120
this.description = undefined;
116121
if (this.parent.children?.length && this.parent.children.length > 1) {
117122
const allSameOwner = this.parent.children.every(child => {

0 commit comments

Comments
 (0)