Skip to content

Commit ea064fa

Browse files
authored
It's not clear why the Copilot PR's top comment has "Pending" (#7199)
Fixes #7181
1 parent f052052 commit ea064fa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webviews/components/comment.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ function isReviewEvent(comment: IComment | ReviewEvent | PullRequest | CommentEv
136136
return (comment as ReviewEvent).authorAssociation !== undefined;
137137
}
138138

139+
function isIComment(comment: any): comment is IComment {
140+
return comment && typeof comment === 'object' &&
141+
typeof comment.body === 'string' && typeof comment.diffHunk === 'string';
142+
}
143+
139144
const DESCRIPTORS = {
140145
PENDING: 'will review',
141146
COMMENTED: 'reviewed',
@@ -147,7 +152,7 @@ const reviewDescriptor = (state: string) => DESCRIPTORS[state] || 'reviewed';
147152

148153
function CommentBox({ for: comment, onFocus, onMouseEnter, onMouseLeave, children }: CommentBoxProps) {
149154
const htmlUrl = ('htmlUrl' in comment) ? comment.htmlUrl : (comment as PullRequest).url;
150-
const isDraft = (comment as IComment).isDraft ?? (isReviewEvent(comment) && (comment.state?.toLocaleUpperCase() === 'PENDING'));
155+
const isDraft = (isIComment(comment) && comment.isDraft) ?? (isReviewEvent(comment) && (comment.state?.toLocaleUpperCase() === 'PENDING'));
151156
const author = ('user' in comment) ? comment.user! : (comment as PullRequest).author!;
152157
const createdAt = ('createdAt' in comment) ? comment.createdAt : (comment as ReviewEvent).submittedAt;
153158

0 commit comments

Comments
 (0)