@@ -301,6 +301,9 @@ describe("ClineProvider.markDelegatedChildInterrupted() — live eviction path",
301301 return { historyItem : { id : childTaskId , status : "interrupted" , parentTaskId } }
302302 } )
303303
304+ const realRunDelegation = ClineProvider . prototype [ "runDelegationTransition" ] . bind ( {
305+ delegationTransitionLocks : new Map ( ) ,
306+ } )
304307 const provider = makeProviderStub ( {
305308 clineStack : [ ] as any [ ] ,
306309 taskEventListeners : new Map ( ) ,
@@ -320,15 +323,13 @@ describe("ClineProvider.markDelegatedChildInterrupted() — live eviction path",
320323 return undefined
321324 } ) ,
322325 } ,
326+ // Wrap the real runDelegationTransition to set lockAcquired before the lock fires
327+ runDelegationTransition : async ( parentId : string , fn : ( ) => Promise < void > ) => {
328+ lockAcquired = true
329+ return realRunDelegation ( parentId , fn )
330+ } ,
323331 } )
324332
325- // Patch runDelegationTransition to set lockAcquired before calling fn
326- const realRunDelegation = provider [ "runDelegationTransition" ] . bind ( provider )
327- provider [ "runDelegationTransition" ] = async ( _parentId : string , fn : ( ) => Promise < void > ) => {
328- lockAcquired = true
329- return realRunDelegation ( _parentId , fn )
330- }
331-
332333 await ( ClineProvider . prototype as any ) . markDelegatedChildInterrupted . call ( provider , {
333334 childTaskId,
334335 parentTaskId,
@@ -642,7 +643,7 @@ describe("onTaskCompleted callback — writes completed status before re-emittin
642643 `[onTaskCompleted] Failed to write completed status for ${ taskId } : ${ err instanceof Error ? err . message : String ( err ) } ` ,
643644 )
644645 }
645- provider [ " emit" ] ( "TaskCompleted" , taskId , { } , { } )
646+ emit ( "TaskCompleted" , taskId , { } , { } )
646647 }
647648
648649 return { onTaskCompleted, updateTaskHistory, emit, log }
0 commit comments