Skip to content

Commit 7265672

Browse files
Copilotalexr00
andauthored
Add issue avatar display option for assignees in GitHub Issues view (#7867)
* Initial plan * Initial plan: Add avatar option for assignee instead of creator in issue list Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Implement avatar option for assignee instead of creator in issue list Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Optimize configuration key string concatenation for better performance Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Address code review feedback: remove unnecessary constant, use GitHub codicon instead of fallback, remove tests Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Simplify --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 3071d50 commit 7265672

4 files changed

Lines changed: 49 additions & 4 deletions

File tree

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,19 @@
744744
"default": true,
745745
"description": "%githubIssues.assignWhenWorking.description%"
746746
},
747+
"githubIssues.issueAvatarDisplay": {
748+
"type": "string",
749+
"enum": [
750+
"author",
751+
"assignee"
752+
],
753+
"enumDescriptions": [
754+
"%githubIssues.issueAvatarDisplay.author%",
755+
"%githubIssues.issueAvatarDisplay.assignee%"
756+
],
757+
"default": "author",
758+
"description": "%githubIssues.issueAvatarDisplay.description%"
759+
},
747760
"githubPullRequests.focusedMode": {
748761
"properties": {
749762
"oneOf": [

package.nls.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@
149149
"githubIssues.queries.default.createdIssues": "Created Issues",
150150
"githubIssues.queries.default.recentIssues": "Recent Issues",
151151
"githubIssues.assignWhenWorking.description": "Assigns the issue you're working on to you. Only applies when the issue you're working on is in a repo you currently have open.",
152+
"githubIssues.issueAvatarDisplay.description": "Controls which avatar to display in the issue list.",
153+
"githubIssues.issueAvatarDisplay.author": "Show the avatar of the issue creator",
154+
"githubIssues.issueAvatarDisplay.assignee": "Show the avatar of the first assignee (show GitHub icon if no assignees)",
152155
"githubPullRequests.focusedMode.description": "The layout to use when a pull request is checked out. Set to false to prevent layout changes.",
153156
"githubPullRequests.focusedMode.firstDiff": "Show the first diff in the pull request. If there are no changes, show the overview.",
154157
"githubPullRequests.focusedMode.overview": "Show the overview of the pull request.",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const DEFAULT = 'default';
5454
export const IGNORE_MILESTONES = 'ignoreMilestones';
5555
export const ALLOW_FETCH = 'allowFetch';
5656
export const ALWAYS_PROMPT_FOR_NEW_ISSUE_REPO = 'alwaysPromptForNewIssueRepo';
57+
export const ISSUE_AVATAR_DISPLAY = 'issueAvatarDisplay';
5758
export const EXPERIMENTAL_CHAT = 'experimental.chat';
5859
export const EXPERIMENTAL_USE_QUICK_CHAT = 'experimental.useQuickChat';
5960
export const EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE = 'experimental.notificationsViewPageSize';

src/issues/issuesView.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import * as path from 'path';
77
import * as vscode from 'vscode';
88
import { commands, contexts } from '../common/executeCommands';
9+
import { ISSUE_AVATAR_DISPLAY, ISSUES_SETTINGS_NAMESPACE } from '../common/settingKeys';
910
import { DataUri } from '../common/uri';
1011
import { groupBy } from '../common/utils';
1112
import { FolderRepositoryManager, ReposManagerState } from '../github/folderRepositoryManager';
13+
import { IAccount } from '../github/interface';
1214
import { IssueModel } from '../github/issueModel';
1315
import { issueMarkdown } from '../github/markdownUtils';
1416
import { RepositoriesManager } from '../github/repositoriesManager';
@@ -59,6 +61,15 @@ export class IssuesTreeData
5961
this._onDidChangeTreeData.fire();
6062
}),
6163
);
64+
65+
// Listen for changes to the avatar display setting
66+
context.subscriptions.push(
67+
vscode.workspace.onDidChangeConfiguration(change => {
68+
if (change.affectsConfiguration(`${ISSUES_SETTINGS_NAMESPACE}.${ISSUE_AVATAR_DISPLAY}`)) {
69+
this._onDidChangeTreeData.fire();
70+
}
71+
}),
72+
);
6273
}
6374

6475
private getFolderRepoItem(element: FolderRepositoryManager): vscode.TreeItem {
@@ -77,10 +88,27 @@ export class IssuesTreeData
7788

7889
private async getIssueTreeItem(element: IssueItem): Promise<vscode.TreeItem> {
7990
const treeItem = new vscode.TreeItem(element.title, vscode.TreeItemCollapsibleState.None);
80-
treeItem.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.context, [element.author], 16, 16))[0] ??
81-
(element.isOpen
82-
? new vscode.ThemeIcon('issues', new vscode.ThemeColor('issues.open'))
83-
: new vscode.ThemeIcon('issue-closed', new vscode.ThemeColor('issues.closed')));
91+
92+
const avatarDisplaySetting = vscode.workspace
93+
.getConfiguration(ISSUES_SETTINGS_NAMESPACE, null)
94+
.get<'author' | 'assignee'>(ISSUE_AVATAR_DISPLAY, 'author');
95+
96+
let avatarUser: IAccount | undefined;
97+
if ((avatarDisplaySetting === 'assignee') && element.assignees && (element.assignees.length > 0)) {
98+
avatarUser = element.assignees[0];
99+
} else if (avatarDisplaySetting === 'author') {
100+
avatarUser = element.author;
101+
}
102+
103+
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('issues.closed')));
108+
} else {
109+
// Use GitHub codicon when assignee setting is selected but no assignees exist
110+
treeItem.iconPath = new vscode.ThemeIcon('github');
111+
}
84112

85113
treeItem.command = {
86114
command: 'issue.openDescription',

0 commit comments

Comments
 (0)