@@ -3434,32 +3434,29 @@ export class ClineProvider
34343434 } )
34353435
34363436 // 4b) Persist child's initial status in globalState (saveClineMessages no longer writes status)
3437- await this . updateTaskHistory ( { id : child . taskId , status : "active" } as HistoryItem , { broadcast : false } )
3437+ const { historyItem : childHistory } = await this . getTaskWithId ( child . taskId )
3438+ await this . updateTaskHistory ( { ...childHistory , status : "active" } , { broadcast : false } )
34383439
34393440 // 5) Persist parent delegation metadata BEFORE the child starts writing.
3440- try {
3441- const { historyItem } = await this . getTaskWithId ( parentTaskId )
3442- const childIds = Array . from ( new Set ( [ ...( historyItem . childIds ?? [ ] ) , child . taskId ] ) )
3443- const updatedHistory : typeof historyItem = {
3444- ...historyItem ,
3445- status : "delegated" ,
3446- delegatedToId : child . taskId ,
3447- awaitingChildId : child . taskId ,
3448- childIds,
3449- }
3450- await this . updateTaskHistory ( updatedHistory )
3441+ // updateTaskHistory (globalState) is critical — without it, parent won't show as delegated
3442+ const { historyItem } = await this . getTaskWithId ( parentTaskId )
3443+ const childIds = Array . from ( new Set ( [ ...( historyItem . childIds ?? [ ] ) , child . taskId ] ) )
3444+ const updatedHistory = {
3445+ ...historyItem ,
3446+ status : "delegated" as const ,
3447+ delegatedToId : child . taskId ,
3448+ awaitingChildId : child . taskId ,
3449+ childIds,
3450+ }
3451+ await this . updateTaskHistory ( updatedHistory )
34513452
3452- // Write delegation metadata to per-task file (cross-process-safe source of truth)
3453+ // Per-task file backup is non-critical — globalState is the primary source
3454+ try {
34533455 const globalStoragePath = this . contextProxy . globalStorageUri . fsPath
34543456 await saveDelegationMeta ( {
34553457 taskId : parentTaskId ,
34563458 globalStoragePath,
3457- meta : {
3458- status : "delegated" ,
3459- delegatedToId : child . taskId ,
3460- awaitingChildId : child . taskId ,
3461- childIds,
3462- } ,
3459+ meta : { status : "delegated" , delegatedToId : child . taskId , awaitingChildId : child . taskId , childIds } ,
34633460 } )
34643461 await saveDelegationMeta ( {
34653462 taskId : child . taskId ,
@@ -3468,9 +3465,7 @@ export class ClineProvider
34683465 } )
34693466 } catch ( err ) {
34703467 this . log (
3471- `[delegateParentAndOpenChild] Failed to persist parent metadata for ${ parentTaskId } -> ${ child . taskId } : ${
3472- ( err as Error ) ?. message ?? String ( err )
3473- } `,
3468+ `[delegateParentAndOpenChild] Non-critical: Failed to write delegation metadata files for ${ parentTaskId } -> ${ child . taskId } : ${ ( err as Error ) ?. message ?? String ( err ) } ` ,
34743469 )
34753470 }
34763471
0 commit comments