Skip to content

Commit cacdfa6

Browse files
Copilotalexr00
andcommitted
Changes before error encountered
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent aadc0e4 commit cacdfa6

File tree

6 files changed

+82
-21
lines changed

6 files changed

+82
-21
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,10 @@
19901990
"command": "pr.dismissNotification",
19911991
"when": "false"
19921992
},
1993+
{
1994+
"command": "pr.markAllCopilotNotificationsAsRead",
1995+
"when": "false"
1996+
},
19931997
{
19941998
"command": "pr.resetViewedFiles",
19951999
"when": "github:inReviewMode"
@@ -2781,6 +2785,7 @@
27812785
{
27822786
"command": "pr.markAllCopilotNotificationsAsRead",
27832787
"when": "view == pr:github && viewItem =~ /copilot-query/",
2788+
"enablement": "viewItem == copilot-query-with-notifications",
27842789
"group": "0_category@1"
27852790
},
27862791
{

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
// version: 2
7+
68
declare module 'vscode' {
79
/**
810
* Represents the status of a chat session.
@@ -34,6 +36,13 @@ declare module 'vscode' {
3436
readonly onDidChangeChatSessionItems: Event<void>;
3537

3638
/**
39+
* Event that the provider can fire to signal that the current (original) chat session should be replaced with a new (modified) chat session.
40+
* The UI can use this information to gracefully migrate the user to the new session.
41+
*/
42+
readonly onDidCommitChatSessionItem: Event<{ original: ChatSessionItem /** untitled */; modified: ChatSessionItem /** newly created */ }>;
43+
44+
/**
45+
* DEPRECATED: Will be removed!
3746
* Creates a new chat session.
3847
*
3948
* @param options Options for the new session including an optional initial prompt and history
@@ -46,16 +55,6 @@ declare module 'vscode' {
4655
*/
4756
readonly request: ChatRequest;
4857

49-
/**
50-
* Initial prompt to initiate the session
51-
*/
52-
readonly prompt?: string;
53-
54-
/**
55-
* History to initialize the session with
56-
*/
57-
readonly history?: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
58-
5958
/**
6059
* Additional metadata to use for session creation
6160
*/
@@ -190,7 +189,16 @@ declare module 'vscode' {
190189
*
191190
* @returns A disposable that unregisters the provider when disposed.
192191
*/
193-
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, capabilities?: ChatSessionCapabilities): Disposable;
192+
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, chatParticipant: ChatParticipant, capabilities?: ChatSessionCapabilities): Disposable;
193+
}
194+
195+
export interface ChatContext {
196+
readonly chatSessionContext?: ChatSessionContext;
197+
}
198+
199+
export interface ChatSessionContext {
200+
readonly chatSessionItem: ChatSessionItem; // Maps to URI of chat session editor (could be 'untitled-1', etc..)
201+
readonly isUntitled: boolean;
194202
}
195203

196204
export interface ChatSessionCapabilities {

src/commands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,9 @@ export function registerCommands(
919919

920920
context.subscriptions.push(
921921
vscode.commands.registerCommand('pr.markAllCopilotNotificationsAsRead', node => {
922-
if (node instanceof CategoryTreeNode && node.isCopilot) {
923-
copilotRemoteAgentManager.clearAllNotifications();
922+
if (node instanceof CategoryTreeNode && node.isCopilot && node.folderRepoManager.gitHubRepositories.length > 0) {
923+
const repo = node.folderRepoManager.gitHubRepositories[0];
924+
copilotRemoteAgentManager.clearAllNotifications(repo.remote.owner, repo.remote.repositoryName);
924925
tree.refresh(node);
925926
}
926927
}),

src/github/copilotPrWatcher.ts

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

108-
clearAllNotifications(): void {
108+
clearAllNotifications(owner?: string, repo?: string): void {
109109
if (this._showNotification.size > 0) {
110110
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);
111+
112+
// If owner and repo are specified, only clear notifications for that repo
113+
if (owner && repo) {
114+
const keysToRemove: string[] = [];
115+
for (const key of this._showNotification.keys()) {
116+
if (key.startsWith(`${owner}/${repo}#`)) {
117+
const item = this._states.get(key)?.item;
118+
if (item) {
119+
items.push(item);
120+
}
121+
keysToRemove.push(key);
122+
}
123+
}
124+
keysToRemove.forEach(key => this._showNotification.delete(key));
125+
} else {
126+
// Clear all notifications
127+
for (const key of this._showNotification.keys()) {
128+
const item = this._states.get(key)?.item;
129+
if (item) {
130+
items.push(item);
131+
}
115132
}
133+
this._showNotification.clear();
116134
}
117-
this._showNotification.clear();
135+
118136
if (items.length > 0) {
119137
this._onDidChangeNotifications.fire(items);
120138
}

src/github/copilotRemoteAgent.ts

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

750-
public clearAllNotifications(): void {
751-
this._stateModel.clearAllNotifications();
750+
getNotificationsCountForRepo(owner: string, repo: string): number {
751+
let count = 0;
752+
const prefix = `${owner}/${repo}#`;
753+
for (const key of this._stateModel.notifications.keys()) {
754+
if (key.startsWith(prefix)) {
755+
count++;
756+
}
757+
}
758+
return count;
759+
}
760+
761+
public clearAllNotifications(owner?: string, repo?: string): void {
762+
this._stateModel.clearAllNotifications(owner, repo);
752763
}
753764

754765
hasNotification(owner: string, repo: string, pullRequestNumber: number): boolean {

src/view/treeNodes/categoryNode.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,24 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
327327

328328
getTreeItem(): vscode.TreeItem {
329329
this.description = this._getDescription();
330+
331+
// Update contextValue based on current notification state
332+
if (this._categoryQuery) {
333+
const hasNotifications = this.isCopilot && this._hasNotificationsForRepo();
334+
this.contextValue = this.isCopilot ?
335+
(hasNotifications ? 'copilot-query-with-notifications' : 'copilot-query') :
336+
'query';
337+
}
338+
330339
return this;
331340
}
341+
342+
private _hasNotificationsForRepo(): boolean {
343+
if (!this.isCopilot || this.folderRepoManager.gitHubRepositories.length === 0) {
344+
return false;
345+
}
346+
347+
const repo = this.folderRepoManager.gitHubRepositories[0];
348+
return this._copilotManager.getNotificationsCountForRepo(repo.remote.owner, repo.remote.repositoryName) > 0;
349+
}
332350
}

0 commit comments

Comments
 (0)