File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -491,11 +491,24 @@ export const AutoCompactWarning: AppStory = {
491491 canvas . getByText ( / a c c e s s t o k e n e x p i r e s i n 1 5 m i n u t e s / ) ;
492492 } ) ;
493493
494- // Wait a bit for auto-scroll to settle, then scroll up
495- await new Promise ( ( r ) => setTimeout ( r , 100 ) ) ;
494+ // Wait for auto-scroll to settle and ResizeObserver callbacks to complete
495+ await new Promise ( ( r ) => setTimeout ( r , 300 ) ) ;
496+
496497 const messageWindow = canvasElement . querySelector ( '[data-testid="message-window"]' ) ;
497498 if ( messageWindow ) {
498- messageWindow . scrollTop = messageWindow . scrollHeight - messageWindow . clientHeight - 150 ;
499+ // The useAutoScroll hook tracks user interactions to distinguish user scrolls
500+ // from programmatic scrolls. We need to simulate the full interaction flow:
501+ // 1. Fire wheel event to mark user interaction timestamp
502+ // 2. Change scrollTop to trigger scroll handler within the 100ms window
503+ // 3. The handler detects upward scroll and disables auto-scroll
504+ messageWindow . dispatchEvent ( new WheelEvent ( "wheel" , { bubbles : true , deltaY : - 100 } ) ) ;
505+ const targetScroll = Math . max (
506+ 0 ,
507+ messageWindow . scrollHeight - messageWindow . clientHeight - 250
508+ ) ;
509+ messageWindow . scrollTop = targetScroll ;
510+ // Fire scroll event manually since programmatic scrollTop change may not trigger it
511+ messageWindow . dispatchEvent ( new Event ( "scroll" , { bubbles : true } ) ) ;
499512 }
500513 } ,
501514 parameters : {
You can’t perform that action at this time.
0 commit comments