Skip to content

[WIP] Generating VS Code Product Links for Chat Response Turn 2 #7415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/github/copilotRemoteAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,22 @@ export class CopilotRemoteAgentManager extends Disposable {

return new Promise<void>((resolve, reject) => {
const complete = async () => {
// Generate and add pull request reference link for the active response callback stream
try {
const prLinkUri = await toOpenPullRequestWebviewUri({
owner: pullRequest.remote.owner,
repo: pullRequest.remote.repositoryName,
pullRequestNumber: pullRequest.number
});
const referencePart = new vscode.ChatResponseReferencePart2(
prLinkUri,
new vscode.ThemeIcon('git-pull-request')
);
stream.push(referencePart);
} catch (error) {
Logger.error(`Failed to generate pull request reference link in stream: ${error}`, CopilotRemoteAgentManager.ID);
}

const multiDiffPart = await this.getFileChangesMultiDiffPart(pullRequest);
if (multiDiffPart) {
stream.push(multiDiffPart);
Expand Down Expand Up @@ -1340,7 +1356,7 @@ export class CopilotRemoteAgentManager extends Disposable {
private async parseSessionLogsIntoResponseTurn(pullRequest: PullRequestModel, logs: string, session: SessionInfo): Promise<vscode.ChatResponseTurn2 | undefined> {
try {
const logChunks = parseSessionLogs(logs);
const responseParts: Array<vscode.ChatResponseMarkdownPart | vscode.ChatToolInvocationPart | vscode.ChatResponseMultiDiffPart> = [];
const responseParts: Array<vscode.ChatResponseMarkdownPart | vscode.ChatToolInvocationPart | vscode.ChatResponseMultiDiffPart | vscode.ChatResponseReferencePart2> = [];
let currentResponseContent = '';

for (const chunk of logChunks) {
Expand Down Expand Up @@ -1376,6 +1392,22 @@ export class CopilotRemoteAgentManager extends Disposable {
responseParts.push(new vscode.ChatResponseMarkdownPart(currentResponseContent.trim()));
}

// Generate and add pull request reference link for the last stream session (active response callback stream)
try {
const prLinkUri = await toOpenPullRequestWebviewUri({
owner: pullRequest.remote.owner,
repo: pullRequest.remote.repositoryName,
pullRequestNumber: pullRequest.number
});
const referencePart = new vscode.ChatResponseReferencePart2(
prLinkUri,
new vscode.ThemeIcon('git-pull-request')
);
responseParts.push(referencePart);
} catch (error) {
Logger.error(`Failed to generate pull request reference link: ${error}`, CopilotRemoteAgentManager.ID);
}

if (session.state === 'completed') {
const fileChangesPart = await this.getFileChangesMultiDiffPart(pullRequest);
if (fileChangesPart) {
Expand Down