fix(github): align PR source and review head origin (#10677)

* fix(github): align PR source and review head origin

* fix(github): pin number-based work item open to the repo source preference

Open-by-number and details still ran the upstream-first multi-candidate PR
probe, so a fork and its upstream sharing a PR number opened different PRs
than the list and start-point paths did once #10677 pinned those to origin.

Thread repo.issueSourcePreference through dispatchWorkItem, getWorkItemDetails,
getRepoWorkItem, and getRepoWorkItemDetails. getWorkItemByOwnerRepo is left
alone: explicit owner/repo already pins identity. auto/upstream/undefined keep
the multi-candidate probe.

Co-authored-by: Orca <help@stably.ai>

* test(github): enforce origin preference in review head origin resolution

The explicit origin preference must short-circuit before any identity probe, so no remote queries should occur. Add validation to reject unexpected remotes and tighten the test assertion to verify no remote get-url calls happen at all.

* fix(github): enforce origin preference in issue open-by-number lookup

listWorkItems and getWorkItem must share preference so origin/upstream
toggles cannot disagree. Explicit origin preference now fail-closes when
origin identity is unresolved (no bare-lookup fallback), matching the
PR candidate resolution rule.

---------

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinjing
2026-07-25 22:48:53 -07:00
committed by GitHub
co-authored by Orca
parent 8cb45318d7
commit 33bd676644
18 changed files with 654 additions and 69 deletions
+10 -4
View File
@@ -16139,12 +16139,15 @@ export class OrcaRuntimeService {
type?: 'issue' | 'pr'
): Promise<Awaited<ReturnType<typeof getWorkItem>>> {
const repo = await this.resolveRepoSelector(repoSelector)
// Why: open-by-number must pin the same source the list and start-point use,
// else a fork and its upstream sharing a PR number resolve to different PRs.
return getWorkItem(
repo.path,
number,
type,
repo.connectionId ?? null,
...this.getLocalGitExecutionOptionArgs(repo)
this.getLocalGitExecutionOptionArgs(repo)[0] ?? {},
repo.issueSourcePreference
)
}
@@ -16176,7 +16179,8 @@ export class OrcaRuntimeService {
number,
type,
repo.connectionId ?? null,
...this.getLocalGitExecutionOptionArgs(repo)
this.getLocalGitExecutionOptionArgs(repo)[0] ?? {},
repo.issueSourcePreference
)
}
@@ -20142,11 +20146,12 @@ export class OrcaRuntimeService {
const gitExec = sshGitProvider
? (gitArgs: string[]) => sshGitProvider.exec(gitArgs, repo.path)
: (gitArgs: string[]) => gitExecFileAsync(gitArgs, localGitExecOptions ?? { cwd: repo.path })
// Why: one shared resolver for local and SSH so origin-vs-upstream cannot
// diverge by surface; it prefers the remote hosting the PR's project.
// Why: one resolver keeps source preference and hosting identity aligned
// across local, WSL, and SSH worktree creation.
const resolveRemote = (): Promise<string> =>
resolveGitHubReviewHeadRemote({
repoPath: repo.path,
issueSourcePreference: repo.issueSourcePreference,
connectionId: repo.connectionId ?? null,
localGitOptions: localWorktreeGitOptions,
gitExec
@@ -20176,6 +20181,7 @@ export class OrcaRuntimeService {
headRefName: args.headRefName,
baseRefName: args.baseRefName,
isCrossRepository: args.isCrossRepository,
issueSourcePreference: repo.issueSourcePreference,
connectionId: repo.connectionId ?? null,
localGitOptions: localWorktreeGitOptions,
gitExec,