@@ -628,6 +628,33 @@ describe('serve app', () => {
628628 expect ( secondPage . next_cursor ) . toBeUndefined ( ) ;
629629 } ) ;
630630
631+ it ( 'sorts runs by displayed timestamp descending before pagination' , async ( ) => {
632+ createLocalRun ( tempDir , 'z-older-directory-name' , {
633+ ...RESULT_A ,
634+ timestamp : '2026-03-25T10:00:00.000Z' ,
635+ } ) ;
636+ createLocalRun ( tempDir , 'a-newer-directory-name' , {
637+ ...RESULT_A ,
638+ timestamp : '2026-03-25T10:09:00.000Z' ,
639+ } ) ;
640+
641+ const app = createApp ( [ ] , tempDir , tempDir , undefined , { studioDir } ) ;
642+
643+ const res = await app . request ( '/api/runs?limit=1' ) ;
644+ expect ( res . status ) . toBe ( 200 ) ;
645+ const data = ( await res . json ( ) ) as {
646+ runs : Array < { filename : string ; timestamp : string } > ;
647+ next_cursor ?: string ;
648+ } ;
649+ expect ( data . runs . map ( ( { filename, timestamp } ) => ( { filename, timestamp } ) ) ) . toEqual ( [
650+ {
651+ filename : 'a-newer-directory-name' ,
652+ timestamp : '2026-03-25T10:09:00.000Z' ,
653+ } ,
654+ ] ) ;
655+ expect ( data . next_cursor ) . toBe ( 'a-newer-directory-name' ) ;
656+ } ) ;
657+
631658 it ( 'returns an empty page for unknown cursors' , async ( ) => {
632659 createLocalRun ( tempDir , '2026-03-25T10-00-00-000Z' , RESULT_A ) ;
633660 createLocalRun ( tempDir , '2026-03-25T11-00-00-000Z' , RESULT_A ) ;
0 commit comments