@@ -564,6 +564,41 @@ describe("Android delivery routing", () => {
564564 } ) . pipe ( Effect . provide ( h . layer ) ) ;
565565 } ) ;
566566
567+ for ( const phase of [ "waiting_for_approval" , "waiting_for_input" ] as const ) {
568+ it . effect ( `keeps ${ phase } visible when five newer agents are running` , ( ) => {
569+ const h = harness ( ) ;
570+ const running = Array . from ( { length : 5 } , ( _ , index ) => ( {
571+ ...state ,
572+ threadId : ThreadId . make ( `running-${ index } ` ) ,
573+ updatedAt : "1970-01-01T00:00:01.000Z" ,
574+ } ) ) ;
575+ const waiting : RelayAgentActivityState = {
576+ ...state ,
577+ threadId : ThreadId . make ( "waiting" ) ,
578+ threadTitle : "Needs your response" ,
579+ phase,
580+ deepLink : "/threads/env/waiting" ,
581+ } ;
582+ h . current . state = running [ 0 ] ! ;
583+ h . current . otherStates = [ ...running . slice ( 1 ) , waiting ] ;
584+ h . current . target . last_aggregate_json = encodeJson ( aggregateFor ( running ) ) ;
585+ return Effect . gen ( function * ( ) {
586+ yield * TestClock . adjust ( "1 second" ) ;
587+ const delivery = yield * FcmDeliveries ;
588+ yield * delivery . process ( { ...h . job , state : waiting } ) ;
589+ expect ( h . sent ) . toHaveLength ( 1 ) ;
590+ expect ( h . sent [ 0 ] ?. alert ) . toBe ( true ) ;
591+ expect ( h . sent [ 0 ] ?. data . activity_title ) . toBe ( "6 active agents · 1 needs attention" ) ;
592+ expect ( h . sent [ 0 ] ?. data . activity_line_0 ) . toContain ( "\tNeeds your response\tProject" ) ;
593+ expect ( h . sent [ 0 ] ?. data . activity_path ) . toBe ( waiting . deepLink ) ;
594+ expect ( h . sent [ 0 ] ?. data . alert_path ) . toBe ( waiting . deepLink ) ;
595+ expect (
596+ Object . keys ( h . sent [ 0 ] ! . data ) . filter ( ( key ) => key . startsWith ( "activity_line_" ) ) ,
597+ ) . toHaveLength ( 5 ) ;
598+ } ) . pipe ( Effect . provide ( h . layer ) ) ;
599+ } ) ;
600+ }
601+
567602 it ( "shows five rows with attention then failure first, including project and status" , ( ) => {
568603 const aggregate = aggregateFor ( [
569604 state ,
0 commit comments