@@ -32,6 +32,7 @@ import {
3232 shouldCollapseUserMessage ,
3333 resolveAssistantMessageCopyState ,
3434 type MessagesTimelineRow ,
35+ type TimelineLatestRun ,
3536 workEntryDisplayLabel ,
3637} from "./MessagesTimeline.logic" ;
3738
@@ -4479,7 +4480,16 @@ describe("live subagents after their parent turn settles", () => {
44794480 prompt : `Inspect ${ id } ` ,
44804481 result : null ,
44814482 } ) ;
4482- const rowsFor = ( children : ReadonlyArray < OrchestrationV2TurnItem > ) =>
4483+ const rowsFor = (
4484+ children : ReadonlyArray < OrchestrationV2TurnItem > ,
4485+ afterReply : ReadonlyArray < OrchestrationV2TurnItem > = [ ] ,
4486+ latestRun : TimelineLatestRun = {
4487+ runId,
4488+ status : "completed" ,
4489+ startedAt : DateTime . formatIso ( at ( 0 ) ) ,
4490+ completedAt : DateTime . formatIso ( at ( 8 ) ) ,
4491+ } ,
4492+ ) =>
44834493 deriveMessagesTimelineRows ( {
44844494 timelineEntries : deriveTimelineEntriesFromVisibleTurnItems ( {
44854495 visibleTurnItems : (
@@ -4519,16 +4529,12 @@ describe("live subagents after their parent turn settles", () => {
45194529 text : "Both children are running." ,
45204530 streaming : false ,
45214531 } ,
4532+ ...afterReply ,
45224533 ] satisfies OrchestrationV2TurnItem [ ]
45234534 ) . map ( projected ) ,
45244535 optimisticMessages : [ ] ,
45254536 } ) ,
4526- latestRun : {
4527- runId,
4528- status : "completed" ,
4529- startedAt : DateTime . formatIso ( at ( 0 ) ) ,
4530- completedAt : DateTime . formatIso ( at ( 8 ) ) ,
4531- } ,
4537+ latestRun,
45324538 isWorking : false ,
45334539 turnDiffSummaries : [ ] ,
45344540 supportsConversationRollback : false ,
@@ -4547,6 +4553,19 @@ describe("live subagents after their parent turn settles", () => {
45474553 } ,
45484554 ) ;
45494555
4556+ it ( "keeps the turn's duration when a background child delegates after it settles" , ( ) => {
4557+ // The child's completion woke a later run, so this run's duration comes from its entries.
4558+ const rows = rowsFor ( [ ] , [ child ( "late" , 50 , "completed" ) ] , {
4559+ runId : RunId . make ( "wake-run" ) ,
4560+ status : "completed" ,
4561+ startedAt : DateTime . formatIso ( at ( 55 ) ) ,
4562+ completedAt : DateTime . formatIso ( at ( 58 ) ) ,
4563+ } ) ;
4564+ expect ( rows . find ( ( row ) => row . kind === "turn-fold" ) ) . toMatchObject ( {
4565+ label : "Worked for 8s" ,
4566+ } ) ;
4567+ } ) ;
4568+
45504569 it ( "keeps a launch batch visible while any member is still running" , ( ) => {
45514570 const rows = rowsFor ( [ child ( "done" , 3 , "completed" ) , child ( "live" , 4 , "running" ) ] ) ;
45524571 expect ( rows . map ( ( row ) => row . id ) ) . toEqual ( [ "user" , `turn-fold:${ runId } ` , "done" , "assistant" ] ) ;
0 commit comments