@@ -438,7 +438,7 @@ class TaskTracker {
438438 children ?: ( input : { path : { id : string } } ) => Promise < { data ?: unknown } | unknown [ ] >
439439 status ?: ( ) => Promise < { data ?: unknown } | Record < string , unknown > >
440440 }
441- if ( ! session . children || ! session . status ) return
441+ if ( ! session . children ) return
442442 let childIDs : string [ ]
443443 try {
444444 const result = await session . children ( { path : { id : parentSessionID } } )
@@ -447,7 +447,8 @@ class TaskTracker {
447447 } catch {
448448 return
449449 }
450- if ( childIDs . length === 0 ) return
450+ this . markAbsentRunningChildren ( parentSessionID , new Set ( childIDs ) )
451+ if ( childIDs . length === 0 || ! session . status ) return
451452 let statuses : Record < string , unknown >
452453 try {
453454 const result = await session . status ( )
@@ -540,6 +541,15 @@ class TaskTracker {
540541 if ( hold . expiresAt > now ) continue
541542 this . snapshotIdleHolds . delete ( key )
542543 this . settledSnapshotIdleTasks . add ( key )
544+ const task = this . tasks . get ( hold . taskID )
545+ if ( task ?. parentSessionID === hold . parentSessionID && task . state === "running" ) this . tasks . delete ( hold . taskID )
546+ }
547+ }
548+
549+ private markAbsentRunningChildren ( parentSessionID : string , liveChildIDs : Set < string > ) {
550+ for ( const task of this . tasks . values ( ) ) {
551+ if ( task . parentSessionID !== parentSessionID || task . state !== "running" || liveChildIDs . has ( task . taskID ) ) continue
552+ this . markSnapshotIdle ( parentSessionID , task . taskID )
543553 }
544554 }
545555
@@ -662,6 +672,7 @@ const server: Plugin = async ({ client }, options?: Options) => {
662672 if ( current . status === "active" ) await pauseGoalForPlanMode ( sessionID )
663673 return
664674 }
675+ if ( busySessions . has ( sessionID ) ) return
665676 if ( ! fromTaskDeferral && taskDeferredSessions . has ( sessionID ) ) {
666677 scheduleSettledContinuation ( sessionID )
667678 return
0 commit comments