@@ -36,6 +36,7 @@ const runningSubagent = {
3636 status : "running" ,
3737 title : "Map model routing code" ,
3838 agentId : "main" ,
39+ sessionKey : chatSessionKey ,
3940 ownerKey : chatSessionKey ,
4041 childSessionKey : "agent:main:subagent:routing" ,
4142 createdAt : baseTime - 5_000 ,
@@ -323,6 +324,111 @@ suite.define(() => {
323324 ) ;
324325 } ) ;
325326
327+ it ( "streams two subagent activity rows and retains final diff chips" , async ( ) => {
328+ const activityDir = path . join ( artifactDir , "subagent-activity" ) ;
329+ await mkdir ( activityDir , { recursive : true } ) ;
330+ await suite . withPage (
331+ {
332+ locale : "en-US" ,
333+ recordVideo : { dir : activityDir , size : { width : 1280 , height : 800 } } ,
334+ serviceWorkers : "block" ,
335+ viewport : { width : 1280 , height : 800 } ,
336+ } ,
337+ async ( { page } ) => {
338+ const gateway = await installMockGateway ( page , {
339+ historyMessages : [
340+ {
341+ content : [ { type : "text" , text : "Parallel subagent activity proof." } ] ,
342+ role : "assistant" ,
343+ timestamp : Date . now ( ) ,
344+ } ,
345+ ] ,
346+ methodResponses : { "tasks.list" : { tasks : [ ] } } ,
347+ } ) ;
348+
349+ const response = await page . goto ( `${ suite . server . baseUrl } chat` ) ;
350+ expect ( response ?. status ( ) ) . toBe ( 200 ) ;
351+ await page . getByText ( "Parallel subagent activity proof." ) . waitFor ( { timeout : 10_000 } ) ;
352+
353+ const first = {
354+ ...runningSubagent ,
355+ id : "task-parallel-one" ,
356+ taskId : "task-parallel-one" ,
357+ childSessionKey : "agent:main:subagent:parallel-one" ,
358+ title : "Review session ownership" ,
359+ lastActivity : "Reviewing session ownership" ,
360+ diffStat : { files : 2 , added : 14 , removed : 3 } ,
361+ } ;
362+ const second = {
363+ ...runningSubagent ,
364+ id : "task-parallel-two" ,
365+ taskId : "task-parallel-two" ,
366+ childSessionKey : "agent:main:subagent:parallel-two" ,
367+ title : "Review tool card rendering" ,
368+ lastActivity : "Checking tool card rendering" ,
369+ diffStat : { files : 1 , added : 5 , removed : 0 } ,
370+ } ;
371+ await gateway . emitGatewayEvent ( "task" , { action : "upserted" , task : first } ) ;
372+ await gateway . emitGatewayEvent ( "task" , { action : "upserted" , task : second } ) ;
373+
374+ const activity = page . locator ( ".chat-subagent-activity" ) ;
375+ await expect . poll ( ( ) => activity . locator ( ".chat-subagent-activity__row" ) . count ( ) ) . toBe ( 2 ) ;
376+ const firstRow = activity . locator ( '[data-subagent-task-id="task-parallel-one"]' ) ;
377+ const secondRow = activity . locator ( '[data-subagent-task-id="task-parallel-two"]' ) ;
378+ expect ( await firstRow . textContent ( ) ) . toContain ( "Reviewing session ownership" ) ;
379+ expect ( await secondRow . textContent ( ) ) . toContain ( "Checking tool card rendering" ) ;
380+ expect ( await firstRow . locator ( ".chat-diffstat__add" ) . textContent ( ) ) . toBe ( "+14" ) ;
381+ expect ( await firstRow . locator ( ".chat-diffstat__del" ) . textContent ( ) ) . toBe ( "-3" ) ;
382+ await page . screenshot ( {
383+ path : path . join ( activityDir , "01-two-subagents-streaming.png" ) ,
384+ fullPage : true ,
385+ } ) ;
386+
387+ await gateway . emitGatewayEvent ( "task" , {
388+ action : "upserted" ,
389+ task : {
390+ ...first ,
391+ updatedAt : baseTime + 1_000 ,
392+ lastActivity : "Cross-checking requester ownership" ,
393+ } ,
394+ } ) ;
395+ await firstRow . getByText ( "Cross-checking requester ownership" ) . waitFor ( ) ;
396+
397+ await gateway . emitGatewayEvent ( "task" , {
398+ action : "upserted" ,
399+ task : {
400+ id : first . id ,
401+ taskId : first . taskId ,
402+ kind : first . kind ,
403+ runtime : first . runtime ,
404+ status : "completed" ,
405+ title : first . title ,
406+ agentId : first . agentId ,
407+ sessionKey : first . sessionKey ,
408+ ownerKey : first . ownerKey ,
409+ childSessionKey : first . childSessionKey ,
410+ createdAt : first . createdAt ,
411+ startedAt : first . startedAt ,
412+ updatedAt : baseTime + 2_000 ,
413+ endedAt : baseTime + 2_000 ,
414+ terminalSummary : "Ownership review complete" ,
415+ } ,
416+ } ) ;
417+
418+ await firstRow . getByText ( "Subagent finished" ) . waitFor ( ) ;
419+ expect ( await firstRow . textContent ( ) ) . toContain ( "Ownership review complete" ) ;
420+ expect ( await firstRow . locator ( ".chat-diffstat__add" ) . textContent ( ) ) . toBe ( "+14" ) ;
421+ expect ( await firstRow . locator ( ".chat-diffstat__del" ) . textContent ( ) ) . toBe ( "-3" ) ;
422+ expect ( await secondRow . textContent ( ) ) . toContain ( "Subagent working" ) ;
423+ expect ( await secondRow . textContent ( ) ) . toContain ( "Checking tool card rendering" ) ;
424+ await page . screenshot ( {
425+ path : path . join ( activityDir , "02-one-subagent-finished.png" ) ,
426+ fullPage : true ,
427+ } ) ;
428+ } ,
429+ ) ;
430+ } ) ;
431+
326432 it ( "shows one detached exec after the agent turn ends" , async ( ) => {
327433 await suite . withPage (
328434 {
0 commit comments