@@ -3454,6 +3454,33 @@ function deriveRows(entries: TimelineEntry[], summarizeSubagents = true) {
34543454}
34553455
34563456describe ( "subagent summary rows" , ( ) => {
3457+ it . each ( [
3458+ { statuses : [ ] , count : 1 , working : 0 , failed : 0 } ,
3459+ { statuses : [ "completed" ] , count : 2 , working : 0 , failed : 0 } ,
3460+ { statuses : [ "running" ] , count : 2 , working : 1 , failed : 0 } ,
3461+ { statuses : [ "failed" ] , count : 2 , working : 0 , failed : 1 } ,
3462+ ] as const ) (
3463+ "keeps idle agents distinct alongside $statuses" ,
3464+ ( { statuses, count, working, failed } ) => {
3465+ const result = deriveRows ( [
3466+ subagentTimelineEntry ( "idle-agent" , "run-1" , "idle" ) ,
3467+ ...statuses . map ( ( status , index ) =>
3468+ subagentTimelineEntry ( `agent-${ index } ` , "run-1" , status ) ,
3469+ ) ,
3470+ ] ) ;
3471+
3472+ expect ( result ) . toMatchObject ( [
3473+ {
3474+ kind : "agent-spawn" ,
3475+ count,
3476+ idle : 1 ,
3477+ working,
3478+ failed,
3479+ } ,
3480+ ] ) ;
3481+ } ,
3482+ ) ;
3483+
34573484 it ( "groups local agents by run without swallowing inherited or unowned entries" , ( ) => {
34583485 const result = deriveRows ( [
34593486 subagentTimelineEntry ( "agent-a" , "run-1" , "running" ) ,
@@ -3481,6 +3508,21 @@ describe("subagent summary rows", () => {
34813508 ] ) ;
34823509 } ) ;
34833510
3511+ it ( "refreshes a cached summary when an idle agent completes" , ( ) => {
3512+ const idle = computeStableMessagesTimelineRows (
3513+ deriveRows ( [ subagentTimelineEntry ( "agent" , "run-1" , "idle" ) ] ) ,
3514+ { byId : new Map ( ) , result : [ ] } ,
3515+ ) ;
3516+ const completed = computeStableMessagesTimelineRows (
3517+ deriveRows ( [ subagentTimelineEntry ( "agent" , "run-1" , "completed" ) ] ) ,
3518+ idle ,
3519+ ) ;
3520+
3521+ expect ( idle . result ) . toMatchObject ( [ { idle : 1 , working : 0 } ] ) ;
3522+ expect ( completed . result ) . toMatchObject ( [ { idle : 0 , working : 0 } ] ) ;
3523+ expect ( completed . result [ 0 ] ) . not . toBe ( idle . result [ 0 ] ) ;
3524+ } ) ;
3525+
34843526 it ( "keeps superseded and replacement attempts in separate rosters" , ( ) => {
34853527 const runId = "run-steered" as never ;
34863528 const supersededAttempt = {
0 commit comments