@@ -829,6 +829,18 @@ test.describe("Working", () => {
829829 { completed : false } ,
830830 ) ,
831831 ] ,
832+ shellCommands : [
833+ {
834+ id : "sh_working_background" ,
835+ status : "running" ,
836+ command : "sleep 10" ,
837+ cwd : directory ,
838+ shell : "bash" ,
839+ file : "/tmp/working-background.out" ,
840+ metadata : { sessionID } ,
841+ time : { started : 2 } ,
842+ } ,
843+ ] ,
832844 } )
833845 const working = page . locator ( '[data-component="session-working"]' )
834846
@@ -998,6 +1010,18 @@ test.describe("background shortcut", () => {
9981010 time : { created : 2 , completed : 3 } ,
9991011 } ,
10001012 ] ,
1013+ shellCommands : [
1014+ {
1015+ id : "shell_backgrounded" ,
1016+ status : "running" ,
1017+ command : "sleep 120" ,
1018+ cwd : directory ,
1019+ shell : "bash" ,
1020+ file : "/tmp/background.out" ,
1021+ metadata : { sessionID } ,
1022+ time : { started : 2 } ,
1023+ } ,
1024+ ] ,
10011025 } )
10021026
10031027 // The open menu hides the rest of the page from the accessibility tree, the capsule included.
@@ -1029,6 +1053,50 @@ test.describe("background shortcut", () => {
10291053 } )
10301054 }
10311055
1056+ test ( "counts a backgrounded subagent while its session runs, not while its call still reads running" , async ( {
1057+ page,
1058+ } ) => {
1059+ const childID = "ses_background_stale_call"
1060+
1061+ // As after a lost completion notice: the call still reads running, while the child session has finished.
1062+ const timeline = await setupTimeline ( page , {
1063+ settings : { timelineDetail : detailed } ,
1064+ sessionMessages : [
1065+ user ,
1066+ {
1067+ id : "msg_stale_call" ,
1068+ type : "assistant" ,
1069+ agent : "build" ,
1070+ model : { id : "model" , providerID : "provider" } ,
1071+ content : [
1072+ {
1073+ type : "tool" ,
1074+ id : "call_stale" ,
1075+ name : "subagent" ,
1076+ state : {
1077+ status : "completed" ,
1078+ input : { description : "Stale task" , agent : "explore" , background : true } ,
1079+ content : [ { type : "text" , text : "working" } ] ,
1080+ metadata : { sessionID : childID , status : "running" } ,
1081+ } ,
1082+ time : { created : 2 , completed : 3 } ,
1083+ } ,
1084+ ] ,
1085+ time : { created : 2 , completed : 3 } ,
1086+ } ,
1087+ ] ,
1088+ sessions : [ session ( ) , session ( { id : childID , parentID : sessionID , title : "Stale task" , agent : "explore" } ) ] ,
1089+ } )
1090+ const capsule = page . locator ( '[data-slot="session-activity-chip"]' )
1091+
1092+ await expect ( page . locator ( '[data-timeline-part-id="call_stale"]' ) ) . toContainText ( "Stale task (background)" )
1093+ await expect ( capsule ) . toHaveCount ( 0 )
1094+ await timeline . transport . send ( status ( "busy" , 1 , childID ) )
1095+ await expect ( page . getByRole ( "button" , { name : "1 subagent" , exact : true } ) ) . toBeVisible ( )
1096+ await timeline . transport . send ( status ( "idle" , 1 , childID ) )
1097+ await expect ( capsule ) . toHaveCount ( 0 )
1098+ } )
1099+
10321100 test ( "separates blocking and already-backgrounded work into two rows" , async ( { page } ) => {
10331101 const backgroundID = "ses_background_existing"
10341102 const blockingID = "ses_background_blocking"
0 commit comments