@@ -2207,11 +2207,18 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
22072207 [ 393 , 852 ] ,
22082208 [ 1366 , 900 ] ,
22092209 ] as const ) (
2210- "anchors received bubbles left and sent bubbles right at %sx%s" ,
2210+ "anchors message roles and balances transcript width at %sx%s" ,
22112211 async ( width , height ) => {
22122212 const page = await openFixture ( width , height ) ;
22132213 try {
22142214 const roles = await page . evaluate ( ( ) => {
2215+ const transcriptViewport = document . querySelector < HTMLElement > ( ".chat-thread" ) ! ;
2216+ const widthProbe = document . createElement ( "div" ) ;
2217+ widthProbe . style . width = "100%" ;
2218+ widthProbe . style . height = "0" ;
2219+ transcriptViewport . append ( widthProbe ) ;
2220+ const transcriptAvailableWidth = widthProbe . getBoundingClientRect ( ) . width ;
2221+ widthProbe . remove ( ) ;
22152222 const rectFor = ( selector : string ) => {
22162223 const node = document . querySelector ( selector ) as HTMLElement | null ;
22172224 if ( ! node ) {
@@ -2228,16 +2235,36 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
22282235 return {
22292236 assistantLane : rectFor ( ".chat-group.assistant .chat-group-messages" ) ,
22302237 assistantBubble : rectFor ( ".chat-group.assistant .chat-bubble:first-child" ) ,
2238+ transcript : rectFor ( ".chat-thread-inner" ) ,
2239+ transcriptViewport : rectFor ( ".chat-thread" ) ,
2240+ transcriptAvailableWidth,
22312241 userLane : rectFor ( ".chat-group.user .chat-group-messages" ) ,
22322242 userBubble : rectFor ( ".chat-group.user .chat-bubble:first-child" ) ,
22332243 } ;
22342244 } ) ;
22352245
22362246 const assistantLane = expectControlRect ( roles . assistantLane , "assistant message lane" ) ;
22372247 const assistantBubble = expectControlRect ( roles . assistantBubble , "assistant bubble" ) ;
2248+ const transcript = expectControlRect ( roles . transcript , "transcript" ) ;
2249+ const transcriptViewport = expectControlRect (
2250+ roles . transcriptViewport ,
2251+ "transcript viewport" ,
2252+ ) ;
22382253 const userLane = expectControlRect ( roles . userLane , "user message lane" ) ;
22392254 const userBubble = expectControlRect ( roles . userBubble , "user bubble" ) ;
22402255
2256+ expect (
2257+ Math . abs (
2258+ transcript . x +
2259+ transcript . width / 2 -
2260+ ( transcriptViewport . x + transcriptViewport . width / 2 ) ,
2261+ ) ,
2262+ ) . toBeLessThanOrEqual ( 1 ) ;
2263+ if ( width <= 768 ) {
2264+ expect ( roles . transcriptAvailableWidth - transcript . width ) . toBeCloseTo ( 32 , 0 ) ;
2265+ } else {
2266+ expect ( transcript . width ) . toBeCloseTo ( 768 , 0 ) ;
2267+ }
22412268 expect ( Math . abs ( assistantBubble . x - assistantLane . x ) ) . toBeLessThanOrEqual ( 1 ) ;
22422269 expect (
22432270 Math . abs ( userBubble . x + userBubble . width - ( userLane . x + userLane . width ) ) ,
0 commit comments