Repository navigation
fix(github): load PR details on fork checkouts by preferring upstream (#7331) - #9384
Merged
Merged
Conversation
…7331) getOwnerRepo() only consulted the origin remote, so on a fork checkout (origin -> fork, upstream -> parent) PR detail lookups targeted the fork and failed with 'Could not resolve to a PullRequest'. Make getOwnerRepo prefer upstream when present, mirroring getIssueOwnerRepo, and fall back to origin when there is no upstream remote. Callers that need the checkout's own identity (getRepoSlug), that combine both remotes themselves (getRepoUpstream, resolvePrWorkItemSource), or that create a PR against the pushed branch (createGitHubPullRequest) now request the origin remote explicitly via getOwnerRepoForRemote. Fixes #7331 Co-authored-by: Orca <[email protected]>
nwparker
marked this pull request as ready for review
July 18, 2026 21:33
Contributor
📝 WalkthroughWalkthroughRepository identity resolution now checks the upstream remote before origin and retains origin-specific resolution through 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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 was referenced Jul 18, 2026
2 of 7 tasks
This was referenced Aug 6, 2026
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…stablyai#9384) On a fork checkout (origin=fork, upstream=parent) PR details failed to load because getOwnerRepo() resolved only the origin remote while GitHub PRs live on the upstream parent. Make getOwnerRepo() prefer upstream (mirroring getIssueOwnerRepo), and pin the call sites that genuinely need the checkout's own origin identity (getRepoSlug, getRepoUpstream, createGitHubPullRequest, resolvePrWorkItemSource) to the origin-only primitive. Lands the fix community-identified in stablyai#7332 and hardened in stablyai#7513. Closes stablyai#7331 Co-authored-by: fsdwen <[email protected]> Co-authored-by: brennanb2025 <[email protected]>
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.
Description
On a fork checkout — where
originpoints at your personal fork andupstreampoints at the parent repo — opening PR details failed to load. GitHub PRs live on the upstream parent, but the PR-lookup resolver only ever consulted the fork.Root cause:
getOwnerRepo()insrc/main/github/github-repository-identity.ts:206resolved only theoriginremote, sogh pr view <N> --repo <fork>targeted the fork and returnedCould not resolve to a PullRequest. The siblinggetIssueOwnerRepo()already preferredupstreamfirst, so issues loaded but PRs did not — the exact divergence #7331 reports.Fix: make
getOwnerRepo()prefer theupstreamremote when present and fall back tooriginotherwise, mirroringgetIssueOwnerRepo(). Repos with noupstreamremote are unaffected (behavior unchanged).Because
getOwnerRepo()is also used by callers that specifically need the checkout's own (origin) identity, those call sites were switched to the origin-only primitivegetOwnerRepoForRemote(repoPath, 'origin', …)so their behavior is preserved:getRepoSlug(src/main/github/client.ts:1649) — the slug is the checkout's own identity used for renderer display and icon autodetect; must stay origin-based.getRepoUpstream(src/main/github/client.ts:1675) — its offline fork-parent fast-path compares origin against the upstream remote; both must be distinct.resolvePrWorkItemSource(src/main/github/client.ts:1093) — combines origin + upstream itself, so it needs origin explicitly.createGitHubPullRequest(src/main/github/client.ts:1889) — the head branch is unqualified and lives on the fork, sogh pr createmust run against origin.Fixes #7331
Evidence (proof of improvement)
New test:
src/main/github/github-repository-identity.fork-owner-repo.test.ts(imports the realgithub-repository-identityandclientmodules; only the git runner / ssh dispatch / config-signature boundaries are mocked).Coverage:
getOwnerRepoprefers the upstream parent on a fork checkout — returnsstablyai/orca, not the forkfsdwen/orca.getOwnerRepoandgetIssueOwnerReponow agree on a fork checkout (the pre-fix discrepancy is gone).getOwnerRepofalls back tooriginwhen there is noupstreamremote (non-fork behavior unchanged).[email protected]:…) resolve the upstream parent too.getOwnerRepoForRemote('origin')still resolves the fork itself (origin-only primitive intact).getRepoUpstreamstill resolves the fork parent offline without anyghcall (fast-path regression guard).Failing-on-main → passing-on-fix reasoning: the reproduction test in the scan worktree pins the buggy behavior — on
main,getOwnerRepo(forkCheckout)returns{ owner: 'fsdwen', repo: 'orca' }(the fork) whilegetIssueOwnerReporeturns{ owner: 'stablyai', repo: 'orca' }, and the two resolvers disagree. After this changegetOwnerReporeturns the upstream parent and the two resolvers agree, which is what the new test asserts.Proof of no regression
src/main/github/vitest suite: 27 files, 389 tests passed.typecheck:tsc:node(tsc --noEmit -p config/tsconfig.node.json): clean, no errors.oxlinton all changed files: exit 0, no warnings/errors. Pre-commit hook (oxlint + react-doctor + oxfmt) passed.Unchanged behaviors and why:
upstreamremote, sogetOwnerRepofalls through to the identicaloriginresolution — the negativeupstreamprobe is cached to avoid extra git spawns.getRepoSlugcontinues returning the checkout's own (origin) identity, so renderer display and icon autodetect are untouched.getRepoUpstream's offline fork-detection fast-path still compares a distinct origin vs. upstream, so fork parents still resolve without a networkghcall.createGitHubPullRequeststill targets origin, so PR creation pushes to the fork the branch actually lives on.githubtests that previously defined the origin candidate throughgetOwnerRepowere rerouted to the origin-onlygetOwnerRepoForRemotemock, asserting the same end-user outcomes.ELI5
When you copy someone else's project to your own account (a "fork") and then look at a pull request, the request actually lives on the original project, not your copy. The app was mistakenly looking in your copy, so the PR page came up empty. Now it looks in the original project first — just like it already did for issues — so pull requests load correctly, and everything works exactly as before for projects that aren't forks.
Credit
This lands the fix community-identified in #7332 by @fsdwen (who also filed #7331 with the root-cause analysis) and hardened in #7513 by @brennanb2025. Both are credited as commit co-authors. This PR carries the same upstream-first core change plus an audit of every
getOwnerRepocall site (notably keepinggetRepoSlugon the checkout's own origin identity) against current main.Made with Orca 🐋