fix(tasks): resolve PR work items upstream-first under 'auto' like issues#8727
Open
moseoh wants to merge 1 commit into
Open
fix(tasks): resolve PR work items upstream-first under 'auto' like issues#8727moseoh wants to merge 1 commit into
moseoh wants to merge 1 commit into
Conversation
…sues On a fork, 'auto' routed the Tasks PR list/count to origin — the fork's own PR list, which is almost always empty — while highlighting the Upstream pill (issues resolve upstream-first). The PRs tab showed 'No matching GitHub work' until the user explicitly clicked Upstream, and the highlighted pill contradicted where the data actually came from. stablyai#5176 routed explicit picks through the preference for both sides but deferred the 'auto' side. This aligns it: 'auto' resolves PRs upstream-first exactly like issues; an explicit 'origin' pick still pins PRs to the fork.
Contributor
📝 WalkthroughWalkthroughAutomatic pull request source resolution now prefers the upstream repository for non-origin preferences, falling back to the origin repository when needed. Tests cover upstream PR retrieval and source metadata for 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #8726 (item A).
On a fork (
origin= fork,upstream= canonical repo), opening Tasks → PRs with no explicit source preference shows "No matching GitHub work" even though the user's PRs exist upstream — while the source selector highlights Upstream.Under
auto, the issue side resolves upstream-first, butresolvePrWorkItemSourcepinned the PR side toorigin— the fork's own PR list, which is almost always empty, since fork-contribution PRs live on the upstream repo. So the PRs tab was empty by default on exactly the repos where upstream/origin routing matters, and the highlighted pill (which reflects the issue-side heuristic) contradicted where the PR data actually came from.#5166/#5176 fixed explicit picks (both sides follow an explicit Upstream/Origin selection) but consciously deferred the
autoside. This PR aligns it — one resolution expression inresolvePrWorkItemSource, shared bylistWorkItemsandcountWorkItems, so the list, pagination totals, andsources.prsmetadata stay consistent:issueSourcePreference'upstream'(explicit)'origin'(explicit)'auto'/ unsetRepos without an
upstreamremote are unaffected:upstreamCandidateisnull, so the?? originfallback preserves today's behavior. A side benefit: whenautocollapses both sides onto the same repo, the default count uses one search call instead of two.Repro (before): fork with
origin+upstreamremotes, never touch the source selector → Tasks → PRs → empty list with the Upstream pill highlighted; clicking Upstream (which writes the explicit preference) suddenly populates it.Screenshots
Testing
pnpm lintpnpm typecheckpnpm test— 2 new regression tests (written first, red on the old resolver): (1)auto+ upstream remote → the PR list queries upstream andsources.prsreports it; (2) the default count collapses to one search call when both sides resolve to upstream. Fullsrc/main/github(375 tests) and the consuming renderer suites (389 tests) pass.pnpm buildauto(was empty), explicit Origin still pins to the fork, Issues tab unchanged.AI Review Report
resolvePrWorkItemSourcehas exactly two callers (listWorkItems,countWorkItems); both inherit the change, so lists and pagination totals cannot diverge. The raworiginCandidate/upstreamCandidatemetadata is untouched, so the selector's render gate (raw-candidate divergence, per Route task PR queries by upstream source #5176's design) is unaffected.autoon a fork,sources.issues === sources.prsnow, so the "Issues from X" indicator chip correctly stops rendering (there is no split to announce). Selector, TaskPage source-state, and store cache suites pass unchanged.'origin'and'upstream'branches are behaviorally identical to before;'upstream'with a missing upstream remote still falls back to origin.connectionId/localGitOptionsplumbing; no new lookups (the upstream probe was already made forupstreamCandidate).auto—listMergeRequestsingitlab/client.ts), so this change also removes a GitHub↔GitLab inconsistency in howautotreats the PR/MR side.Security Audit
No new inputs, IPC, command execution, or dependencies — one resolution expression in the main-process GitHub client plus tests.
Notes
autoside as out of scope at the time; this completes that deferred half. The practical argument: a fork's own PR list is nearly always empty, so the old default rendered the PRs tab useless on forks.Related to(notFixes) [Bug]: Tasks upstream/origin problems on forks — auto PR routing, stale source switches, slow page jumps #8726 — that issue tracks the whole cluster; this addresses item A only. Item B (stale lists when toggling without a manual refresh) reproduces onmainbefore and after this change and is under separate investigation.