Skip to content

Commit 2290ec2

Browse files
authored
Commenting on a coding agent PR doesn't refresh timeline (#7195)
Fixes #7193
1 parent 54dc08b commit 2290ec2

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

src/github/activityBarViewProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
364364
this.updateReviewers(review);
365365
const reviewMessage: SubmitReviewReply & { command: string } = {
366366
command: 'pr.append-review',
367-
event: review,
368-
reviewers: this._existingReviewers
367+
events: [],
368+
reviewers: this._existingReviewers,
369+
reviewedEvent: review,
369370
};
370371
await this._postMessage(reviewMessage);
371372
} catch (e) {
@@ -380,7 +381,8 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
380381
const review = await action(message.args);
381382
this.updateReviewers(review);
382383
const reviewMessage: SubmitReviewReply = {
383-
event: review,
384+
events: [],
385+
reviewedEvent: review,
384386
reviewers: this._existingReviewers,
385387
};
386388
this._replyMessage(message, reviewMessage);

src/github/issueOverview.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { GithubItemStateEnum, IAccount, ILabel, IMilestone, IProject, IProjectIt
1919
import { IssueModel } from './issueModel';
2020
import { getAssigneesQuickPickItems, getLabelOptions, getMilestoneFromQuickPick, getProjectFromQuickPick } from './quickPicks';
2121
import { isInCodespaces, vscodeDevPrLink } from './utils';
22-
import { ChangeAssigneesReply, Issue, ProjectItemsReply } from './views';
22+
import { ChangeAssigneesReply, Issue, ProjectItemsReply, SubmitReviewReply } from './views';
2323

2424
export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends WebviewBase {
2525
public static ID: string = 'IssueOverviewPanel';
@@ -603,14 +603,17 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
603603
}
604604

605605
private createComment(message: IRequestMessage<string>) {
606-
return this._item.createIssueComment(message.args).then(comment => {
606+
return this._item.createIssueComment(message.args).then(async (comment) => {
607607
const commentedEvent: CommentEvent = {
608608
...comment,
609609
event: EventType.Commented
610610
};
611-
return this._replyMessage(message, {
612-
event: commentedEvent,
613-
});
611+
const allEvents = await this._item.githubRepository.getIssueTimelineEvents(this._item);
612+
const reply: SubmitReviewReply = {
613+
events: allEvents,
614+
reviewedEvent: commentedEvent,
615+
};
616+
return this._replyMessage(message, reply);
614617
});
615618
}
616619

src/github/pullRequestOverview.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,11 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
655655
try {
656656
const review = await action(context.body);
657657
this.updateReviewers(review);
658+
const allEvents = await this._item.getTimelineEvents();
658659
const reviewMessage: SubmitReviewReply & { command: string } = {
659660
command: 'pr.append-review',
660-
event: review,
661+
reviewedEvent: review,
662+
events: allEvents,
661663
reviewers: this._existingReviewers
662664
};
663665
await this._postMessage(reviewMessage);
@@ -673,8 +675,10 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
673675
try {
674676
const review = await action(message.args);
675677
this.updateReviewers(review);
678+
const allEvents = await this._item.getTimelineEvents();
676679
const reply: SubmitReviewReply = {
677-
event: review,
680+
reviewedEvent: review,
681+
events: allEvents,
678682
reviewers: this._existingReviewers,
679683
};
680684
this._replyMessage(message, reply);

src/github/views.ts

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

6-
import { ReviewEvent, TimelineEvent } from '../common/timelineEvent';
6+
import { CommentEvent, ReviewEvent, TimelineEvent } from '../common/timelineEvent';
77
import {
88
GithubItemStateEnum,
99
IAccount,
@@ -110,7 +110,8 @@ export interface ChangeAssigneesReply {
110110
}
111111

112112
export interface SubmitReviewReply {
113-
event?: ReviewEvent | TimelineEvent;
113+
events?: TimelineEvent[];
114+
reviewedEvent: ReviewEvent | CommentEvent;
114115
reviewers?: ReviewState[];
115116
}
116117

webviews/common/context.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,19 @@ export class PRContext {
176176
};
177177

178178
private appendReview(reply: SubmitReviewReply) {
179-
const { event, reviewers } = reply;
179+
const { events, reviewers, reviewedEvent } = reply;
180180
const state = this.pr;
181181
state.busy = false;
182-
if (!event) {
182+
if (!events) {
183183
this.updatePR(state);
184184
return;
185185
}
186-
const events = state.events.filter(e => e.event !== EventType.Reviewed || e.state?.toLowerCase() !== 'pending');
187-
events.forEach(event => {
188-
if (event.event === EventType.Reviewed) {
189-
event.comments.forEach(c => (c.isDraft = false));
190-
}
191-
});
192186
if (reviewers) {
193187
state.reviewers = reviewers;
194188
}
195-
state.events = [...state.events.filter(e => (e.event === EventType.Reviewed ? e.state !== 'PENDING' : e)), event];
196-
if (event.event === EventType.Reviewed) {
197-
state.currentUserReviewState = event.state;
189+
state.events = events;
190+
if (reviewedEvent.event === EventType.Reviewed) {
191+
state.currentUserReviewState = reviewedEvent.state;
198192
}
199193
state.pendingCommentText = '';
200194
state.pendingReviewType = undefined;

0 commit comments

Comments
 (0)