Repository navigation
fix(work-items): merge multi-repo PR and issue lists by creation time, not number - #48804
Conversation
…, not number GitHub numbers issues and PRs per repository, so sorting a multi-repo list by number buried recent items from repos with lower numbers under old items from repos with higher numbers. Fetch createdAt for list rows and, when the rows span more than one repo, order them newest-created first. Single-repo lists, and any list where a row lacks createdAt (older hosts), keep the existing number order. Fixes #48761 Co-authored-by: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
ELI5
Each GitHub repo counts its PRs and issues on its own (#1, #2, ...). When you pick several projects, the Tasks list was sorted by that number across all repos, so a repo with big numbers took over the top of the list and a PR opened a few minutes ago in a repo with smaller numbers ended up far down. Now, when the list covers more than one repo, the newest-created item comes first.
What Changed
gh pr list --jsonfield list, and REST mapping) now also fetchcreatedAt.GitHubWorkItemgets an optionalcreatedAtfield (desktop and mobile types).sortWorkItemsByRecency(items, fields)insrc/shared/work-items/work-item-order.ts. It sorts bycreatedAtonly when the rows span several repos/hosts and every row has a parseablecreatedAt. Otherwise it keeps number order, with number also used as the tie-breaker.materializeTaskPageItemList(so rows kept through a mutation keep their place), and the mobile multi-repo merge. Since they all share one ordering, rows don't jump around between pages and refreshes.Why
Numbers can't be compared across repos, so a cross-repo list needs a key that means the same thing in every repo. We picked creation time over
updatedAtbecause it never changes. A row's position stays put when someone comments or a check runs, which keeps the cross-repo merge pagination (#12127) stable. Inside one repo, number order is the same as creation order apart from transferred issues, so single-repo lists keep the existing behavior. If any row has nocreatedAt(for example, a paired phone talking to an older desktop host), the whole list falls back to number order. Mixing the two keys would give an inconsistent order.Linked Issue
Fixes #48761
Visual Proof
N/A. No screenshot or recording was captured for this change. It only changes the order of rows in the existing list (no new UI). Reproducing it needs several live GitHub repos with PR numbers in different ranges. The ordering rules are covered by the unit test below.
Testing
Repro (from the issue): select two GitHub repos whose PR numbers are in different ranges (about fix: prevent phantom notifications on worktree shutdown #700 and about Prevent branch name reuse across PR history #250), open a new PR in the lower-numbered repo, then open the PRs tab with both selected. Before: the new PR sits below every open PR from the higher-numbered repo. After: it comes first.
Added
src/shared/work-items/work-item-order.test.ts. It covers: a cross-repo merge by creation time (repo-b Fix link formatting in installation instructions #263 newest ahead of repo-a feat: improve cookie import robustness and cross-platform support #736/Revert "feat: add quick-delete worktree shortcut" #572); a single repo that keeps number order even with a transferred issue's oldcreatedAt; and the fallback to number order when a row has nocreatedAt.vitest run src/shared/work-items/passes. oxlint, oxfmt, the anti-slop and native code-quality oxlint configs, ast-grep, and the changed-code quality gate are clean on all 13 touched files.Platforms: macOS (unit tests and static checks). The change is platform-independent: data mapping and sorting only, no paths, shortcuts or OS APIs. SSH: there are no relay changes, because GitHub list fetches already return the new field through the existing mappers.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None that matters, because the sort runs once each time a list response or refresh arrives. It does not run per frame or per keystroke. It adds no polling, subprocesses or sync I/O, and the only payload added is one timestamp field per row. Measured on Node 24 (M-series), old
sortWorkItemsByNumbervs newsortWorkItemsByRecency:The cross-repo case is about 3 to 4 times slower because it parses the dates, but even the adversarial 10,000-row case stays far below a 16 ms frame.
Risk
Level: Low
createdAtis optional everywhere. An older desktop host that doesn't send it makes mobile fall back to number order, and the new mobile build works against it.Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Reported by @anirudh-777