Skip to content

fix(work-items): merge multi-repo PR and issue lists by creation time, not number - #48804

Merged
nwparker merged 1 commit into
mainfrom
bugbash/issue-48761
Nov 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
bugbash/issue-48761

Conversation

@nwparker

@nwparker nwparker commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​69 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

What Changed

  • Before: With several projects selected, the PR and issue lists were ordered by number across repos. For example, repo-b Fix link formatting in installation instructions #263 (opened 18 minutes ago) sat below repo-a Revert "feat: add quick-delete worktree shortcut" #572 (47 days old), because 572 > 263.
  • After: When the rows come from more than one repo (or more than one host), they are ordered newest-created first. A single-repo list keeps GitHub's number order, as before ([Bug]: Desktop Tasks re-sorts GitHub items by last update, not by issue number like mobile #41987).
  • Mechanism:
    • The PR and issue list queries (GraphQL node selections, the gh pr list --json field list, and REST mapping) now also fetch createdAt. GitHubWorkItem gets an optional createdAt field (desktop and mobile types).
    • New sortWorkItemsByRecency(items, fields) in src/shared/work-items/work-item-order.ts. It sorts by createdAt only when the rows span several repos/hosts and every row has a parseable createdAt. Otherwise it keeps number order, with number also used as the tie-breaker.
    • Every place that merges rows across repos now uses it: the cross-repo aggregate fetch and count actions, landing refresh page 0, the collection-state page 0 seed, 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 updatedAt because 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 no createdAt (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

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 sortWorkItemsByNumber vs new sortWorkItemsByRecency:

rows / repos old mean new mean new max
30 / 1 (single repo) 1.1 us 1.7 us 32 us
100 / 10 3.9 us 17.7 us 50 us
300 / 10 (about one page at 36 per repo) 14.3 us 59.1 us 150 us
1,000 / 10 69 us 226 us 508 us
10,000 / 20 (adversarial) 1.25 ms 2.9 ms 3.3 ms

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

  • Only cross-repo lists change order. That is the intended fix, though users who were used to number order across repos will notice it. Single-repo lists are unchanged.
  • Mixed versions: createdAt is 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.
  • Back out with a plain revert. No saved data or settings are touched.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Reported by @anirudh-777

…, 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>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

GitHub issue and pull-request work items now include an optional creation timestamp. A shared sorter orders items from multiple repositories by descending creation time when every timestamp is valid. For items from one repository, or when cross-repository timestamps are missing or invalid, it uses descending item number. Mobile and renderer list paths now use this sorter.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 68578

Cross-repository PR and issue lists now sort newest-created first, and single-repository lists keep number order. Lists that lack creation dates, for example from older hosts, keep the existing number order. No concrete defect was found, so the change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: cross-repo PR and issue lists are now merged by creation time instead of issue number. The changeset adds createdAt to list queries and types, adds sortWorkItemsByRece…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #48761), Visual Proof (N/A with a reason), Testing, Performance (a filled-in None line with…
Linked Issues check Passed Objective [#48761]: when several GitHub repos or hosts are selected, PR and issue lists must not order by repo-specific number. Addressed. Evidence: src/shared/work-items/work-item-order.ts (head) add…
Out of Scope Changes check Passed All listed changes support the cross-repo ordering objective. These include: the optional createdAt field on GitHubWorkItem (desktop shared types and mobile types); the createdAt additions to the Grap…
Full details: Title check

Explanation

The title names the main change: cross-repo PR and issue lists are now merged by creation time instead of issue number. The changeset adds createdAt to list queries and types, adds sortWorkItemsByRecency, and applies it across the merge paths. The title also uses the fix() prefix, which fits the linked bug report. The title is 81 characters, which is slightly long but still clear.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #48761), Visual Proof (N/A with a reason), Testing, Performance (a filled-in None line with measurements), Risk (Low, with a back-out plan), and Notes. The AI Disclosure section is empty, and the Review and Agent skill upstream boundary sections are not addressed. The Testing checklist leaves manual testing unchecked, and the Repro steps are written but not confirmed as run. These gaps are minor relative to the content.

Full details: Linked Issues check

Explanation

Objective [#48761]: when several GitHub repos or hosts are selected, PR and issue lists must not order by repo-specific number. Addressed. Evidence: src/shared/work-items/work-item-order.ts (head) adds sortWorkItemsByRecency. It sorts by createdAt, newest first, only when rows span more than one repoId or repoHostId and every row has a parseable createdAt. Otherwise it keeps number order. The PR summary reports that this function is applied to the cross-repo aggregate fetch and count actions, landing refresh page 0, the collection-state page 0 seed, materializeTaskPageItemList, and the mobile multi-repo merge. createdAt is requested in the GraphQL PR and issue selections, the gh JSON field list, and the REST mapping. Single-repo behavior keeps number order [#41987], as the issue expects. Creation time is an allowed key under the issue's 'created or updated' expectation. I inspected only work-item-order.ts directly. I did not inspect the call sites or the test file, so their wiring rests on the PR summary. No automated test result was independently verified. Manual testing is non-coding and is not assessed.

Full details: Out of Scope Changes check

Explanation

All listed changes support the cross-repo ordering objective. These include: the optional createdAt field on GitHubWorkItem (desktop shared types and mobile types); the createdAt additions to the GraphQL, gh JSON, and REST list mappings; the new sortWorkItemsByRecency helper and its unit tests; and the replacement of sortWorkItemsByNumber with sortWorkItemsByRecency at the merge points. Performance figures in the PR description are supporting evidence and are not code changes. No change was found that is unrelated to ordering or to the carrying of createdAt. Call sites were not inspected directly, so this verdict rests on the PR summary for those files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 215abe35-b9d5-4c9c-8c20-a9608a272dfd
Commits

Reviewing files that changed from the base of the PR and between fab60cd and 68578dd.

Files selected for processing: 13

  • mobile/src/tasks/mobile-tasks-provider-detail-types.ts
  • mobile/src/tasks/task-list/use-mobile-tasks-provider-load-actions.tsx
  • src/main/github/client/list/work-item-issue-page.ts
  • src/main/github/client/list/work-item-pr-page.ts
  • src/main/github/client/map/work-item-field-coercion.ts
  • src/main/github/client/map/work-item.ts
  • src/renderer/src/components/task-page/github/listing/use-task-page-github-collection-state.ts
  • src/renderer/src/components/task-page/github/mutations/task-page-github-work-item-mutation-pages.ts
  • src/renderer/src/components/task-page/github/refresh/task-page-github-landing-refresh-run.tsx
  • src/renderer/src/store/github/work-items/work-item-aggregate-actions.ts
  • src/shared/github/work-items/work-item-types.ts
  • src/shared/work-items/work-item-order.test.ts
  • src/shared/work-items/work-item-order.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@nwparker
nwparker merged commit b6c3bd2 into main Nov 25, 2026
57 checks passed
@nwparker
nwparker deleted the bugbash/issue-48761 branch November 25, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PR list sorts by PR number across repos, so recent PRs from repos with lower numbers sink

1 participant