Skip to content

Commit 6d38f1d

Browse files
Copilotalexr00
andauthored
Add Apply Suggestion commands to Comments view context menu (#8409)
* Initial plan * Initial progress report: Plan to add Apply Suggestion with Copilot to Comments view Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Add Apply Suggestion commands to Comments view context menu Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix command * Always show "with copilot" --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent b99fbe9 commit 6d38f1d

3 files changed

Lines changed: 28 additions & 13 deletions

File tree

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,11 @@
31003100
"command": "pr.unresolveReviewThreadFromView",
31013101
"group": "context@1",
31023102
"when": "commentController =~ /^github-(browse|review)/ && commentThread =~ /canUnresolve/"
3103+
},
3104+
{
3105+
"command": "pr.applySuggestionWithCopilot",
3106+
"group": "context@2",
3107+
"when": "commentController =~ /^github-review/"
31033108
}
31043109
],
31053110
"editor/title": [
@@ -3256,7 +3261,7 @@
32563261
},
32573262
{
32583263
"command": "pr.applySuggestionWithCopilot",
3259-
"when": "commentController =~ /^github-review/ && !(comment =~ /hasSuggestion/)"
3264+
"when": "commentController =~ /^github-review/"
32603265
}
32613266
],
32623267
"comments/comment/title": [
@@ -3268,7 +3273,7 @@
32683273
{
32693274
"command": "pr.applySuggestionWithCopilot",
32703275
"group": "overflow@0",
3271-
"when": "commentController =~ /^github-review/ && !(comment =~ /hasSuggestion/)"
3276+
"when": "commentController =~ /^github-review/"
32723277
},
32733278
{
32743279
"command": "pr.editComment",

src/@types/vscode.proposed.chatParticipantAdditions.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ declare module 'vscode' {
171171
pastTenseMessage?: string | MarkdownString;
172172
isConfirmed?: boolean;
173173
isComplete?: boolean;
174-
toolSpecificData?: ChatTerminalToolInvocationData | ChatMcpToolInvocationData;
175-
subAgentInvocationId?: string;
174+
toolSpecificData?: ChatTerminalToolInvocationData;
175+
fromSubAgent?: boolean;
176176
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
177177

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

247-
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseWorkspaceEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
247+
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
248248
export class ChatResponseWarningPart {
249249
value: MarkdownString;
250250
constructor(value: string | MarkdownString);

src/commands.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,20 +1768,30 @@ ${contents}
17681768
}
17691769
}));
17701770
context.subscriptions.push(
1771-
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment) => {
1771+
vscode.commands.registerCommand('pr.applySuggestionWithCopilot', async (comment: GHPRComment | GHPRCommentThread) => {
17721772
/* __GDPR__
17731773
"pr.applySuggestionWithCopilot" : {}
17741774
*/
17751775
telemetry.sendTelemetryEvent('pr.applySuggestionWithCopilot');
17761776

1777-
const commentThread = comment.parent;
1777+
const isThread = GHPRCommentThread.is(comment);
1778+
const commentThread = isThread ? comment : comment.parent;
1779+
const commentBody = isThread ? comment.comments[0].body : comment.body;
17781780
commentThread.collapsibleState = vscode.CommentThreadCollapsibleState.Collapsed;
1779-
const message = comment.body instanceof vscode.MarkdownString ? comment.body.value : comment.body;
1780-
await vscode.commands.executeCommand('vscode.editorChat.start', {
1781-
initialRange: commentThread.range,
1782-
message: message,
1783-
autoSend: true,
1784-
});
1781+
const message = commentBody instanceof vscode.MarkdownString ? commentBody.value : commentBody;
1782+
1783+
if (isThread) {
1784+
// For threads, open the Chat view instead of inline chat
1785+
await vscode.commands.executeCommand(commands.NEW_CHAT, { inputValue: message, isPartialQuery: true, agentMode: true });
1786+
1787+
} else {
1788+
// For single comments, use inline chat
1789+
await vscode.commands.executeCommand('vscode.editorChat.start', {
1790+
initialRange: commentThread.range,
1791+
message: message,
1792+
autoSend: true,
1793+
});
1794+
}
17851795
})
17861796
);
17871797
context.subscriptions.push(

0 commit comments

Comments
 (0)