Skip to content

Commit bc3e067

Browse files
authored
Do not create notifications for copilot PRs which are in progress (#8381)
* Do not create notifications for copilot PRs which are in progress Fixes #8380 * Copilot PR feedback * Fix test * Fix test
1 parent 3b1f20f commit bc3e067

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/github/copilotPrWatcher.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export class CopilotStateModel extends Disposable {
6969
continue;
7070
}
7171
this._states.set(key, { item, status });
72+
if (status === CopilotPRStatus.Started) {
73+
continue;
74+
}
7275
changedModels.push(item);
7376
changedKeys.push(key);
7477
}

src/test/github/copilotPrWatcher.test.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ describe('Copilot PR watcher', () => {
3131
model.set([{ item: pr, status: CopilotPRStatus.Started }]);
3232

3333
assert.strictEqual(model.get('octo', 'repo', 1), CopilotPRStatus.Started);
34-
assert.strictEqual(changeEvents, 1);
34+
assert.strictEqual(changeEvents, 0);
3535
assert.strictEqual(notifications.length, 0);
3636
assert.strictEqual(model.notifications.size, 0);
3737

3838
model.set([{ item: pr, status: CopilotPRStatus.Started }]);
39-
assert.strictEqual(changeEvents, 1);
39+
assert.strictEqual(changeEvents, 0);
4040

4141
model.setInitialized();
4242
const updated = createPullRequest('octo', 'repo', 1);
4343
model.set([{ item: updated, status: CopilotPRStatus.Completed }]);
4444

4545
assert.strictEqual(model.get('octo', 'repo', 1), CopilotPRStatus.Completed);
46-
assert.strictEqual(changeEvents, 2);
46+
assert.strictEqual(changeEvents, 1);
4747
assert.strictEqual(notifications.length, 1);
4848
assert.deepStrictEqual(notifications[0], [updated]);
4949
assert.ok(model.notifications.has('octo/repo#1'));
@@ -58,7 +58,7 @@ describe('Copilot PR watcher', () => {
5858

5959
model.setInitialized();
6060
const pr = createPullRequest('octo', 'repo', 42);
61-
model.set([{ item: pr, status: CopilotPRStatus.Started }]);
61+
model.set([{ item: pr, status: CopilotPRStatus.Completed }]);
6262

6363
assert.strictEqual(model.notifications.size, 1);
6464
assert.strictEqual(changeEvents, 1);
@@ -79,7 +79,7 @@ describe('Copilot PR watcher', () => {
7979

8080
model.setInitialized();
8181
const pr = createPullRequest('octo', 'repo', 5);
82-
model.set([{ item: pr, status: CopilotPRStatus.Started }]);
82+
model.set([{ item: pr, status: CopilotPRStatus.Completed }]);
8383
assert.strictEqual(model.notifications.size, 1);
8484
assert.strictEqual(notifications.length, 1);
8585

@@ -110,22 +110,18 @@ describe('Copilot PR watcher', () => {
110110
{ item: prThree, status: CopilotPRStatus.Completed }
111111
]);
112112

113-
assert.strictEqual(model.notifications.size, 3);
113+
assert.strictEqual(model.notifications.size, 2);
114114
assert.strictEqual(notifications.length, 1);
115-
assert.deepStrictEqual(notifications[0], [prOne, prTwo, prThree]);
116-
assert.strictEqual(model.getNotificationsCount('octo', 'repo'), 2);
115+
assert.deepStrictEqual(notifications[0], [prTwo, prThree]);
116+
assert.strictEqual(model.getNotificationsCount('octo', 'repo'), 1);
117117
assert.deepStrictEqual(model.keys().sort(), ['octo/repo#1', 'octo/repo#2', 'other/repo#3']);
118118

119119
model.clearAllNotifications('octo', 'repo');
120120
assert.strictEqual(model.notifications.size, 1);
121121
assert.strictEqual(model.getNotificationsCount('octo', 'repo'), 0);
122-
assert.strictEqual(notifications.length, 2);
123-
assert.deepStrictEqual(notifications[1], [prOne, prTwo]);
124122

125123
model.clearAllNotifications();
126124
assert.strictEqual(model.notifications.size, 0);
127-
assert.strictEqual(notifications.length, 3);
128-
assert.deepStrictEqual(notifications[2], [prThree]);
129125

130126
const counts = model.getCounts('octo', 'repo');
131127
assert.deepStrictEqual(counts, { total: 3, inProgress: 1, error: 1 });

0 commit comments

Comments
 (0)