@@ -2966,13 +2966,35 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
29662966 } ) ;
29672967 }
29682968 const records = yield * projectionStore
2969- . getThreadRecords ( command . threadId , [ "runs" , "runtimeRequests" ] )
2969+ . getThreadRecords (
2970+ command . threadId ,
2971+ [ "runs" , "runtimeRequests" , "subagents" , "providerThreads" , "turnItems" ] ,
2972+ {
2973+ turnItemTypes : [ "command_execution" , "dynamic_tool" , "subagent" ] ,
2974+ turnItemStatuses : [ "pending" , "running" , "waiting" ] ,
2975+ } ,
2976+ )
29702977 . pipe ( mapDispatchError ( command ) ) ;
2978+ // Children inherit the parent's project and workspace; moving only the parent would strand them.
2979+ if ( records . subagents . some ( ( task ) => task . childThreadId !== null ) ) {
2980+ return yield * new OrchestratorDispatchError ( {
2981+ commandId : command . commandId ,
2982+ commandType : command . type ,
2983+ cause : `Thread ${ command . threadId } has child threads and cannot move to another project.` ,
2984+ } ) ;
2985+ }
29712986 if (
29722987 records . runs . some ( ( run ) =>
29732988 [ "preparing" , "queued" , "starting" , "running" , "waiting" ] . includes ( run . status ) ,
29742989 ) ||
2975- records . runtimeRequests . some ( ( request ) => request . status === "pending" )
2990+ records . runtimeRequests . some ( ( request ) => request . status === "pending" ) ||
2991+ derivePendingBackgroundWork ( {
2992+ latestRun : records . runs . findLast ( ( run ) => run . status !== "queued" ) ,
2993+ providerThreads : records . providerThreads ,
2994+ turnItems : records . turnItems ,
2995+ activeProviderThreadId : thread . activeProviderThreadId ,
2996+ runs : records . runs ,
2997+ } ) . length > 0
29762998 ) {
29772999 return yield * new OrchestratorDispatchError ( {
29783000 commandId : command . commandId ,
@@ -3409,7 +3431,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
34093431 snooze : command . limitRecovery . snooze ?? previousRecovery ?. snooze ?? false ,
34103432 requestId : command . commandId ,
34113433 } ;
3412- return {
3434+ const updated : OrchestrationV2AppThread = {
34133435 ...thread ,
34143436 ...( command . title === undefined ? { } : { title : command . title } ) ,
34153437 ...( command . limitRecovery === undefined ? { } : { limitRecovery } ) ,
@@ -3471,6 +3493,15 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
34713493 : { } ) ,
34723494 updatedAt : now ,
34733495 } ;
3496+ // Watches read through the project's checkout, which no longer holds these links.
3497+ return movesProject
3498+ ? {
3499+ ...updated ,
3500+ pullRequests : updated . pullRequests ?. map ( ( link ) =>
3501+ withPullRequestWatch ( link , undefined ) ,
3502+ ) ,
3503+ }
3504+ : updated ;
34743505 }
34753506 case "thread.pull-request.link" :
34763507 case "thread.pull-request.unlink" :
0 commit comments