Skip to content

Commit b9984b6

Browse files
Copilotalexr00
andauthored
Add file path and line number context to AI suggestion prompt
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/eee01273-3d0c-403d-8bf7-8fbf1a909169 Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 736b535 commit b9984b6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/commands.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,9 +1850,25 @@ ${contents}
18501850
const commentThread = isThread ? comment : comment.parent;
18511851
const firstComment = isThread ? comment.comments[0] : comment;
18521852
commentThread.collapsibleState = vscode.CommentThreadCollapsibleState.Collapsed;
1853-
const message = firstComment instanceof GHPRComment ? firstComment.rawComment.body
1853+
const commentBody = firstComment instanceof GHPRComment ? firstComment.rawComment.body
18541854
: (firstComment.body instanceof vscode.MarkdownString ? firstComment.body.value : firstComment.body);
18551855

1856+
const filePath = firstComment instanceof GHPRComment ? firstComment.rawComment.path : undefined;
1857+
const range = commentThread.range;
1858+
let message: string;
1859+
if (filePath && range) {
1860+
const startLine = range.start.line + 1;
1861+
const endLine = range.end.line + 1;
1862+
const lineRef = startLine === endLine
1863+
? vscode.l10n.t('line {0}', startLine)
1864+
: vscode.l10n.t('lines {0}-{1}', startLine, endLine);
1865+
message = vscode.l10n.t('There is a code review comment for file {0} at {1}:\n{2}', filePath, lineRef, commentBody);
1866+
} else if (filePath) {
1867+
message = vscode.l10n.t('There is a code review comment for file {0}:\n{1}', filePath, commentBody);
1868+
} else {
1869+
message = commentBody;
1870+
}
1871+
18561872
if (isThread) {
18571873
// For threads, open the Chat view instead of inline chat
18581874
await vscode.commands.executeCommand(commands.NEW_CHAT, { inputValue: message, isPartialQuery: true, agentMode: true });

0 commit comments

Comments
 (0)