@@ -4888,6 +4888,113 @@ describe("live subagents after their parent turn settles", () => {
48884888 } ) ;
48894889} ) ;
48904890
4891+ describe ( "parent run waiting on foreground subagents" , ( ) => {
4892+ const runId = RunId . make ( "parent-run" ) ;
4893+ const threadId = ThreadId . make ( "parent-thread" ) ;
4894+ const at = ( second : number ) =>
4895+ DateTime . makeUnsafe ( `2026-10-06T10:00:${ String ( second ) . padStart ( 2 , "0" ) } Z` ) ;
4896+ const base = ( id : string , second : number ) => ( {
4897+ id : TurnItemId . make ( id ) ,
4898+ threadId,
4899+ runId,
4900+ nodeId : null ,
4901+ providerThreadId : null ,
4902+ providerTurnId : ProviderTurnId . make ( "parent-provider-turn" ) ,
4903+ nativeItemRef : null ,
4904+ parentItemId : null ,
4905+ ordinal : second ,
4906+ title : null ,
4907+ startedAt : at ( second ) ,
4908+ completedAt : at ( second ) ,
4909+ updatedAt : at ( second ) ,
4910+ } ) ;
4911+ const child = ( id : string , second : number ) : OrchestrationV2TurnItem => ( {
4912+ ...base ( id , second ) ,
4913+ status : "running" ,
4914+ completedAt : null ,
4915+ type : "subagent" ,
4916+ subagentId : NodeId . make ( id ) ,
4917+ origin : "provider_native" ,
4918+ driver : ProviderDriverKind . make ( "opencode" ) ,
4919+ providerInstanceId : ProviderInstanceId . make ( "opencode" ) ,
4920+ childThreadId : null ,
4921+ prompt : `Read ${ id } ` ,
4922+ result : null ,
4923+ } ) ;
4924+
4925+ const liveRow = ( later : ReadonlyArray < OrchestrationV2TurnItem > , toolCallVisibility ?: "hideAll" ) =>
4926+ deriveMessagesTimelineRows ( {
4927+ timelineEntries : deriveTimelineEntriesFromVisibleTurnItems ( {
4928+ visibleTurnItems : (
4929+ [
4930+ {
4931+ ...base ( "user" , 0 ) ,
4932+ status : "completed" ,
4933+ type : "user_message" ,
4934+ messageId : MessageId . make ( "user" ) ,
4935+ createdBy : "user" ,
4936+ creationSource : "web" ,
4937+ inputIntent : "turn_start" ,
4938+ text : "Research these in parallel" ,
4939+ attachments : [ ] ,
4940+ } ,
4941+ {
4942+ ...base ( "assistant" , 1 ) ,
4943+ status : "completed" ,
4944+ type : "assistant_message" ,
4945+ messageId : MessageId . make ( "assistant" ) ,
4946+ text : "Dispatching three subagents." ,
4947+ streaming : false ,
4948+ } ,
4949+ child ( "a" , 2 ) ,
4950+ { ...child ( "b" , 3 ) , status : "completed" , completedAt : at ( 3 ) } ,
4951+ child ( "c" , 4 ) ,
4952+ ...later ,
4953+ ] satisfies OrchestrationV2TurnItem [ ]
4954+ ) . map ( ( item ) => ( {
4955+ position : item . ordinal ,
4956+ visibility : "local" as const ,
4957+ sourceThreadId : threadId ,
4958+ sourceItemId : item . id ,
4959+ item,
4960+ } ) ) ,
4961+ optimisticMessages : [ ] ,
4962+ } ) ,
4963+ latestRun : {
4964+ runId,
4965+ status : "running" ,
4966+ startedAt : DateTime . formatIso ( at ( 0 ) ) ,
4967+ completedAt : null ,
4968+ } ,
4969+ isWorking : true ,
4970+ activeTurnStartedAt : DateTime . formatIso ( at ( 0 ) ) ,
4971+ turnDiffSummaries : [ ] ,
4972+ supportsConversationRollback : false ,
4973+ ...( toolCallVisibility ? { toolCallVisibility } : { } ) ,
4974+ } ) . find ( ( row ) => row . id === "live-activity-row" ) ;
4975+ const thinking = {
4976+ kind : "thinking" ,
4977+ id : "live-activity-row" ,
4978+ createdAt : DateTime . formatIso ( at ( 0 ) ) ,
4979+ } ;
4980+
4981+ it ( "names the running children while the open run has done nothing since launching them" , ( ) => {
4982+ expect ( liveRow ( [ ] ) ) . toEqual ( { ...thinking , label : "Waiting on 2 subagents" } ) ;
4983+ expect ( liveRow ( [ ] , "hideAll" ) ) . toEqual ( { ...thinking , label : "Waiting on 2 subagents" } ) ;
4984+ } ) ;
4985+
4986+ it ( "keeps Thinking when a hidden newer parent command follows the children" , ( ) => {
4987+ const command : OrchestrationV2TurnItem = {
4988+ ...base ( "command" , 5 ) ,
4989+ status : "running" ,
4990+ completedAt : null ,
4991+ type : "command_execution" ,
4992+ input : "sleep 5" ,
4993+ } ;
4994+ expect ( liveRow ( [ command ] , "hideAll" ) ) . toEqual ( thinking ) ;
4995+ } ) ;
4996+ } ) ;
4997+
48914998describe ( "subagent continued by a later turn" , ( ) => {
48924999 const threadId = ThreadId . make ( "parent-thread" ) ;
48935000 const run1 = RunId . make ( "run-1" ) ;
0 commit comments