@@ -78,6 +78,11 @@ function scenario(): ControlUiMockGatewayScenario {
7878 additions : 4 ,
7979 deletions : 2 ,
8080 } ,
81+ "sessions.companion.ask" : {
82+ answer : "The mobile side chat stayed inside its panel." ,
83+ ts : Date . UTC ( 2026 , 7 , 16 , 12 , 0 ) ,
84+ } ,
85+ "sessions.companion.state" : { exchanges : [ ] } ,
8186 "sessions.files.list" : {
8287 browser : {
8388 path : "ui/src/pages/chat" ,
@@ -872,13 +877,15 @@ suite.define(() => {
872877 } ,
873878 async ( { page } ) => {
874879 await seedSettings ( page , "light" ) ;
875- await installMockGateway ( page , scenario ( ) ) ;
880+ const gateway = await installMockGateway ( page , scenario ( ) ) ;
876881 await page . goto ( `${ suite . server . baseUrl } chat` ) ;
877882 await page . locator ( ".chat-group" ) . first ( ) . waitFor ( ) ;
878883 await page . locator ( ".chat-side-panel-toggle" ) . click ( ) ;
879884 await openFromEmpty ( page , "Files" ) ;
880885 await openFromPlus ( page , "Terminal" ) ;
881- await expect . poll ( async ( ) => tabLabels ( page ) ) . toEqual ( [ "Files" , "Terminal" ] ) ;
886+ await openFromPlus ( page , "Side chat" ) ;
887+ await selectTab ( page , "Side chat" ) ;
888+ await expect . poll ( async ( ) => tabLabels ( page ) ) . toEqual ( [ "Files" , "Terminal" , "Side chat" ] ) ;
882889 await expect . poll ( ( ) => narrowestRailTabLabel ( page ) ) . toBeGreaterThanOrEqual ( 24 ) ;
883890
884891 const geometry = await sidePanel ( page ) . evaluate ( ( element ) => {
@@ -889,6 +896,48 @@ suite.define(() => {
889896 expect ( geometry . right ) . toBeLessThanOrEqual ( geometry . viewport + 1 ) ;
890897 expect ( geometry . width ) . toBeGreaterThan ( 300 ) ;
891898
899+ const companion = sidePanel ( page ) . locator ( "openclaw-chat-session-rail" ) ;
900+ const companionGeometry = await companion . locator ( ".chat-session-rail" ) . evaluate ( ( rail ) => {
901+ const body = rail . closest ( ".side-panel__body" ) ;
902+ const bodyRect = body ?. getBoundingClientRect ( ) ;
903+ const railRect = rail . getBoundingClientRect ( ) ;
904+ return {
905+ bodyBottom : bodyRect ?. bottom ?? 0 ,
906+ bodyTop : bodyRect ?. top ?? 0 ,
907+ railBottom : railRect . bottom ,
908+ railTop : railRect . top ,
909+ } ;
910+ } ) ;
911+ expect ( companionGeometry . railTop ) . toBeGreaterThanOrEqual ( companionGeometry . bodyTop - 1 ) ;
912+ expect ( companionGeometry . railBottom ) . toBeLessThanOrEqual ( companionGeometry . bodyBottom + 1 ) ;
913+
914+ const mainComposer = page . locator ( ".agent-chat__composer-combobox > textarea" ) ;
915+ await mainComposer . click ( ) ;
916+ expect ( await mainComposer . evaluate ( ( element ) => element === document . activeElement ) ) . toBe (
917+ true ,
918+ ) ;
919+ const input = companion . getByRole ( "textbox" , { name : "Ask the session companion" } ) ;
920+ await input . fill ( "Can I use side chat here?" ) ;
921+ await companion . getByRole ( "button" , { name : "Ask" , exact : true } ) . click ( ) ;
922+ const request = await gateway . waitForRequest ( "sessions.companion.ask" ) ;
923+ expect ( request . params ) . toEqual ( {
924+ agentId : "main" ,
925+ question : "Can I use side chat here?" ,
926+ sessionKey,
927+ } ) ;
928+ await companion
929+ . getByText ( "The mobile side chat stayed inside its panel." , { exact : true } )
930+ . waitFor ( ) ;
931+ const companionActions = sidePanel ( page ) . getByRole ( "button" , {
932+ name : "More companion actions" ,
933+ } ) ;
934+ await companionActions . click ( ) ;
935+ await sidePanel ( page )
936+ . locator ( 'wa-dropdown-item[value="clear"]' )
937+ . waitFor ( { state : "visible" } ) ;
938+ await page . keyboard . press ( "Escape" ) ;
939+ await captureRichPanel ( page , "rails-side-chat-mobile-light" ) ;
940+
892941 await sidePanel ( page ) . getByRole ( "button" , { name : "Expand side panel" } ) . click ( ) ;
893942 await expect
894943 . poll ( ( ) =>
0 commit comments