mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
Fix pagination for unindexed threads sorted by ascending recency (#61181)
## Why Listing threads by ascending `recency_at` can omit `next_cursor` when rollout files have not yet been indexed in SQLite, preventing clients from fetching the remaining threads. ## What changed Scan and index one extra rollout for ascending recency listings when SQLite is available, so the database can detect another page. Trim filesystem results to the requested page size for this sort order. ## Testing Add a regression test that creates two unindexed rollouts after startup backfill and lists them with a provider filter and a page size of one. Verify both threads are returned in order, with a cursor only on the first page. GitOrigin-RevId: 09354055b6e60666a493d9411ed3eb9778b73c0a
This commit is contained in:
@@ -612,9 +612,15 @@ impl RolloutRecorder {
|
||||
};
|
||||
let fs_page = match sort_direction {
|
||||
SortDirection::Asc => {
|
||||
// SQLite needs one extra indexed row to produce a recency cursor.
|
||||
let scan_size = if sort_key == ThreadSortKey::RecencyAt && state_db_ctx.is_some() {
|
||||
page_size.saturating_add(1)
|
||||
} else {
|
||||
page_size
|
||||
};
|
||||
list_threads_from_files_asc(
|
||||
codex_home,
|
||||
page_size,
|
||||
scan_size,
|
||||
cursor,
|
||||
sort_key,
|
||||
file_config,
|
||||
@@ -1377,8 +1383,8 @@ fn page_from_filesystem_scan(
|
||||
sort_key: ThreadSortKey,
|
||||
) -> ThreadsPage {
|
||||
match sort_direction {
|
||||
SortDirection::Asc => page,
|
||||
SortDirection::Desc => truncate_fs_page(page, page_size, sort_key),
|
||||
SortDirection::Asc if sort_key != ThreadSortKey::RecencyAt => page,
|
||||
SortDirection::Asc | SortDirection::Desc => truncate_fs_page(page, page_size, sort_key),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user