@@ -27,7 +27,7 @@ import { isCopilotOnMyBehalf, PullRequestModel } from './pullRequestModel';
2727import { PullRequestView } from './pullRequestOverviewCommon' ;
2828import { pickEmail , reviewersQuickPick } from './quickPicks' ;
2929import { parseReviewers } from './utils' ;
30- import { CancelCodingAgentReply , DeleteReviewResult , MergeArguments , MergeResult , PullRequest , ReviewType , SubmitReviewReply } from './views' ;
30+ import { CancelCodingAgentReply , DeleteReviewResult , MergeArguments , MergeResult , PullRequest , ReadyForReviewReply , ReviewType , SubmitReviewReply } from './views' ;
3131import { IComment } from '../common/comment' ;
3232import { COPILOT_SWE_AGENT , copilotEventToStatus , CopilotPRStatus , mostRecentCopilotEvent } from '../common/copilot' ;
3333import { commands , contexts } from '../common/executeCommands' ;
@@ -142,10 +142,10 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
142142
143143 this . setVisibilityContext ( ) ;
144144
145- this . _register ( vscode . commands . registerCommand ( 'pr.readyForReview ' , async ( ) => {
145+ this . _register ( vscode . commands . registerCommand ( 'pr.readyForReviewDescription ' , async ( ) => {
146146 return this . readyForReviewCommand ( ) ;
147147 } ) ) ;
148- this . _register ( vscode . commands . registerCommand ( 'pr.readyForReviewAndMerge ' , async ( context ? : { mergeMethod : MergeMethod } ) => {
148+ this . _register ( vscode . commands . registerCommand ( 'pr.readyForReviewAndMergeDescription ' , async ( context : { mergeMethod : MergeMethod } ) => {
149149 return this . readyForReviewAndMergeCommand ( context ) ;
150150 } ) ) ;
151151 this . _register ( vscode . commands . registerCommand ( 'review.approveDescription' , ( e ) => this . approvePullRequestCommand ( e ) ) ) ;
@@ -685,19 +685,48 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
685685 }
686686
687687 private async readyForReviewCommand ( ) : Promise < void > {
688- // Trigger the webview action by posting a message
689- // This will use the existing webview logic which handles busy state
690688 this . _postMessage ( {
691- command : 'pr.readyForReview-trigger '
689+ command : 'pr.readying-for-review '
692690 } ) ;
691+ try {
692+ const result = await this . _item . setReadyForReview ( ) ;
693+
694+ const readiedResult : ReadyForReviewReply = {
695+ isDraft : result . isDraft
696+ } ;
697+ await this . _postMessage ( {
698+ command : 'pr.readied-for-review' ,
699+ result : readiedResult
700+ } ) ;
701+ } catch ( e ) {
702+ vscode . window . showErrorMessage ( `Unable to set pull request ready for review. ${ formatError ( e ) } ` ) ;
703+ this . _throwError ( undefined , e . message ) ;
704+ }
693705 }
694706
695- private async readyForReviewAndMergeCommand ( _context ?: { mergeMethod : MergeMethod } ) : Promise < void > {
696- // Trigger the webview action by posting a message
697- // This will use the existing webview logic which handles busy state
707+ private async readyForReviewAndMergeCommand ( context : { mergeMethod : MergeMethod } ) : Promise < void > {
698708 this . _postMessage ( {
699- command : 'pr.readyForReviewAndMerge-trigger '
709+ command : 'pr.readying-for-review '
700710 } ) ;
711+ try {
712+ const [ readyResult , approveResult ] = await Promise . all ( [ this . _item . setReadyForReview ( ) , this . _item . approve ( this . _folderRepositoryManager . repository ) ] ) ;
713+ await this . _item . enableAutoMerge ( context . mergeMethod ) ;
714+ this . updateReviewers ( approveResult ) ;
715+
716+ const readiedResult : ReadyForReviewReply = {
717+ isDraft : readyResult . isDraft ,
718+ autoMerge : true ,
719+ reviewEvent : approveResult ,
720+ reviewers : this . _existingReviewers
721+ } ;
722+ await this . _postMessage ( {
723+ command : 'pr.readied-for-review' ,
724+ result : readiedResult
725+ } ) ;
726+ } catch ( e ) {
727+ vscode . window . showErrorMessage ( `Unable to set pull request ready for review. ${ formatError ( e ) } ` ) ;
728+ this . _throwError ( undefined , e . message ) ;
729+ }
701730 }
702731
703732 private async checkoutDefaultBranch ( message : IRequestMessage < string > ) : Promise < void > {
0 commit comments