Repository navigation
fix(github): pin work-item list ordering to updated-desc so cursor pagination reaches every page - #8658
Conversation
…gination reaches every page The Tasks page paginates work items with an updatedAt cursor (updated:<oldest-item), but the underlying gh calls never pinned a sort: 'gh issue list' defaults to created-desc and '--search' defaults to best-match. Items created long ago but updated recently therefore never appeared on any page — page 0 (created order) skipped them and every later page excluded them via the cursor — so the pager advertised pages the fetch chain could never reach, clicks on them clamped to the last real page, and cross-page ordering was scrambled. Append sort:updated-desc to every list/search invocation so the fetch order matches the cursor field on the first and all subsequent pages. Verified against a live 588-issue repo: the cursor chain previously died around page 5; it now traverses 585/588 unique issues (the remainder is the pre-existing strict '<' boundary edge for items sharing the cursor's exact timestamp). Fixes stablyai#8649
📝 WalkthroughWalkthroughGitHub work-item list arguments now always include a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…oundaries Builds on the sort-pin fix: switch the pagination cursor from strict 'updated:<' to inclusive 'updated:<=' so items sharing the boundary row's exact updatedAt are no longer skipped between pages (the residual 3/588 edge in stablyai#8649). The inclusive bound re-fetches the boundary rows, so dedupe them by repoId+id (a bare item.id like 'issue:9' collides across repos). Extract the page accumulation out of the 12k-line TaskPage component into a pure, unit-tested helper (accumulateWorkItemPages) that dedupes and backfills: it accumulates fresh rows across fetches and emits uniform pageSize pages, so deduped pages never shrink below the size totalPages (count / effectivePageSize) assumes — which would otherwise strand the tail items and break the no-count degraded pager. Also hoist the updated-desc ordering into a named WORK_ITEM_LIST_SORT_QUALIFIER constant so the cursor's ordering contract has one home. Tradeoff: when per-repo fetch size equals pageSize, the boundary dedupe costs one extra fetch per page; acceptable for interactive pagination and bounded by the gh rate-limit guard. Persisting the cursor/buffer across calls is a possible follow-up.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e52b250a-5ce5-4657-bde1-56f1ba7aeb5a
📒 Files selected for processing (5)
src/main/github/client-work-items.test.tssrc/main/github/client.tssrc/renderer/src/components/TaskPage.tsxsrc/renderer/src/components/task-page-work-item-pagination.test.tssrc/renderer/src/components/task-page-work-item-pagination.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/github/client-work-items.test.ts
| if (result.newPages.length > 0) { | ||
| setPages((prev) => [...prev, ...result.newPages]) | ||
| setCurrentPage(target < result.loadedPages ? target : result.loadedPages - 1) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Update the current page even if no new pages are loaded.
If result.newPages.length === 0 (e.g., data changed on the server and fewer pages exist than expected), but the user clicked a specific target page beyond the currently loaded ones, they will remain on their current page rather than advancing to the last available page.
Moving setCurrentPage outside the if block ensures the user is navigated as far as possible toward their target (it gracefully falls back to result.loadedPages - 1).
💡 Proposed fix
if (result.newPages.length > 0) {
setPages((prev) => [...prev, ...result.newPages])
- setCurrentPage(target < result.loadedPages ? target : result.loadedPages - 1)
}
+ setCurrentPage(target < result.loadedPages ? target : result.loadedPages - 1)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (result.newPages.length > 0) { | |
| setPages((prev) => [...prev, ...result.newPages]) | |
| setCurrentPage(target < result.loadedPages ? target : result.loadedPages - 1) | |
| if (result.newPages.length > 0) { | |
| setPages((prev) => [...prev, ...result.newPages]) | |
| } | |
| setCurrentPage(target < result.loadedPages ? target : result.loadedPages - 1) |
…gination reaches every page (stablyai#8658) * fix(github): pin work-item list ordering to updated-desc so cursor pagination reaches every page The Tasks page paginates work items with an updatedAt cursor (updated:<oldest-item), but the underlying gh calls never pinned a sort: 'gh issue list' defaults to created-desc and '--search' defaults to best-match. Items created long ago but updated recently therefore never appeared on any page — page 0 (created order) skipped them and every later page excluded them via the cursor — so the pager advertised pages the fetch chain could never reach, clicks on them clamped to the last real page, and cross-page ordering was scrambled. Append sort:updated-desc to every list/search invocation so the fetch order matches the cursor field on the first and all subsequent pages. Verified against a live 588-issue repo: the cursor chain previously died around page 5; it now traverses 585/588 unique issues (the remainder is the pre-existing strict '<' boundary edge for items sharing the cursor's exact timestamp). Fixes stablyai#8649 * fix(github): make work-item cursor pagination lossless at updatedAt boundaries Builds on the sort-pin fix: switch the pagination cursor from strict 'updated:<' to inclusive 'updated:<=' so items sharing the boundary row's exact updatedAt are no longer skipped between pages (the residual 3/588 edge in stablyai#8649). The inclusive bound re-fetches the boundary rows, so dedupe them by repoId+id (a bare item.id like 'issue:9' collides across repos). Extract the page accumulation out of the 12k-line TaskPage component into a pure, unit-tested helper (accumulateWorkItemPages) that dedupes and backfills: it accumulates fresh rows across fetches and emits uniform pageSize pages, so deduped pages never shrink below the size totalPages (count / effectivePageSize) assumes — which would otherwise strand the tail items and break the no-count degraded pager. Also hoist the updated-desc ordering into a named WORK_ITEM_LIST_SORT_QUALIFIER constant so the cursor's ordering contract has one home. Tradeoff: when per-repo fetch size equals pageSize, the boundary dedupe costs one extra fetch per page; acceptable for interactive pagination and bounded by the gh rate-limit guard. Persisting the cursor/buffer across calls is a possible follow-up. --------- Co-authored-by: OrcaWin <[email protected]>
Summary
Fixes #8649.
The Tasks page paginates GitHub work items with an updatedAt cursor (
updated:<oldest item's updatedAt), but the underlyingghinvocations never pinned a sort order:gh issue list)--search "updated:<cursor")Items created long ago but updated recently never appeared on any page: page 0 (created order) skipped them, and every later page excluded them via the cursor. The pager therefore advertised pages the fetch chain could never reach (the search-API count is correct; the fetched rows fall short), clicking those pages clamped to the last real page, and cross-page ordering was scrambled (e.g. #1082 rendering between #1308 and #1499).
The fix appends
sort:updated-descto every list/search invocation (issues and PRs), so the fetch order matches the cursor field on the first and all subsequent pages. The REST fallback path already pinnedsort=updated&direction=desc; the primary gh CLI path was the only one missing it.Screenshots
Testing
pnpm lint(pre-commit oxlint/react-doctor/oxfmt; repository config)pnpm typecheckpnpm test— allsrc/main/githubsuites pass (359/359); the workstation's full run has pre-existing environment-dependent failures (git pathspec/relay/ssh) that fail identically onmainpnpm buildsort:updated-desc; cursor pages combineupdated:<cursor sort:updated-descAI Review Report
buildWorkItemListArgs, so issues and PRs get the same ordering pin; the count path (countWorkItems) is unaffected and already consistent.--search; best-match with it) and the fix (sort:updated-deschonored in bothgh issue listandgh pr list).ghinvocation shape is identical on macOS/Linux/Windows.Security Audit
The change appends a constant qualifier to an existing
--searchargument built from already-parsed query parts — no new user input reaches the command line, andghis still invoked via execFile-style argument arrays (no shell interpolation).Notes
updated:<, so items sharing the boundary item's exact timestamp can be skipped (3/588 in live verification, and items updated mid-traversal drift). Fixing it needs<=plus seen-ID dedupe in the renderer chain — separable follow-up.countWorkItemsparticipates in the search budget guard (noteRateLimitSpend('search')). Wiring list calls into that accounting would make the guard estimate more accurate.page/per_pageoffset form could jump directly (within its 1,000-result window).