Skip to content

Commit 974d80a

Browse files
authored
"Copilot started work" should not be the same message for CCA and CCR (#8427)
Fixes #8211
1 parent bccd293 commit 974d80a

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/common/timelineEvent.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum EventType {
2626
CopilotStarted,
2727
CopilotFinished,
2828
CopilotFinishedError,
29+
CopilotReviewStarted,
2930
Other,
3031
}
3132

@@ -202,4 +203,10 @@ export interface CopilotFinishedErrorEvent {
202203
sessionLink: SessionLinkInfo;
203204
}
204205

205-
export type TimelineEvent = CommitEvent | ReviewEvent | CommentEvent | NewCommitsSinceReviewEvent | MergedEvent | AssignEvent | UnassignEvent | HeadRefDeleteEvent | CrossReferencedEvent | ClosedEvent | ReopenedEvent | BaseRefChangedEvent | CopilotStartedEvent | CopilotFinishedEvent | CopilotFinishedErrorEvent;
206+
export interface CopilotReviewStartedEvent {
207+
id: string;
208+
event: EventType.CopilotReviewStarted;
209+
createdAt: string;
210+
}
211+
212+
export type TimelineEvent = CommitEvent | ReviewEvent | CommentEvent | NewCommitsSinceReviewEvent | MergedEvent | AssignEvent | UnassignEvent | HeadRefDeleteEvent | CrossReferencedEvent | ClosedEvent | ReopenedEvent | BaseRefChangedEvent | CopilotStartedEvent | CopilotFinishedEvent | CopilotFinishedErrorEvent | CopilotReviewStartedEvent;

src/github/utils.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { Repository } from '../api/api';
4545
import { GitApiImpl } from '../api/api1';
4646
import { AuthProvider, GitHubServerType } from '../common/authentication';
4747
import { COPILOT_ACCOUNTS, IComment, IReviewThread, SubjectType } from '../common/comment';
48-
import { COPILOT_SWE_AGENT } from '../common/copilot';
48+
import { COPILOT_REVIEWER, COPILOT_SWE_AGENT } from '../common/copilot';
4949
import { DiffHunk, parseDiffHunk } from '../common/diffHunk';
5050
import { emojify } from '../common/emoji';
5151
import { GitHubRef } from '../common/githubRef';
@@ -1060,9 +1060,9 @@ export function parseSelectRestTimelineEvents(
10601060

10611061
let sessionIndex = 0;
10621062
for (const event of events) {
1063-
const eventNode = event as { created_at?: string; node_id?: string; actor: RestAccount };
1063+
const eventNode = event as { created_at?: string; node_id?: string; actor: RestAccount, performed_via_github_app?: { slug: string } | null };
10641064
if (eventNode.created_at && eventNode.node_id) {
1065-
if (event.event === 'copilot_work_started') {
1065+
if (event.event === 'copilot_work_started' && eventNode.performed_via_github_app?.slug === COPILOT_SWE_AGENT) {
10661066
parsedEvents.push({
10671067
id: eventNode.node_id,
10681068
event: Common.EventType.CopilotStarted,
@@ -1073,7 +1073,7 @@ export function parseSelectRestTimelineEvents(
10731073
sessionIndex
10741074
}
10751075
});
1076-
} else if (event.event === 'copilot_work_finished') {
1076+
} else if (event.event === 'copilot_work_finished' && eventNode.performed_via_github_app?.slug === COPILOT_SWE_AGENT) {
10771077
parsedEvents.push({
10781078
id: eventNode.node_id,
10791079
event: Common.EventType.CopilotFinished,
@@ -1093,6 +1093,12 @@ export function parseSelectRestTimelineEvents(
10931093
sessionIndex
10941094
}
10951095
});
1096+
} else if (event.event === 'copilot_work_started' && eventNode.performed_via_github_app?.slug === COPILOT_REVIEWER) {
1097+
parsedEvents.push({
1098+
id: eventNode.node_id,
1099+
event: Common.EventType.CopilotReviewStarted,
1100+
createdAt: eventNode.created_at,
1101+
});
10961102
}
10971103
}
10981104
}
@@ -1114,6 +1120,7 @@ export function eventTime(event: Common.TimelineEvent): Date | undefined {
11141120
case Common.EventType.CopilotStarted:
11151121
case Common.EventType.CopilotFinished:
11161122
case Common.EventType.CopilotFinishedError:
1123+
case Common.EventType.CopilotReviewStarted:
11171124
return new Date(event.createdAt);
11181125
case Common.EventType.Reviewed:
11191126
return new Date(event.submittedAt);

webviews/components/timeline.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import React, { useContext, useRef, useState } from 'react';
77
import { CommentView } from './comment';
88
import Diff from './diff';
9-
import { addIcon, checkIcon, circleFilledIcon, closeIcon, errorIcon, gitCommitIcon, gitMergeIcon, loadingIcon, tasklistIcon, threeBars } from './icon';
9+
import { addIcon, checkIcon, circleFilledIcon, closeIcon, commentIcon, errorIcon, gitCommitIcon, gitMergeIcon, loadingIcon, tasklistIcon, threeBars } from './icon';
1010
import { nbsp } from './space';
1111
import { Timestamp } from './timestamp';
1212
import { AuthorLink, Avatar } from './user';
@@ -19,6 +19,7 @@ import {
1919
CommitEvent,
2020
CopilotFinishedErrorEvent,
2121
CopilotFinishedEvent,
22+
CopilotReviewStartedEvent,
2223
CopilotStartedEvent,
2324
CrossReferencedEvent,
2425
EventType,
@@ -100,6 +101,8 @@ export const Timeline = ({ events, isIssue }: { events: TimelineEvent[], isIssue
100101
return <CopilotFinishedEventView key={`copilotFinished${event.id}`} {...event} />;
101102
case EventType.CopilotFinishedError:
102103
return <CopilotFinishedErrorEventView key={`copilotFinishedError${event.id}`} {...event} />;
104+
case EventType.CopilotReviewStarted:
105+
return <CopilotReviewStartedEventView key={`copilotReviewStarted${event.id}`} {...event} />;
103106
default:
104107
throw new UnreachableCaseError(event);
105108
}
@@ -610,4 +613,18 @@ const CopilotFinishedErrorEventView = (event: CopilotFinishedErrorEvent) => {
610613
<Timestamp date={createdAt} />
611614
</div>
612615
);
616+
};
617+
618+
const CopilotReviewStartedEventView = (event: CopilotReviewStartedEvent) => {
619+
const { createdAt } = event;
620+
return (
621+
<div className="comment-container commit">
622+
<div className="commit-message">
623+
{commentIcon}
624+
{nbsp}
625+
<div className="message">Copilot started reviewing</div>
626+
</div>
627+
<Timestamp date={createdAt} />
628+
</div>
629+
);
613630
};

0 commit comments

Comments
 (0)