Skip to content

Commit fc42bca

Browse files
committed
Fix nextCursor for runs list pagination.
1 parent 7af789b commit fc42bca

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

apps/webapp/app/services/runsRepository/clickhouseRunsRepository.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ export class ClickHouseRunsRepository implements IRunsRepository {
101101
previousCursor = reversedRunIds.at(1) ?? null;
102102
nextCursor = reversedRunIds.at(options.page.size) ?? null;
103103
} else {
104-
nextCursor = reversedRunIds.at(options.page.size - 1) ?? null;
104+
// Use the last item (oldest run) as the forward cursor.
105+
// We can't use a fixed index (pageSize - 1) because the result set
106+
// may have fewer items than pageSize (e.g., when new runs were created
107+
// while the user was browsing, shifting page boundaries).
108+
nextCursor = reversedRunIds.at(reversedRunIds.length - 1) ?? null;
105109
}
106110

107111
break;

apps/webapp/app/services/runsRepository/postgresRunsRepository.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class PostgresRunsRepository implements IRunsRepository {
7575
previousCursor = reversedRuns.at(1)?.id ?? null;
7676
nextCursor = reversedRuns.at(options.page.size)?.id ?? null;
7777
} else {
78-
nextCursor = reversedRuns.at(options.page.size - 1)?.id ?? null;
78+
// Use the last item (oldest run) as the forward cursor.
79+
// We can't use a fixed index (pageSize - 1) because the result set
80+
// may have fewer items than pageSize (e.g., when new runs were created
81+
// while the user was browsing, shifting page boundaries).
82+
nextCursor = reversedRuns.at(reversedRuns.length - 1)?.id ?? null;
7983
}
8084
break;
8185
}

0 commit comments

Comments
 (0)