Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,11 @@
"command": "pr.unresolveReviewThreadFromView",
"group": "context@1",
"when": "commentController =~ /^github-(browse|review)/ && commentThread =~ /canUnresolve/"
},
{
"command": "pr.applySuggestionWithCopilot",
"group": "context@2",
"when": "commentController =~ /^github-review/"
}
],
"editor/title": [
Expand Down Expand Up @@ -3256,7 +3261,7 @@
},
{
"command": "pr.applySuggestionWithCopilot",
"when": "commentController =~ /^github-review/ && !(comment =~ /hasSuggestion/)"
"when": "commentController =~ /^github-review/"
}
],
"comments/comment/title": [
Expand All @@ -3268,7 +3273,7 @@
{
"command": "pr.applySuggestionWithCopilot",
"group": "overflow@0",
"when": "commentController =~ /^github-review/ && !(comment =~ /hasSuggestion/)"
"when": "commentController =~ /^github-review/"
},
{
"command": "pr.editComment",
Expand Down
6 changes: 3 additions & 3 deletions src/@types/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ declare module 'vscode' {
pastTenseMessage?: string | MarkdownString;
isConfirmed?: boolean;
isComplete?: boolean;
toolSpecificData?: ChatTerminalToolInvocationData | ChatMcpToolInvocationData;
subAgentInvocationId?: string;
toolSpecificData?: ChatTerminalToolInvocationData;
fromSubAgent?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? This is bringing back old code

presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;

constructor(toolName: string, toolCallId: string, isError?: boolean);
Expand Down Expand Up @@ -244,7 +244,7 @@ declare module 'vscode' {
constructor(uris: Uri[], callback: () => Thenable<unknown>);
}

export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseWorkspaceEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
export class ChatResponseWarningPart {
value: MarkdownString;
constructor(value: string | MarkdownString);
Expand Down
26 changes: 18 additions & 8 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1768,20 +1768,30 @@ ${contents}
}
}));
context.subscriptions.push(
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment) => {
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment | GHPRCommentThread) => {
/* __GDPR__
"pr.applySuggestionWithCopilot" : {}
*/
telemetry.sendTelemetryEvent('pr.applySuggestionWithCopilot');

const commentThread = comment.parent;
const isThread = GHPRCommentThread.is(comment);
const commentThread = isThread ? comment : comment.parent;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing bounds check before accessing comment.comments[0]. If a thread has no comments, this will throw a runtime error. Add a check to ensure the comments array has at least one element before accessing it, or handle the empty case appropriately.

Suggested change
const commentThread = isThread ? comment : comment.parent;
const commentThread = isThread ? comment : comment.parent;
if (isThread && (!comment.comments || comment.comments.length === 0)) {
// No comments available on this thread; nothing to apply with Copilot
return;
}

Copilot uses AI. Check for mistakes.
const commentBody = isThread ? comment.comments[0].body : comment.body;
commentThread.collapsibleState = vscode.CommentThreadCollapsibleState.Collapsed;
const message = comment.body instanceof vscode.MarkdownString ? comment.body.value : comment.body;
await vscode.commands.executeCommand('vscode.editorChat.start', {
initialRange: commentThread.range,
message: message,
autoSend: true,
});
const message = commentBody instanceof vscode.MarkdownString ? commentBody.value : commentBody;

if (isThread) {
// For threads, open the Chat view instead of inline chat
await vscode.commands.executeCommand(commands.NEW_CHAT, { inputValue: message, isPartialQuery: true, agentMode: true });

} else {
// For single comments, use inline chat
await vscode.commands.executeCommand('vscode.editorChat.start', {
initialRange: commentThread.range,
message: message,
autoSend: true,
});
}
})
);
context.subscriptions.push(
Expand Down