Skip to content

Commit 1d8b5f2

Browse files
committed
contribute open changes button to copilot-cloud-agent
1 parent 040f821 commit 1d8b5f2

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3555,7 +3555,11 @@
35553555
},
35563556
{
35573557
"command": "pr.applyChangesFromDescription",
3558-
"when": "chatSessionType == copilot-swe-agent || chatSessionType == 'copilot-cloud-agent'"
3558+
"when": "resourceScheme == copilot-swe-agent || resourceScheme == 'copilot-cloud-agent'"
3559+
},
3560+
{
3561+
"command": "pr.openChanges",
3562+
"when": "resourceScheme == 'copilot-cloud-agent'"
35593563
}
35603564
]
35613565
},

src/commands.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ export function registerCommands(
704704
}));
705705

706706
context.subscriptions.push(
707-
vscode.commands.registerCommand('pr.openChanges', async (pr: PRNode | RepositoryChangesNode | PullRequestModel | OverviewContext | ChatSessionWithPR | undefined) => {
707+
vscode.commands.registerCommand('pr.openChanges', async (pr: PRNode | RepositoryChangesNode | PullRequestModel | OverviewContext | ChatSessionWithPR | { path: string } | undefined) => {
708708
if (pr === undefined) {
709709
// This is unexpected, but has happened a few times.
710710
Logger.error('Unexpectedly received undefined when picking a PR.', logId);
@@ -727,7 +727,22 @@ export function registerCommands(
727727
preventDefaultContextMenuItems: true,
728728
});
729729
pullRequestModel = resolved?.pr;
730-
} else {
730+
}
731+
else if (contextHasPath(pr)) {
732+
// looks like '/123' where 123 is the PR number
733+
const { path } = pr;
734+
const prNumber = Number(path.startsWith('/') ? path.substring(1) : path);
735+
if (Number.isNaN(prNumber)) {
736+
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to parse pull request number.'));
737+
}
738+
const folderManager = reposManager.folderManagers[0];
739+
const pullRequest = await folderManager.fetchById(folderManager.gitHubRepositories[0], Number(prNumber));
740+
if (!pullRequest) {
741+
return vscode.window.showErrorMessage(vscode.l10n.t('Unable to find pull request #{0}', prNumber.toString()));
742+
}
743+
pullRequestModel = pullRequest;
744+
}
745+
else {
731746
const resolved = await resolvePr(pr as OverviewContext);
732747
pullRequestModel = resolved?.pr;
733748
}

0 commit comments

Comments
 (0)