@@ -786,6 +786,18 @@ export function pausedModeStatusBlocksReplay({
786786 ) ;
787787}
788788
789+ export function maintainerModeCommandCanResumePausedMode ( {
790+ command,
791+ entries = [ ] ,
792+ } : LooseRecord = { } ) {
793+ if ( command ?. trusted_bot ) return false ;
794+ if ( ! [ "autofix" , "automerge" ] . includes ( String ( command ?. intent ?? "" ) ) ) return false ;
795+ const commandAt = repairLoopControlTime ( command ) ;
796+ if ( ! commandAt ) return false ;
797+ const pauseAt = latestRepairLoopPauseTime ( entries , command ) ;
798+ return pauseAt > 0 && commandAt > pauseAt ;
799+ }
800+
789801export function isMaintainerCommandAllowed ( {
790802 authorAssociation,
791803 repositoryPermission = null ,
@@ -2393,6 +2405,28 @@ export function repairLoopStopPauseReason({ command, entries = [] }: LooseRecord
23932405 return "ClawSweeper automation was paused by a later /clawsweeper stop command" ;
23942406}
23952407
2408+ function latestRepairLoopPauseTime ( entries : JsonValue , command : LooseRecord ) {
2409+ if ( ! Array . isArray ( entries ) ) return 0 ;
2410+ let latest = 0 ;
2411+ for ( const entry of entries ) {
2412+ if ( ! entry || typeof entry !== "object" ) continue ;
2413+ if ( entry . repo !== command ?. repo ) continue ;
2414+ if ( Number ( entry . issue_number ) !== Number ( command ?. issue_number ) ) continue ;
2415+ if ( ! isRepairLoopPauseEntry ( entry ) ) continue ;
2416+ latest = Math . max ( latest , repairLoopControlTime ( entry ) ) ;
2417+ }
2418+ return latest ;
2419+ }
2420+
2421+ function isRepairLoopPauseEntry ( entry : LooseRecord ) {
2422+ if ( String ( entry . intent ?? "" ) === "stop" ) return true ;
2423+ if ( String ( entry . intent ?? "" ) !== "clawsweeper_needs_human" ) return false ;
2424+ return ( entry . actions ?? [ ] ) . some (
2425+ ( action : JsonValue ) =>
2426+ action . action === "label" && String ( action . label ?? "" ) === HUMAN_REVIEW_LABEL ,
2427+ ) ;
2428+ }
2429+
23962430function latestRepairLoopControlTime ( entries : JsonValue , command : LooseRecord , intents : string [ ] ) {
23972431 if ( ! Array . isArray ( entries ) ) return 0 ;
23982432 const intentSet = new Set ( intents ) ;
0 commit comments