Skip to content

fix(tasks): resolve PR work items upstream-first under 'auto' like issues - #8727

Merged
nwparker merged 1 commit into
stablyai:mainfrom
moseoh:fix/pr-work-items-auto-upstream
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
moseoh:fix/pr-work-items-auto-upstream

Conversation

@moseoh

@moseoh moseoh commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

fix(tasks): resolve PR work items upstream-first under 'auto' like issues

Summary

On a fork, opening Tasks → PRs with no explicit source preference showed "No matching GitHub work" even though the user's PRs existed upstream.

ELI5

When you work from a fork, your pull requests actually live on the original project, not your copy. The PRs tab was looking at your (empty) copy by default, so it looked like you had none. Now it looks in the right place.

Root cause & fix

Under the auto preference, the issue side resolved upstream-first, but resolvePrWorkItemSource() pinned the PR side to origin (the fork), whose PR list is almost always empty for fork-contribution workflows. The fix flips the default so auto resolves upstream-first, mirroring the issue side; only an explicit origin preference still pins PRs to the fork. It's a single resolution expression shared by listWorkItems and countWorkItems, so lists, pagination totals, and sources.prs metadata stay consistent. Repos without an upstream remote are unaffected — the ?? origin fallback preserves current behavior.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23. Rebase onto origin/main was clean (base 7ab601487c, head e2ff0024c3).

  • Suite src/main/github/client-issue-source.test.ts passes on branch: 30/30 tests passed.
  • Reverting only the fix (git checkout origin/main -- src/main/github/client.ts), keeping the tests, fails 2 tests (28 passed), capturing the bug:
STEP 2a (branch):  Test Files 1 passed (1) | Tests 30 passed (30)
STEP 2b (fix reverted, test kept): Test Files 1 failed (1) | Tests 2 failed | 28 passed (30)

  ✗ preference='auto' + upstream exists → PRs query upstream too
      AssertionError: expected --repo "stablyai/orca" but got "fork/orca"
  ✗ collapses the default count to one query when auto resolves both sides to upstream
      AssertionError: expected mock called 1 time, but got 2 times
  • Lint clean: npx oxlint src/main/github/client.ts → exit 0, no warnings/errors.

Trade-offs

None — pure fix.

Regression risk

Zero-regression. Only the auto branch changes (now upstream-first, matching issues); explicit origin still pins the fork and explicit upstream is unchanged. Repos with no upstream remote fall back to origin exactly as before. Callers are unaffected, and this is proven by the passing branch suite plus the fail-on-revert assertions above.

Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved. Credit to original author @moseoh.

@moseoh
moseoh marked this pull request as ready for review July 14, 2026 10:45
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Automatic 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 listWorkItems, along with collapsed upstream search counting for countWorkItems.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main behavior change under auto preference.
Description check ✅ Passed It covers the bug, fix, evidence, and regression risk well, though it omits some template sections like screenshots and security audit.

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

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Heads-up: #9384 just landed on main and touched resolvePrWorkItemSource (the originCandidate now comes from the origin-only getOwnerRepoForRemote since getOwnerRepo became upstream-first for #7331). This PR's auto-mode alignment is still a distinct, wanted fix for #8726 — it'll just need a rebase over that change.

@moseoh
moseoh force-pushed the fix/pr-work-items-auto-upstream branch from a399fbc to e2ff002 Compare July 19, 2026 03:48
@moseoh

moseoh commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased over #9384 — this PR still only changes the auto-side resolution expression.

…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.
@nwparker
nwparker force-pushed the fix/pr-work-items-auto-upstream branch from e2ff002 to 4a38a91 Compare July 23, 2026 11:48
@nwparker
nwparker merged commit 832aa69 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @moseoh — resolve PR work items upstream-first under 'auto' like issues. Reviewed, rebased on latest main, and merged. Really appreciate the contribution! 🙏

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.

3 participants