Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances GitHub review comments to extract and apply code suggestions from GitHub's suggestion blocks. The changes enable proper handling of multi-line suggestions and improve context value updates for comment threads.
- Extract suggestions from GitHub review comment bodies using regex parsing
- Create editable suggestions with proper range calculation for multi-line comments
- Update comment thread context values to reflect suggestion availability
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/extension/review/node/githubReviewAgent.ts | Extracts suggestions from GitHub comment bodies, creates suggestion ranges based on start/end lines, and populates the suggestion field with edits |
| src/extension/review/node/doReview.ts | Adds error logging for review failures |
| src/extension/inlineChat/vscode-node/inlineChatCommands.ts | Updates context values when suggestions are available but marked as hasNoSuggestion |
| @@ -212,7 +212,9 @@ function createReviewComment(ghComment: ResponseComment | ExcludedComment, reque | |||
| const range = new Range(fromLine.lineNumber, fromLine.firstNonWhitespaceCharacterIndex, fromLine.lineNumber, lastNonWhitespaceCharacterIndex); | |||
| const raw = ghComment.data.body; | |||
| // Remove suggestion because that interfers with our own suggestion rendering later. | |||
There was a problem hiding this comment.
Corrected spelling of 'interfers' to 'interferes'.
| // Remove suggestion because that interfers with our own suggestion rendering later. | |
| // Remove suggestion because that interferes with our own suggestion rendering later. |
| const content = removeSuggestion(raw); | ||
| const { content, suggestions } = removeSuggestion(raw); | ||
| const startLine = typeof ghComment.data.start_line === 'number' ? ghComment.data.start_line : ghComment.data.line; | ||
| const suggestionRange = new Range(startLine - 1, 0, ghComment.data.line, 0); |
There was a problem hiding this comment.
The suggestionRange end line should be ghComment.data.line - 1 to properly convert from 1-indexed GitHub line numbers to 0-indexed VS Code line numbers. Currently, the start line is correctly adjusted (startLine - 1) but the end line is not, which could cause the range to extend one line too far.
| const suggestionRange = new Range(startLine - 1, 0, ghComment.data.line, 0); | |
| const suggestionRange = new Range(startLine - 1, 0, ghComment.data.line - 1, 0); |
| edits: suggestions.map(suggestion => { | ||
| const oldText = document.getText(suggestionRange); | ||
| return { | ||
| range: suggestionRange, | ||
| newText: suggestion, | ||
| oldText, | ||
| }; | ||
| }), |
There was a problem hiding this comment.
The document.getText(suggestionRange) call is being made inside the map callback, which means it's called once per suggestion. Since all suggestions use the same suggestionRange, this value should be computed once before the map operation to avoid redundant document access.
| edits: suggestions.map(suggestion => { | |
| const oldText = document.getText(suggestionRange); | |
| return { | |
| range: suggestionRange, | |
| newText: suggestion, | |
| oldText, | |
| }; | |
| }), | |
| edits: (() => { | |
| const oldText = document.getText(suggestionRange); | |
| return suggestions.map(suggestion => { | |
| return { | |
| range: suggestionRange, | |
| newText: suggestion, | |
| oldText, | |
| }; | |
| }); | |
| })(), |
Fixes microsoft/vscode#275624