ISSUE DESCRIPTION Tasks PR Upstream source still queries origin This was generated by AI…
- User
ISSUE DESCRIPTION
Tasks PR Upstream source still queries origin
This was generated by AI during triage.
Summary
In the Tasks page, selecting the
PRstab and choosingUpstreamin the source selector can showNo matching GitHub workeven when matching upstream PRs exist.The upstream/origin selector is visible in the PRs view, but the GitHub client still resolves PR list/count queries from
origin, sois:pr is:open author:@mesearches the fork/origin repo instead of the selected upstream repo.Reproduction
- Open a forked repository in Orca where
originpoints to the fork andupstreampoints to the canonical repo. - Open Tasks.
- Select
PRs. - Select
Upstreamin the source selector. - Use a PR-only query such as
is:pr is:open author:@me.
Actual behavior
The list can be empty with
No matching GitHub work, despite matching PRs existing in the upstream repository.Expected behavior
When
Upstreamis selected, PR list and PR count queries should use the upstream owner/repo, so the PRs tab returns matching upstream PRs.Code evidence
src/main/github/client.tsresolvesissueResolvedwith the selected preference, but resolvesprOwnerReposeparately viagetOwnerRepo(repoPath, connectionId), which is the origin repo.listWorkItemspasses thatprOwnerRepointo both recent and queried PR fetches.countWorkItemsuses the sameprOwnerRepofor PR count queries, so pagination/count can also be wrong.src/renderer/src/components/TaskPage.tsxrenders the selector usingorigin={s.sources.prs}andupstream={s.sources.upstreamCandidate}, which makes the control appear relevant in the PRs surface while the backend still routes PR queries to origin.
Suggested regression coverage
Add tests for:
listWorkItems('/repo-root', 10, 'is:pr is:open author:@me', undefined, 'upstream')using the upstream slug in--repo.countWorkItems('/repo-root', 'is:pr is:open author:@me', 'upstream')building a search query withrepo:<upstream-owner>/<repo>.
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /orca, current file: none) bash-$
- Open a forked repository in Orca where
Assistant
I'll start by exploring the repository structure and understanding the codebase, then reproduce the issue.
Assistant
Let me run one command at a time.
Assistant
Let me look at the
listWorkItemsandcountWorkItemsfunctions in detail.Assistant
Now let me look at the
gh-utils.tsto understandresolveIssueSource,resolvePRRepositoryCandidates,getOwnerRepo, andgetOwnerRepoForRemote.Assistant
Now let me look at the types involved.
Assistant
Let me look at the existing tests for these functions.
Assistant
Let me look at the client-issue-source.test.ts file to understand how the preference is tested.
Assistant
Now let me look at the TaskPage.tsx and the source selector to understand the renderer side.
Assistant
Let me look at the
hasUpstreamCandidateDivergenceandhasDivergentSourcesfunctions and the broader context.Assistant
Let me look at the second selector usage around line 9680-9720.
Assistant
Let me look at the
IssueSourceSelectorcomponent.Assistant
Let me search for all usages of
sources.prsand.prsin the renderer and store.Assistant
Let me narrow the search for
sources.prsusage specifically.Assistant
Let me look at how
sources.prsis used in display logic (lines 4440-4460, 4750-4760, 2950-2975).Assistant
Let me look at the
listRecentWorkItemsandlistQueriedWorkItemsfunctions and the SSH assertion logic.Assistant
Let me look at the usages around lines 2950-2980 and 4745-4765.
Assistant
Line 2971-2972:
prSlugis used in the "fell back to origin" toast. This toast only shows whenissueSourceFellBackis true (preference=upstream but no upstream remote → fell back to origin). In that case, PRs are also from origin (fallback). Sosources.prs= origin = the repo we fell back to. The toast says "Using origin" with the origin slug. ✓. Correct.So this usage is fine with
sources.prs= origin.Now line 4754.
Assistant
Let me check how
primaryGithubFilterSlugis used.Assistant
primaryGithubFilterSlugis passed toPRFilterDropdownsasprimarySlug. Let me check whatPRFilterDropdownsdoes withprimarySlug.Assistant
Let me look at
buildWorkItemListArgsand the work-item list args builder.Assistant
Let me check how tests are run in this repo.
Assistant
Let me create a temporary reproduction test to confirm the bug.
Assistant
I've reproduced the bug. Now let me check the renderer tests to understand the impact before deciding on the scope.
Assistant
Let me look at the store test around line 3620-3660.
Assistant
Let me check for renderer tests asserting the filter dropdown / external link behavior.
Assistant
No tests directly assert
primaryGithubFilterSlugorselectedGitHubRepoExternalLink. So renderer changes there would be low-risk for tests. But there might be component tests forPRFilterDropdowns. Let me check.Actually, the grep showed
PRFilterDropdowns.tsxandPRFilterPickers.tsxbut no test files for them. Let me confirm there are no test files referencing these.The grep for
tests/returned nothing (only src/renderer files). So no tests for these components. Good.But wait, there might be TaskPage tests. Let me check if there's a TaskPage.test.tsx.
Assistant
Let me verify
parseTaskQueryhandlesis:pr is:open author:@meas expected.Assistant
Now I understand the code. Let me implement the backend fix. First, let me open the
listWorkItemsfunction.Assistant
Now let me implement the fix in
listWorkItems. I'll resolve the PR query target based on the preference while keepingsources.prsas the origin repo (which the renderer's selector relies on for its Origin pill).Assistant
The edit left duplicate lines (1255-1257). Let me remove them.
Assistant
The
listWorkItemsfix looks good. Now let me updatecountWorkItems.Assistant
There's a stray
}and I accidentally removed theif (!ownerRepo)null check. Let me fix that.Assistant
Both functions are updated. Now let me run my reproduction test to confirm the fix.
Assistant
My reproduction tests now pass. Let me run the existing GitHub client tests to make sure I didn't break anything.
Assistant
All existing tests pass. Let me run the broader GitHub-related test suite to be safe.
Assistant
All 193 GitHub tests pass. Let me also run the IPC and runtime tests that call these functions.
Assistant
The runtime/github.test.ts failure is a pre-existing environment issue (missing native
pty.nodemodule at load time, 0 tests collected) — unrelated to my TypeScript change. Let me verifygetWorkItem(PR detail lookup used when clicking a PR) to see if it also needs the preference, since the PRs tab would use it.Assistant
getWorkItemdoesn't take a preference parameter (out of scope, and the work items returned bylistWorkItemscarry their ownprRepo). Let me verify thatmapPullRequestWorkItemsetsprRepofrom the resolved owner repo, so PR detail lookups follow correctly.Assistant
mapPullRequestWorkItemsetsprRepofrom the resolvedprOwnerRepo, so PR detail/checks/merge operations (which use the work item'sprRepo) correctly target upstream. The fix is complete and consistent with the issue's scope (PR list/count queries, no new interfaces).Let me run the typecheck to ensure no type errors.
Assistant
Typecheck passes. Let me run the linter on the changed file.
Assistant
All checks pass. Now let me clean up my temporary reproduction test file (per the instructions, I shouldn't add tests to the repo).
Assistant
Let me verify how the preference is threaded from the renderer/store to
listWorkItems/countWorkItemsto ensure the fix is reachable end-to-end.Assistant
Let me check how
args(including the preference) is constructed when calling these functions.Assistant
GitHubWorkItemsListArgsdoesn't includepreference. Let me look at the callers around lines 1930-1960 and 2089-2110 to see how the preference reaches the IPC.Assistant
The preference isn't passed via
args. Let me check the IPC layer to see how the preference reaches the main process.Assistant
The IPC layer threads
repo.issueSourcePreferenceto bothlistWorkItemsandcountWorkItems(and evenlistLabels). So my fix is reachable end-to-end.Now let me check the
perRepoSourceStateto see if the preference is available there (relevant to the filter-dropdown slug which usessources.prs).Assistant
The IPC layer threads
repo.issueSourcePreferenceto both functions, so the fix is reachable end-to-end. My change preserves all existing behavior inauto/originmodes and only routes PR queries to upstream whenpreference === 'upstream'and an upstream remote exists.Let me run a final comprehensive check on the affected test areas (excluding the native-module-broken runtime test) and verify the diff.
Assistant
All 330 tests pass. Let me confirm the runtime/github.test.ts failure is a pre-existing environmental issue (native
pty.nodemodule not built) by checking it against a clean checkout via git stash.Assistant
Confirmed — the runtime/github.test.ts failure is pre-existing (fails on a clean checkout too, due to the missing native
pty.nodebinary in this environment). It's unrelated to my change.Let me review my final diff.
Assistant
The diff is clean and correct. Let me do a final review of both modified functions to confirm correctness.
Assistant
Both functions look correct. Let me verify
countWorkItemsonce more.Assistant
Both functions are correct. Let me run one final temporary verification covering the recent (no-query) list path and the default count path with
upstream, to be thorough, then remove it.Assistant
All verification scenarios pass (recent list, default count, and no-regression for auto mode). The temporary test is removed. Let me confirm the final git status shows only the intended change.
Assistant
The change is clean — only
src/main/github/client.tsis modified, with all temporary test files removed.Let me run the checklist review:
Checklist review:
-
[✓] Reproduced the error: I wrote a temporary test confirming that with
preference='upstream', PR list queries used--repo fork/orca(origin) and count queries usedrepo:fork/orcainstead of the upstreamstablyai/orca. -
[✓] Confirmed the fix resolves the error: After the fix, the same scenarios route PR list (
--repo stablyai/orca), PR count (repo:stablyai/orca), recent list, and default count queries to the upstream repo. I also verifiedautomode keeps PRs on origin (no regression). -
[✓] Thought about edge cases:
upstream+ upstream remote exists → PRs target upstream ✓upstream+ no upstream remote → falls back to origin (mirrorsresolveIssueSource,issueSourceFellBackstill set) ✓origin/auto/ undefined → PRs stay on origin (unchanged) ✓- origin == upstream (non-fork) → no behavior change ✓
- SSH repos →
upstreamCandidateresolved withconnectionId; the SSH source assertion uses the resolvedprOwnerRepo✓ countWorkItems'sameOwnerRepogate: upstream mode collapses to a single combined query; auto mode still splits ✓- PR work items carry
prRepo= resolved upstream, so PR detail/checks/merge ops follow ✓ sources.prskept as origin so the renderer's selector (Origin pill + render gate) keeps working after picking Upstream ✓
-
[✓] Ran existing affected tests:
src/main/github/(193),ipc/github.test.ts,store/slices/github.test.ts(90),web-preload-api.test.ts(34) — all 330 pass. Typecheck (tsgo) and lint (oxlint) pass. The only failing suite (runtime/rpc/methods/github.test.ts) fails on a clean checkout too due to a missing nativepty.nodebinary — unrelated to this change.
The fix is minimal, backend-only (no new interfaces, matching the issue's scope), and directly addresses the root cause:
listWorkItems/countWorkItemsnow resolve the PR query target from the selected source preference instead of always using origin.-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →