Skip to content

Commit ebe1a04

Browse files
authored
Show the PR card in the session chat (#7603)
Fixes #7602
1 parent 949c66f commit ebe1a04

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/github/copilotRemoteAgent/chatSessionContentBuilder.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { parseSessionLogs, parseToolCallDetails } from '../../../common/sessionP
99
import { COPILOT_SWE_AGENT } from '../../common/copilot';
1010
import Logger from '../../common/logger';
1111
import { CommentEvent, CopilotFinishedEvent, CopilotStartedEvent, EventType, ReviewEvent, TimelineEvent } from '../../common/timelineEvent';
12+
import { toOpenPullRequestWebviewUri } from '../../common/uri';
1213
import { InMemFileChangeModel, RemoteFileChangeModel } from '../../view/fileChangeModel';
1314
import { AssistantDelta, Choice, ToolCall } from '../common';
1415
import { CopilotApi, SessionInfo } from '../copilotApi';
@@ -53,6 +54,13 @@ export class ChatSessionContentBuilder {
5354
// Create response turn
5455
const responseHistory = await this.createResponseTurn(pullRequest, logs, session);
5556
if (responseHistory) {
57+
// if this is the first response, then also add the PR card
58+
if (history.length === 1) {
59+
const uri = await toOpenPullRequestWebviewUri({ owner: pullRequest.remote.owner, repo: pullRequest.remote.repositoryName, pullRequestNumber: pullRequest.number });
60+
const card = new vscode.ChatResponsePullRequestPart(uri, pullRequest.title, pullRequest.body, pullRequest.author.specialDisplayName ?? pullRequest.author.login, `#${pullRequest.number}`);
61+
const cardTurn = new vscode.ChatResponseTurn2([card], {}, COPILOT_SWE_AGENT);
62+
history.push(cardTurn);
63+
}
5664
history.push(responseHistory);
5765
}
5866
}

0 commit comments

Comments
 (0)