@@ -2232,38 +2232,17 @@ function executeCommand(command: LooseRecord) {
22322232 . filter ( ( action : JsonValue ) => action . action === "remove_label" )
22332233 . map ( ( action : JsonValue ) => String ( action . label ?? "" ) )
22342234 . filter ( Boolean ) ;
2235- if ( pauseLabels . length > 0 ) {
2236- for ( const pausedLabel of pauseLabels ) {
2237- runGitHubBestEffortMutation (
2238- command ,
2239- "label_remove" ,
2240- { repository : command . repo , number : command . issue_number , label : pausedLabel } ,
2241- [
2242- "issue" ,
2243- "edit" ,
2244- String ( command . issue_number ) ,
2245- "--repo" ,
2246- command . repo ,
2247- "--remove-label" ,
2248- pausedLabel ,
2249- ] ,
2250- githubNotFoundNoMutation ,
2251- ) ;
2252- }
2253- command . target = {
2254- ...command . target ,
2255- labels : ( command . target ?. labels ?? [ ] ) . filter (
2256- ( label : JsonValue ) => ! pauseLabels . includes ( String ( label ) ) ,
2257- ) ,
2258- } ;
2259- }
2235+ const deferPauseLabelRemoval = command . intent === "maintainer_approve_automerge" ;
2236+ if ( pauseLabels . length > 0 && ! deferPauseLabelRemoval ) applyRemoveLabelActions ( command ) ;
22602237 const merge = executeAutomerge ( command ) ;
22612238 dispatched = { ...dispatched , merge } ;
22622239 command . actions = command . actions . map ( ( action : JsonValue ) =>
22632240 action . action === "label"
22642241 ? { ...action , status : "executed" , label : action . label }
22652242 : action . action === "remove_label"
2266- ? { ...action , status : "executed" , label : action . label }
2243+ ? deferPauseLabelRemoval
2244+ ? action
2245+ : { ...action , status : "executed" , label : action . label }
22672246 : action . action === "update_description_note"
22682247 ? { ...action , status : "executed" }
22692248 : action . action === "merge"
@@ -2306,12 +2285,16 @@ function executeCommand(command: LooseRecord) {
23062285 mode : command . target . mode ,
23072286 ...dispatchRepairActionStatus ( repair ) ,
23082287 } ) ;
2288+ if ( deferPauseLabelRemoval ) applyRemoveLabelActions ( command ) ;
23092289 if ( repair . status === "claimed" ) {
23102290 keepCommandClaimed ( command ) ;
23112291 return ;
23122292 }
23132293 }
23142294 }
2295+ if ( deferPauseLabelRemoval && merge . status === "executed" ) {
2296+ applyRemoveLabelActions ( command ) ;
2297+ }
23152298 }
23162299 if (
23172300 command . intent === "clawsweeper_needs_human" &&
@@ -4160,7 +4143,9 @@ function validateAutomergeReadiness({ command, view, target }: LooseRecord) {
41604143 if ( ! hasLabel ( target , AUTOMERGE_LABEL ) ) {
41614144 return "PR is not opted into ClawSweeper automerge" ;
41624145 }
4163- if ( hasLabel ( target , HUMAN_REVIEW_LABEL ) ) return "PR is paused for human review" ;
4146+ if ( hasLabel ( target , HUMAN_REVIEW_LABEL ) && command . intent !== "maintainer_approve_automerge" ) {
4147+ return "PR is paused for human review" ;
4148+ }
41644149 if ( view . state && view . state !== "OPEN" )
41654150 return `pull request is ${ String ( view . state ) . toLowerCase ( ) } ` ;
41664151 if ( view . isDraft ) return "pull request is draft" ;
0 commit comments