Skip to content

Commit 56702c6

Browse files
authored
Make sure comments are initialized (#8541)
1 parent f314ec4 commit 56702c6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lm/tools/activePullRequestTool.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export abstract class PullRequestTool implements vscode.LanguageModelTool<FetchI
5050
}
5151

5252
const timeline = (pullRequest.timelineEvents && pullRequest.timelineEvents.length > 0) ? pullRequest.timelineEvents : await pullRequest.getTimelineEvents();
53+
const reviewAndCommentEvents = timeline.filter((event): event is ReviewEvent | CommentEvent => event.event === EventType.Reviewed || event.event === EventType.Commented);
54+
55+
if ((pullRequest.comments.length === 0) && (reviewAndCommentEvents.length !== 0)) {
56+
// Probably missing some comments
57+
await pullRequest.initializeReviewThreadCacheAndReviewComments();
58+
}
59+
5360
const pullRequestInfo = {
5461
title: pullRequest.title,
5562
body: pullRequest.body,
@@ -63,7 +70,7 @@ export abstract class PullRequestTool implements vscode.LanguageModelTool<FetchI
6370
file: comment.path
6471
};
6572
}),
66-
timelineComments: timeline.filter((event): event is ReviewEvent | CommentEvent => event.event === EventType.Reviewed || event.event === EventType.Commented).map(event => {
73+
timelineComments: reviewAndCommentEvents.map(event => {
6774
return {
6875
author: event.user?.login,
6976
body: event.body,

0 commit comments

Comments
 (0)