Skip to content

Commit d72c2eb

Browse files
authored
Checkout PR at the end of a completed chat session (#7641)
* checkout from session chat * guard for chat session type
1 parent e794de1 commit d72c2eb

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,8 @@
13201320
{
13211321
"command": "pr.checkoutFromDescription",
13221322
"title": "%command.pr.checkoutFromDescription.title%",
1323-
"category": "%command.pull.request.category%"
1323+
"category": "%command.pull.request.category%",
1324+
"icon": "$(git-compare)"
13241325
},
13251326
{
13261327
"command": "pr.checkoutOnVscodeDevFromDescription",
@@ -3410,6 +3411,12 @@
34103411
"when": "chatSessionType == copilot-swe-agent",
34113412
"group": "context"
34123413
}
3414+
],
3415+
"chat/multiDiff/context": [
3416+
{
3417+
"command": "pr.checkoutFromDescription",
3418+
"when": "chatSessionType == copilot-swe-agent"
3419+
}
34133420
]
34143421
},
34153422
"colors": [

src/commands.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,27 @@ export function registerCommands(
651651
return { folderManager, pr };
652652
};
653653

654-
context.subscriptions.push(vscode.commands.registerCommand('pr.checkoutFromDescription', async (context: OverviewContext | undefined) => {
655-
if (!context) {
654+
context.subscriptions.push(vscode.commands.registerCommand('pr.checkoutFromDescription', async (ctx: OverviewContext | { path: string } | undefined) => {
655+
if (!ctx) {
656656
return vscode.window.showErrorMessage(vscode.l10n.t('No pull request context provided for checkout.'));
657657
}
658-
const resolved = await resolvePr(context);
658+
659+
if ('path' in ctx) {
660+
const { path } = ctx;
661+
const prNumber = Number(Buffer.from(path.substring(1), 'base64').toString('utf8'));
662+
if (Number.isNaN(prNumber)) {
663+
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to parse pull request number.'));
664+
}
665+
const folderManager = reposManager.folderManagers[0];
666+
const pullRequest = await folderManager.fetchById(folderManager.gitHubRepositories[0], Number(prNumber));
667+
if (!pullRequest) {
668+
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to find pull request #{0}', prNumber.toString()));
669+
}
670+
671+
return switchToPr(folderManager, pullRequest, folderManager.repository, true);
672+
}
673+
674+
const resolved = await resolvePr(ctx);
659675
if (!resolved) {
660676
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to resolve pull request for checkout.'));
661677
}

0 commit comments

Comments
 (0)