Skip to content

Commit 5978bda

Browse files
Copilotalexr00
andauthored
Fix: Detect PR files in #openPullRequest when single file is open (#7892)
* Initial plan * Initial analysis complete Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix: Detect PR files in #openPullRequest when single file is open The OpenPullRequestTool now also detects PR-associated files when a single file with PR scheme is open, not just when a diff is open. This allows users to ask about #openPullRequest when they have newly added files open in a PR. Added support for: - TabInputText with Schemes.Pr (PR files from GitHub) - TabInputText with Schemes.Review (checked out PR files) This fixes the issue where PRs with only newly created files were not detected. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Revert proposed changes --------- 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 2b6142d commit 5978bda

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/github/copilotRemoteAgentUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function extractTitle(prompt: string, context: string | undefined): strin
5050
return prompt;
5151
}
5252
return prompt.substring(0, 20) + '...';
53-
}
53+
};
5454
const titleMatch = context?.match(/TITLE: \s*(.*)/i);
5555
if (titleMatch && titleMatch[1]) {
5656
return titleMatch[1].trim();

src/lm/tools/openPullRequestTool.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ export class OpenPullRequestTool extends PullRequestTool {
4343
}
4444
}
4545
}
46+
} else if (activeTab?.input instanceof vscode.TabInputText) {
47+
// Check if a single file with PR scheme is open (e.g., newly added files)
48+
const textInput = activeTab.input;
49+
if (textInput.uri.scheme === Schemes.Pr) {
50+
const prParams = fromPRUri(textInput.uri);
51+
if (prParams) {
52+
return this._findPullRequestByNumber(prParams.prNumber, prParams.remoteName);
53+
}
54+
} else if (textInput.uri.scheme === Schemes.Review) {
55+
const reviewParams = fromReviewUri(textInput.uri.query);
56+
if (reviewParams) {
57+
const rootUri = vscode.Uri.file(reviewParams.rootPath);
58+
const folderManager = this.folderManagers.getManagerForFile(rootUri);
59+
return folderManager?.activePullRequest;
60+
}
61+
}
4662
}
4763

4864
return undefined;

0 commit comments

Comments
 (0)