Skip to content

Commit 79d17e5

Browse files
authored
Coding agent: Unclear when (1) in GHPRI activity bar entry will go away (#7427)
Fixes #7277
1 parent 5a99d5d commit 79d17e5

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

src/github/copilotPrWatcher.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import { COPILOT_ACCOUNTS } from '../common/comment';
78
import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus } from '../common/copilot';
89
import { Disposable } from '../common/lifecycle';
910
import { PR_SETTINGS_NAMESPACE, QUERIES } from '../common/settingKeys';
1011
import { FolderRepositoryManager } from './folderRepositoryManager';
1112
import { PullRequestModel } from './pullRequestModel';
13+
import { PullRequestOverviewPanel } from './pullRequestOverview';
1214
import { RepositoriesManager } from './repositoriesManager';
1315
import { variableSubstitution } from './utils';
1416

@@ -77,10 +79,15 @@ export class CopilotStateModel extends Disposable {
7779
return Array.from(this._states.keys());
7880
}
7981

80-
clearNotifications(): void {
81-
const items = Array.from(this._showNotification).map(key => this._states.get(key)?.item).filter((item): item is PullRequestModel => !!item);
82-
this._showNotification.clear();
83-
this._onDidChangeNotifications.fire(items);
82+
clearNotification(owner: string, repo: string, prNumber: number): void {
83+
const key = this.makeKey(owner, repo, prNumber);
84+
if (this._showNotification.has(key)) {
85+
this._showNotification.delete(key);
86+
const item = this._states.get(key)?.item;
87+
if (item) {
88+
this._onDidChangeNotifications.fire([item]);
89+
}
90+
}
8491
}
8592

8693
get notifications(): ReadonlySet<string> {
@@ -133,6 +140,7 @@ export class CopilotPRWatcher extends Disposable {
133140
this._getStateChanges();
134141
this._pollForChanges();
135142
this._register(this._reposManager.onDidChangeAnyPullRequests(() => this._getStateChanges()));
143+
this._register(PullRequestOverviewPanel.onVisible(e => this._model.clearNotification(e.remote.owner, e.remote.repositoryName, e.number)));
136144

137145
this._register(vscode.workspace.onDidChangeConfiguration(e => {
138146
if (e.affectsConfiguration(`${PR_SETTINGS_NAMESPACE}.${QUERIES}`)) {
@@ -187,11 +195,14 @@ export class CopilotPRWatcher extends Disposable {
187195
for (const pr of prs?.items ?? []) {
188196
unseenKeys.delete(this._model.makeKey(pr.remote.owner, pr.remote.repositoryName, pr.number));
189197
const copilotEvents = await pr.getCopilotTimelineEvents(pr);
190-
if (copilotEvents.length === 0) {
191-
continue;
198+
let latestEvent = copilotEventToStatus(copilotEvents[copilotEvents.length - 1]);
199+
if (latestEvent === CopilotPRStatus.None) {
200+
if (!COPILOT_ACCOUNTS[pr.author.login]) {
201+
continue;
202+
}
203+
latestEvent = CopilotPRStatus.Started;
192204
}
193205
const lastStatus = this._model.get(pr.remote.owner, pr.remote.repositoryName, pr.number) ?? CopilotPRStatus.None;
194-
const latestEvent = copilotEventToStatus(copilotEvents[copilotEvents.length - 1]);
195206
if (latestEvent !== lastStatus) {
196207
stateChanges.push({
197208
owner: pr.remote.owner,

src/github/copilotRemoteAgent.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,6 @@ export class CopilotRemoteAgentManager extends Disposable {
739739
})[0];
740740
}
741741

742-
clearNotifications() {
743-
this._stateModel.clearNotifications();
744-
}
745-
746742
get notificationsCount(): number {
747743
return this._stateModel.notifications.size;
748744
}

src/view/prsTreeDataProvider.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
8383

8484
this._register(this._view.onDidChangeVisibility(e => {
8585
if (e.visible) {
86-
this._clearNotificationsWithDelay();
8786
// Sync with currently active PR when view becomes visible
8887
const currentPR = PullRequestOverviewPanel.getCurrentPullRequest();
8988
if (currentPR) {
@@ -102,6 +101,10 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
102101
});
103102

104103
this._register(this._copilotManager.onDidChangeStates(() => {
104+
this.refresh(undefined);
105+
}));
106+
107+
this._register(this._copilotManager.onDidChangeNotifications(() => {
105108
if (this._copilotManager.notificationsCount > 0) {
106109
this._view.badge = {
107110
tooltip: this._copilotManager.notificationsCount === 1 ? vscode.l10n.t('Coding agent has 1 pull request to view') : vscode.l10n.t('Coding agent has {0} pull requests to view', this._copilotManager.notificationsCount),
@@ -110,9 +113,6 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
110113
} else {
111114
this._view.badge = undefined;
112115
}
113-
114-
// also need to refresh the Copilot query category to update the status
115-
this.refresh(undefined);
116116
}));
117117

118118
this._register(this._copilotManager.onDidCreatePullRequest(() => this.refresh(undefined, true)));
@@ -171,18 +171,6 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
171171
}));
172172
}
173173

174-
private _clearNotificationsWithDelay() {
175-
if (this._notificationClearTimeout) {
176-
return;
177-
}
178-
// Clear notifications with a delay of 5 seconds)
179-
this._notificationClearTimeout = setTimeout(() => {
180-
this._copilotManager.clearNotifications();
181-
this._view.badge = undefined;
182-
this._notificationClearTimeout = undefined;
183-
}, 5000);
184-
}
185-
186174
public async expandPullRequest(pullRequest: PullRequestModel) {
187175
if (this._children.length === 0) {
188176
await this.getChildren();

0 commit comments

Comments
 (0)