Skip to content

Commit b117e1d

Browse files
committed
Fix command
1 parent 48fab76 commit b117e1d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

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)