Skip to content

Commit 306a496

Browse files
committed
Implement Mark All as Read feature for Copilot notifications
1 parent 14dd356 commit 306a496

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,11 @@
935935
"title": "%command.pr.dismissNotification.title%",
936936
"category": "%command.pull.request.category%"
937937
},
938+
{
939+
"command": "pr.markAllCopilotNotificationsAsRead",
940+
"title": "Mark All as Read",
941+
"category": "%command.pull.request.category%"
942+
},
938943
{
939944
"command": "pr.merge",
940945
"title": "%command.pr.merge.title%",
@@ -2773,6 +2778,11 @@
27732778
"when": "view == pr:github && viewItem =~ /pullrequest(.*):notification/",
27742779
"group": "4_pullrequest@5"
27752780
},
2781+
{
2782+
"command": "pr.markAllCopilotNotificationsAsRead",
2783+
"when": "view == pr:github && viewItem =~ /copilot-query/",
2784+
"group": "0_category@1"
2785+
},
27762786
{
27772787
"command": "issue.chatSummarizeIssue",
27782788
"when": "view == pr:github && viewItem =~ /pullrequest/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat",

src/commands.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,15 @@ export function registerCommands(
917917
}),
918918
);
919919

920+
context.subscriptions.push(
921+
vscode.commands.registerCommand('pr.markAllCopilotNotificationsAsRead', node => {
922+
if (node instanceof CategoryTreeNode && node.isCopilot) {
923+
copilotRemoteAgentManager.clearAllNotifications();
924+
tree.refresh(node);
925+
}
926+
}),
927+
);
928+
920929
async function openDescriptionCommand(argument: RepositoryChangesNode | PRNode | IssueModel | ChatSessionWithPR | undefined) {
921930
let issueModel: IssueModel | undefined;
922931
if (!argument) {

src/github/copilotPrWatcher.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ export class CopilotStateModel extends Disposable {
105105
}
106106
}
107107

108+
clearAllNotifications(): void {
109+
if (this._showNotification.size > 0) {
110+
const items: PullRequestModel[] = [];
111+
for (const key of this._showNotification.keys()) {
112+
const item = this._states.get(key)?.item;
113+
if (item) {
114+
items.push(item);
115+
}
116+
}
117+
this._showNotification.clear();
118+
if (items.length > 0) {
119+
this._onDidChangeNotifications.fire(items);
120+
}
121+
}
122+
}
123+
108124
get notifications(): ReadonlySet<string> {
109125
return this._showNotification;
110126
}

src/github/copilotRemoteAgent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ export class CopilotRemoteAgentManager extends Disposable {
747747
return this._stateModel.notifications.size;
748748
}
749749

750+
public clearAllNotifications(): void {
751+
this._stateModel.clearAllNotifications();
752+
}
753+
750754
hasNotification(owner: string, repo: string, pullRequestNumber: number): boolean {
751755
const key = this._stateModel.makeKey(owner, repo, pullRequestNumber);
752756
return this._stateModel.notifications.has(key);

src/view/treeNodes/categoryNode.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
183183

184184
if (this._categoryQuery) {
185185
this.contextValue = 'query';
186+
if (this.isCopilot) {
187+
this.contextValue = 'copilot-query';
188+
}
186189
}
187190

188191
if (this.isCopilot) {

0 commit comments

Comments
 (0)