@@ -10,6 +10,7 @@ import { MessagesTimeline } from "./MessagesTimeline";
1010import { remarkThoughtPreview } from "./TimelineWorkEntryRow.logic" ;
1111import { parseMarkdownWithMath } from "@t3tools/shared/markdownMath" ;
1212import { collectThreadFindRanges } from "./threadFindHighlights" ;
13+ import { rememberTimelinePosition } from "./timelineScrollAnchoring" ;
1314
1415const environmentQuery = vi . hoisted ( ( ) => ( {
1516 error : "Pull request not found" ,
@@ -274,7 +275,7 @@ describe("MessagesTimeline turn folds", () => {
274275 expect ( screen . text ( ) ) . toContain ( "Interim progress note" ) ;
275276 } ) ;
276277
277- it ( "keeps a turn the user expanded open after switching threads and back " , async ( ) => {
278+ it ( "keeps a restored expanded turn open when the next run starts " , async ( ) => {
278279 const props = baseProps ( ) ;
279280 const firstRun = RunId . make ( "run-1" ) ;
280281 const secondRun = RunId . make ( "run-2" ) ;
@@ -292,22 +293,33 @@ describe("MessagesTimeline turn folds", () => {
292293 "assistant-final" ,
293294 ) ,
294295 ] ;
295- const completed = {
296- latestRun : { runId : firstRun , status : "completed" , startedAt : at ( 0 ) , completedAt : at ( 9 ) } ,
297- } satisfies Partial < TimelineProps > ;
296+ rememberTimelinePosition (
297+ props . routeThreadKey ,
298+ {
299+ rowId : "user-1" ,
300+ offsetWithinRow : 0 ,
301+ scrollOffset : 0 ,
302+ atEnd : true ,
303+ disclosures : {
304+ runs : new Set ( [ firstRun ] ) ,
305+ workGroups : new Set ( ) ,
306+ attempts : new Set ( ) ,
307+ workGroupState : { scrollPositions : new Map ( ) , expandedEntries : new Set ( ) } ,
308+ } ,
309+ } ,
310+ false ,
311+ ) ;
298312 const timeline = ( entries : Entry [ ] , extra : Partial < TimelineProps > ) => (
299313 < MessagesTimeline { ...props } timelineEntries = { entries } { ...extra } />
300314 ) ;
301- await using screen = await renderElement ( timeline ( settled , completed ) ) ;
302- const fold = ( ) => screen . button ( / ^ W o r k e d f o r / ) ;
303- await click ( fold ( ) ) ;
304- expect ( screen . text ( ) ) . toContain ( "Interim progress note" ) ;
305-
306- await screen . rerender (
307- timeline ( [ ] , { ...completed , displayThreadKey : `${ props . routeThreadKey } -other` } ) ,
315+ await using screen = await renderElement (
316+ timeline ( settled , {
317+ latestRun : { runId : firstRun , status : "completed" , startedAt : at ( 0 ) , completedAt : at ( 9 ) } ,
318+ } ) ,
308319 ) ;
309- await screen . rerender ( timeline ( settled , completed ) ) ;
320+ const fold = ( ) => screen . button ( / ^ W o r k e d f o r / ) ;
310321 expect ( fold ( ) . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
322+ expect ( screen . text ( ) ) . toContain ( "Interim progress note" ) ;
311323
312324 await screen . rerender (
313325 timeline (
0 commit comments