Add "Convert to draft" action in PR reviewers section
Users can mark a draft PR as ready for review but cannot revert it back to draft. This adds symmetry to the workflow.
Changes
GraphQL layer
- Added
ConvertToDraftmutation inqueriesShared.gql - Added
ConvertPullRequestToDraftResponseinterface
Model
- Implemented
convertToDraft()method inPullRequestModelwith telemetry
UI
- Added "Convert to draft" button in reviewers section (sidebar)
- Button shown when PR is not draft AND (user is author OR has write permission)
- State management handles busy/disabled states during conversion
Message routing
- Added
pr.convertToDraftcommand handler inpullRequestOverview.ts - Added
convertToDraft()context method in webview layer
Implementation
Mirrors the existing "Ready for review" pattern:
// Backend
async convertToDraft(): Promise<ConvertToDraft> {
const { data } = await mutate<ConvertPullRequestToDraftResponse>({
mutation: schema.ConvertToDraft,
variables: { input: { pullRequestId: this.graphNodeId } }
});
this.item.isDraft = data.convertPullRequestToDraft.pullRequest.isDraft;
return result;
}
// Frontend component
{!pr.isDraft && (hasWritePermission || pr.isAuthor) && (
<ConvertToDraft />
)}
Original prompt
This section details on the original issue you should resolve
<issue_title>Support "Convert to draft" in PR view</issue_title> <issue_description>I created a PR and then realized it wasn't ready. It would be great if I could convert the PR to draft from vscode.
Especially since we can mark a PR ready for review:
(not a very important FR, of course)</issue_description>
<agent_instructions>Add a "convert to draft" in the "reviewers" section of the PR webview.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
- Fixes microsoft/vscode-pull-request-github#6028
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.