Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,8 @@
{
"command": "pr.checkoutFromDescription",
"title": "%command.pr.checkoutFromDescription.title%",
"category": "%command.pull.request.category%"
"category": "%command.pull.request.category%",
"icon": "$(git-compare)"
},
{
"command": "pr.checkoutOnVscodeDevFromDescription",
Expand Down Expand Up @@ -3410,6 +3411,12 @@
"when": "chatSessionType == copilot-swe-agent",
"group": "context"
}
],
"chat/multiDiff/context": [
{
"command": "pr.checkoutFromDescription",
"when": "chatSessionType == copilot-swe-agent"
}
]
},
"colors": [
Expand Down
22 changes: 19 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,27 @@ export function registerCommands(
return { folderManager, pr };
};

context.subscriptions.push(vscode.commands.registerCommand('pr.checkoutFromDescription', async (context: OverviewContext | undefined) => {
if (!context) {
context.subscriptions.push(vscode.commands.registerCommand('pr.checkoutFromDescription', async (ctx: OverviewContext | { path: string } | undefined) => {
if (!ctx) {
return vscode.window.showErrorMessage(vscode.l10n.t('No pull request context provided for checkout.'));
}
const resolved = await resolvePr(context);

if ('path' in ctx) {
const { path } = ctx;
const prNumber = Number(Buffer.from(path.substring(1), 'base64').toString('utf8'));
if (Number.isNaN(prNumber)) {
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to parse pull request number.'));
}
const folderManager = reposManager.folderManagers[0];
const pullRequest = await folderManager.fetchById(folderManager.gitHubRepositories[0], Number(prNumber));
Comment on lines +665 to +666
Copy link
Member

@alexr00 alexr00 Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work for multi-repo. You can easily end up getting the wrong PR. In fully multi repo (usually multiroot workspace) setup, you could get a PR from an unrelated repo.

If there are multiple folder managers and github repos, it would be better to actually find the correct repo to fetch from. You can probably use getManagerForFile:

getManagerForFile(uri: vscode.Uri): FolderRepositoryManager | undefined {
if (uri.scheme === 'untitled') {

if (!pullRequest) {
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to find pull request #{0}', prNumber.toString()));
}

return switchToPr(folderManager, pullRequest, folderManager.repository, true);
}

const resolved = await resolvePr(ctx);
if (!resolved) {
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to resolve pull request for checkout.'));
}
Expand Down