@@ -763,6 +763,50 @@ describe("MessagesTimeline messages", () => {
763763 expect ( turns ) . toEqual ( turns . toSorted ( ( a , b ) => a - b ) ) ;
764764 } ) ;
765765
766+ it ( "steps the minimap's next turn past two adjacent user messages" , async ( ) => {
767+ const props = baseProps ( ) ;
768+ const reply = ( id : string ) => message ( "Reply.\n\n" . repeat ( 120 ) , { role : "assistant" } , id ) ;
769+ const userIds = [ "turn-0" , "turn-1" , "turn-2" , "pair-a" , "pair-b" , "turn-3" , "turn-4" ] ;
770+ const entries = [
771+ ...[ "turn-0" , "turn-1" , "turn-2" ] . flatMap ( ( id ) => [ message ( id , { } , id ) , reply ( `${ id } -r` ) ] ) ,
772+ message ( "pair-a" , { } , "pair-a" ) ,
773+ message ( "pair-b" , { } , "pair-b" ) ,
774+ reply ( "pair-b-r" ) ,
775+ ...[ "turn-3" , "turn-4" ] . flatMap ( ( id ) => [ message ( id , { } , id ) , reply ( `${ id } -r` ) ] ) ,
776+ ] ;
777+ const session = cdp ( ) ;
778+ await session . send ( "Emulation.setEmulatedMedia" , {
779+ features : [ { name : "prefers-reduced-motion" , value : "reduce" } ] ,
780+ } ) ;
781+ try {
782+ await using screen = await renderTimeline ( entries , props ) ;
783+ const viewport = props . listRef . current ! . getScrollableNode ( ) ! ;
784+ const strips = ( ) => [ ...screen . container . querySelectorAll ( "[data-minimap-strip]" ) ] ;
785+ const turnAtTop = ( ) =>
786+ userIds . find ( ( id ) => {
787+ const row = screen . container . querySelector ( `[data-message-id="${ id } "]` ) ;
788+ if ( ! row ) return false ;
789+ const offset = row . getBoundingClientRect ( ) . top - viewport . getBoundingClientRect ( ) . top ;
790+ return offset >= 0 && offset < 100 ;
791+ } ) ;
792+ await act ( ( ) => {
793+ void props . listRef . current ! . scrollToIndex ( { index : 0 , animated : false } ) ;
794+ } ) ;
795+ await vi . waitFor ( ( ) => expect ( strips ( ) [ 0 ] ?. getAttribute ( "data-in-view" ) ) . toBe ( "true" ) ) ;
796+
797+ // Clicks again while the view has not moved, as a user would.
798+ for ( const id of userIds . slice ( 1 ) ) {
799+ const from = turnAtTop ( ) ;
800+ await vi . waitFor ( async ( ) => {
801+ if ( turnAtTop ( ) === from ) await click ( screen . button ( "Next turn" ) ) ;
802+ expect ( turnAtTop ( ) , "turn at the top after Next turn" ) . toBe ( id ) ;
803+ } ) ;
804+ }
805+ } finally {
806+ await session . send ( "Emulation.setEmulatedMedia" , { features : [ ] } ) ;
807+ }
808+ } ) ;
809+
766810 it ( "preserves XML-like tags and comparisons in user messages as text" , async ( ) => {
767811 const source = [
768812 'Without reading a file, do you have <global-agent-instructions scope="workspace">' ,
0 commit comments