|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import * as vscode from 'vscode';
|
| 7 | +import { COPILOT_ACCOUNTS } from '../common/comment'; |
7 | 8 | import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus } from '../common/copilot';
|
8 | 9 | import { Disposable } from '../common/lifecycle';
|
9 | 10 | import { PR_SETTINGS_NAMESPACE, QUERIES } from '../common/settingKeys';
|
10 | 11 | import { FolderRepositoryManager } from './folderRepositoryManager';
|
11 | 12 | import { PullRequestModel } from './pullRequestModel';
|
| 13 | +import { PullRequestOverviewPanel } from './pullRequestOverview'; |
12 | 14 | import { RepositoriesManager } from './repositoriesManager';
|
13 | 15 | import { variableSubstitution } from './utils';
|
14 | 16 |
|
@@ -77,10 +79,15 @@ export class CopilotStateModel extends Disposable {
|
77 | 79 | return Array.from(this._states.keys());
|
78 | 80 | }
|
79 | 81 |
|
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 | + } |
84 | 91 | }
|
85 | 92 |
|
86 | 93 | get notifications(): ReadonlySet<string> {
|
@@ -133,6 +140,7 @@ export class CopilotPRWatcher extends Disposable {
|
133 | 140 | this._getStateChanges();
|
134 | 141 | this._pollForChanges();
|
135 | 142 | this._register(this._reposManager.onDidChangeAnyPullRequests(() => this._getStateChanges()));
|
| 143 | + this._register(PullRequestOverviewPanel.onVisible(e => this._model.clearNotification(e.remote.owner, e.remote.repositoryName, e.number))); |
136 | 144 |
|
137 | 145 | this._register(vscode.workspace.onDidChangeConfiguration(e => {
|
138 | 146 | if (e.affectsConfiguration(`${PR_SETTINGS_NAMESPACE}.${QUERIES}`)) {
|
@@ -187,11 +195,14 @@ export class CopilotPRWatcher extends Disposable {
|
187 | 195 | for (const pr of prs?.items ?? []) {
|
188 | 196 | unseenKeys.delete(this._model.makeKey(pr.remote.owner, pr.remote.repositoryName, pr.number));
|
189 | 197 | 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; |
192 | 204 | }
|
193 | 205 | const lastStatus = this._model.get(pr.remote.owner, pr.remote.repositoryName, pr.number) ?? CopilotPRStatus.None;
|
194 |
| - const latestEvent = copilotEventToStatus(copilotEvents[copilotEvents.length - 1]); |
195 | 206 | if (latestEvent !== lastStatus) {
|
196 | 207 | stateChanges.push({
|
197 | 208 | owner: pr.remote.owner,
|
|
0 commit comments