@@ -271,14 +271,37 @@ describe("remembered timeline positions", () => {
271271 it ( "keeps reading positions and end-follow independent across threads and environments" , ( ) => {
272272 const reading = { rowId : "message-4" , offsetWithinRow : 32 , scrollOffset : 932 , atEnd : false } ;
273273 const following = { rowId : "message-9" , offsetWithinRow : 10 , scrollOffset : 2010 , atEnd : true } ;
274- rememberTimelinePosition ( "scroll-test-a:thread-1" , reading ) ;
275- rememberTimelinePosition ( "scroll-test-a:thread-2" , following ) ;
276- rememberTimelinePosition ( "scroll-test-b:thread-1" , following ) ;
274+ rememberTimelinePosition ( "scroll-test-a:thread-1" , reading , false ) ;
275+ rememberTimelinePosition ( "scroll-test-a:thread-2" , following , true ) ;
276+ rememberTimelinePosition ( "scroll-test-b:thread-1" , following , true ) ;
277277 expect ( readTimelinePosition ( "scroll-test-a:thread-1" ) ) . toEqual ( reading ) ;
278278 expect ( readTimelinePosition ( "scroll-test-a:thread-2" ) ) . toEqual ( following ) ;
279279 expect ( readTimelinePosition ( "scroll-test-b:thread-1" ) ) . toEqual ( following ) ;
280280 expect ( readTimelinePosition ( "scroll-test-a:unvisited" ) ) . toBeUndefined ( ) ;
281- rememberTimelinePosition ( "scroll-test-a:thread-1" , following ) ;
281+ rememberTimelinePosition ( "scroll-test-a:thread-1" , following , true ) ;
282282 expect ( readTimelinePosition ( "scroll-test-a:thread-1" ) ) . toEqual ( following ) ;
283283 } ) ;
284284} ) ;
285+
286+ describe ( "remembered timeline follow intent" , ( ) => {
287+ const key = "follow-intent-test:thread" ;
288+ const position = { rowId : "message-4" , offsetWithinRow : 32 , scrollOffset : 932 , atEnd : false } ;
289+
290+ it ( "keeps following when smooth scrolling or a layout callback reports an end gap" , ( ) => {
291+ rememberTimelinePosition ( key , { ...position , atEnd : true } , true ) ;
292+ rememberTimelinePosition ( key , position , true ) ;
293+ expect ( readTimelinePosition ( key ) ) . toEqual ( { ...position , atEnd : true } ) ;
294+ } ) ;
295+
296+ it ( "restores the reading position after manual navigation opts out of follow" , ( ) => {
297+ rememberTimelinePosition ( key , position , true ) ;
298+ rememberTimelinePosition ( key , position , false ) ;
299+ expect ( readTimelinePosition ( key ) ) . toEqual ( position ) ;
300+ } ) ;
301+
302+ it ( "remembers returning to the end before the follow flag updates" , ( ) => {
303+ rememberTimelinePosition ( key , position , false ) ;
304+ rememberTimelinePosition ( key , { ...position , atEnd : true } , false ) ;
305+ expect ( readTimelinePosition ( key ) ?. atEnd ) . toBe ( true ) ;
306+ } ) ;
307+ } ) ;
0 commit comments