Add Codespaces checkout option to PR dropdown
The PR checkout dropdown lacked a direct path to open PRs in Codespaces for testing without local setup.
Changes
-
Command: Added
pr.checkoutOnCodespacesFromDescriptionthat openshttps://github.com/codespaces/new?ref={branch}&repo={owner/repo} - Menu: Inserted "Checkout on Codespaces" as third option in PR overview dropdown (after "Checkout on vscode.dev")
-
Utility: Added
codespacesPrLink()helper inutils.tsto construct Codespaces URLs from PR head refs
Implementation
export function codespacesPrLink(pullRequest: { head: GitHubRef }): string {
const repoFullName = `${pullRequest.head.owner}/${pullRequest.head.name}`;
const branch = pullRequest.head.ref;
return `https://github.com/codespaces/new?ref=${encodeURIComponent(branch)}&repo=${encodeURIComponent(repoFullName)}`;
}
The command handler validates PR context and head branch existence before opening the external link, mirroring the pattern used by checkoutOnVscodeDevFromDescription.
Original prompt
This section details on the original issue you should resolve
<issue_title>Add option to checkout PR on Codespaces</issue_title> <issue_description>Testing microsoft/vscode-pull-request-github#7424
It'd be nice if I had an option to checkout the PR on Codespaces. I was working on a local repo that wasn't set up on my machine, and I wish I had the option from the PR header to checkout on Codespaces so that the repo would be set up for me to test my changes
</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes microsoft/vscode-pull-request-github#7450
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.