@@ -530,4 +530,49 @@ describeControlUiE2e("Control UI session management mocked Gateway E2E", () => {
530530 await context . close ( ) ;
531531 }
532532 } ) ;
533+
534+ it ( "only paints a sidebar session active on chat routes" , async ( ) => {
535+ const baseTime = Date . parse ( "2026-07-01T16:00:00.000Z" ) ;
536+ const context = await browser . newContext ( {
537+ locale : "en-US" ,
538+ serviceWorkers : "block" ,
539+ viewport : { height : 900 , width : 1280 } ,
540+ } ) ;
541+ const page = await context . newPage ( ) ;
542+ await installMockGateway ( page , {
543+ methodResponses : {
544+ "sessions.list" : sessionsListResponse ( [
545+ sessionRow ( "agent:main:main" , "Main" , baseTime ) ,
546+ sessionRow ( "agent:main:release" , "Release planning" , baseTime - 60_000 ) ,
547+ ] ) ,
548+ } ,
549+ sessionKey : "agent:main:main" ,
550+ } ) ;
551+
552+ try {
553+ await page . goto ( `${ server . baseUrl } overview` ) ;
554+ const activeRows = page . locator ( ".sidebar-recent-session--active" ) ;
555+ const mainRow = page . locator ( '.sidebar-recent-session[data-session-key="agent:main:main"]' ) ;
556+ await mainRow . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
557+ await expect . poll ( ( ) => activeRows . count ( ) ) . toBe ( 0 ) ;
558+
559+ await page . goto ( `${ server . baseUrl } config` ) ;
560+ await mainRow . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
561+ await expect . poll ( ( ) => activeRows . count ( ) ) . toBe ( 0 ) ;
562+
563+ await page . goto ( `${ server . baseUrl } chat?session=agent%3Amain%3Amain` ) ;
564+ await expect . poll ( ( ) => activeRows . count ( ) ) . toBe ( 1 ) ;
565+ await expect
566+ . poll ( ( ) => activeRows . first ( ) . getAttribute ( "data-session-key" ) )
567+ . toBe ( "agent:main:main" ) ;
568+
569+ await page . goto ( `${ server . baseUrl } chat` ) ;
570+ await expect . poll ( ( ) => activeRows . count ( ) ) . toBe ( 1 ) ;
571+ await expect
572+ . poll ( ( ) => activeRows . first ( ) . getAttribute ( "data-session-key" ) )
573+ . toBe ( "agent:main:main" ) ;
574+ } finally {
575+ await context . close ( ) ;
576+ }
577+ } ) ;
533578} ) ;
0 commit comments