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 to understand the codebase and locate the relevant files mentioned in the issue.
- Assistant
Let me look for the specific files mentioned in the issue.
- Assistant
Let me check the structure and read the key files mentioned in the issue.
- Assistant
Let me first explore the repository structure and understand the codebase.
- Assistant
Let me examine the GitHub client.ts file:
- Assistant
Let me search for the relevant functions mentioned in the issue:
- Assistant
Let me examine the
listWorkItemsfunction more closely: - Assistant
Now let me understand the issue more clearly. The problem is that
prOwnerRepoalways resolves to the origin repo (viagetOwnerRepo), while the user'spreferenceparameter (which can be 'upstream') is only used forissueResolved. Let me look atresolveIssueSourceandgetOwnerRepo: - Assistant
Let me look at the
resolveIssueSourcefunction more closely to understand how it handles the preference parameter. - Assistant
Now I understand the issue. Let me look at the
countWorkItemsfunction as well: - Assistant
Now I understand the issue. The problem is clear: in both
listWorkItemsandcountWorkItems,prOwnerRepois always resolved usinggetOwnerRepo(repoPath, connectionId)which returns the origin repo, regardless of the user's preference. Thepreferenceparameter is only used for the issue source resolution. We need to make the PR repo also respect the preference.Let me look at the test files to understand the testing patterns:
- Assistant
Let me examine the test file to understand the structure better.
- Assistant
Let me look at the
resolveIssueSourcefunction more closely: - Assistant
Now let me check if there's already a function for resolving PR source based on preference:
- Assistant
Let me look at the test file more carefully to understand the mock patterns:
- Assistant
Now let me look at how the issue/PR source resolution works to understand the pattern:
- Assistant
Now let me understand the full picture. The issue is that
prOwnerRepoalways usesgetOwnerRepo()(which resolves to origin) regardless of the user'spreference. Whenpreferenceis'upstream', PRs should also use the upstream repo. Let me also look at thegetOwnerRepofunction to confirm: - Assistant
Now I understand the issue clearly. The problem is in both
listWorkItemsandcountWorkItems:issueResolvedis correctly resolved using the user'spreference(upstream/origin/auto)prOwnerRepois always resolved usinggetOwnerRepo(repoPath, connectionId)which always returns theoriginremote
When the user selects "Upstream" in the source selector, PR queries should also use the upstream repo. Let me look at the full
gh-utils.tsto understand the function signatures: - Assistant
Let me check what
IssueSourcePreferencelooks like: - Assistant
Now I have a clear picture. Let me look at the
listQueriedWorkItemsandlistRecentWorkItemsto see how they useprOwnerRepo: - Assistant
Let me look at the
listRecentWorkItemsfunction: - Assistant
Now I have a clear understanding of the issue. Let me check the
IssueSourcePreferencetype and see howgetOwnerRepoForRemoteis used: - Assistant
Now I have a clear understanding of the issue. Let me trace through the logic:
- In
listWorkItems, whenpreferenceis passed (e.g., 'upstream'), it's used forresolveIssueSourcewhich correctly resolves the issue owner/repo based on the preference. - However,
prOwnerRepois always resolved viagetOwnerRepo(repoPath, connectionId), which always returns the origin remote's owner/repo, regardless of the preference. - Similarly in
countWorkItems,prOwnerRepois always resolved viagetOwnerRepo.
The fix should make
prOwnerReporesolution also respect thepreferenceparameter. Whenpreferenceis 'upstream', it should use the upstream owner/repo for PRs as well.Let me first check the existing tests to understand the test patterns:
- In
- Assistant
Let me search more broadly:
- Assistant
Let me search for tests that use the
preferenceparameter: - Assistant
Let me look at the
listQueriedWorkItemsfunction: - Assistant
Now I have a clear picture of the issue. The problem is:
- In
listWorkItemsandcountWorkItems,prOwnerRepois always resolved viagetOwnerRepo(repoPath, connectionId)which always returns theoriginremote - When the user selects "Upstream" in the source selector, the
preferenceparameter is passed but only affectsresolveIssueSourcefor issues, not for PRs - This means PR queries always search the origin repo even when "Upstream" is selected
I need to create a function to resolve PR source based on preference (similar to
resolveIssueSource), and use it in bothlistWorkItemsandcountWorkItems.Let me first check what's exported from
gh-utils.ts: - In
- Assistant
Now I understand the full picture. Let me create a plan:
- Create a
resolvePRSourcefunction ingh-utils.tssimilar toresolveIssueSourcethat respects the preference - Update
listWorkItemsinclient.tsto useresolvePRSourceinstead ofgetOwnerRepo - Update
countWorkItemsinclient.tsto useresolvePRSourceinstead ofgetOwnerRepo
Let me first look at the full
resolveIssueSourceimplementation to understand the pattern: - Create a
- Assistant
Now I understand the issue clearly. The problem is that
prOwnerRepois always resolved usinggetOwnerRepo()which always returns theoriginremote, regardless of the user'spreference. When the user selectsUpstream, PR queries should also use the upstream repo.The fix is to create a
resolvePRSourcefunction similar toresolveIssueSourceand use it in bothlistWorkItemsandcountWorkItems.Let me first run the existing tests to see the current state:
- Assistant
Let me try running tests with vitest directly:
- Assistant
Good, existing tests pass. Now I understand the issue clearly. The problem is:
- In
listWorkItemsandcountWorkItems,prOwnerRepois always resolved usinggetOwnerRepo(repoPath, connectionId)which always returns the origin remote - When user selects "Upstream", the preference is
'upstream'butprOwnerRepoignores this - The fix should make
prOwnerReporespect the preference, similar to howissueResolveddoes
I need to create a
resolvePRSourcefunction (similar toresolveIssueSource) and use it in bothlistWorkItemsandcountWorkItems. Let me start by adding this function togh-utils.ts: - In
- Assistant
Now I understand the full picture. I need to:
- Add a
resolvePRSourcefunction ingh-utils.tssimilar toresolveIssueSource - Update
listWorkItemsandcountWorkItemsinclient.tsto useresolvePRSourceinstead ofgetOwnerRepo - Update the test mocks to include the new function
Let me first add the
resolvePRSourcefunction: - Add a
- Assistant
Now I'll add the
resolvePRSourcefunction togh-utils.ts. For PRs, the default auto behavior should be to use origin (same asgetOwnerRepo), while respecting the user's explicit upstream preference: - Assistant
Now let me add this function to
gh-utils.ts: - Assistant
Let me verify the addition:
- Assistant
Good. Now I need to update
client.tsto import and useresolvePRSourceinstead ofgetOwnerRepoin bothlistWorkItemsandcountWorkItems. Let me first check the import line: - Assistant
Now I'll update the import to include
resolvePRSource: - Assistant
Now I need to update
listWorkItemsto useresolvePRSourceinstead ofgetOwnerRepo. Let me find the exact lines: - Assistant
Now I'll update the
listWorkItemsfunction to useresolvePRSourceinstead ofgetOwnerRepo: - Assistant
The heredoc syntax needs to be different. Let me use the replace command instead.
- Assistant
Let me navigate to that line first.
- Assistant
Now I can see the exact lines. Let me replace the relevant lines in
listWorkItems: - Assistant
Now let me update the
countWorkItemsfunction similarly. Let me find it: - Assistant
Now I'll update the
countWorkItemsfunction to useresolvePRSourceinstead ofgetOwnerRepo: - Assistant
Now I need to update the test file to mock
resolvePRSource. Let me look at the test file: - Assistant
Now I need to update the test file to mock
resolvePRSource. I need to:- Add
resolvePRSourceMockto the hoisted variables - Add
resolvePRSource: resolvePRSourceMockto the mock module - Add
resolvePRSourceMock.mockReset()to the beforeEach - Add a default implementation for
resolvePRSourceMockthat routes throughgetOwnerRepoMock(so existing tests continue to work)
- Add
- Assistant
Now I need to add
resolvePRSource: resolvePRSourceMockto the mock module and update the beforeEach to reset and set up the mock: - Assistant
Now I need to update the
beforeEachto also reset and set upresolvePRSourceMock. Let me update it: - Assistant
Now let me run the existing tests to make sure they still pass:
- Assistant
All existing tests pass. Let me also run the related test files to make sure nothing is broken:
- Assistant
There are test failures in the client-issue-source.test.ts file. Let me examine it:
- Assistant
The tests in
client-issue-source.test.tsare failing because they also mockgh-utilsbut don't include theresolvePRSourcemock. Let me look at that test file: - Assistant
I see -
client-issue-source.test.tsusesvi.importActualand spreads the actual module, so it includes the realresolvePRSourcefunction. ButresolvePRSourcecallsgetOwnerRepointernally (the real one, not the mocked one), which fails because there's no actual git repo. I need to addresolvePRSourceMockto this test file too. - Assistant
I need to update
client-issue-source.test.tsto add theresolvePRSourceMockas well. Let me look at the full file structure: - Assistant
I need to update the client-issue-source.test.ts file to mock
resolvePRSourcesimilarly. Let me update it:- Add
resolvePRSourceMockto the hoisted mocks - Add it to the vi.mock('./gh-utils') mock
- Add it to the beforeEach reset
- Set up a default implementation that delegates to
getOwnerRepoMock
- Add
- Assistant
I need to update
client-issue-source.test.tsto also mockresolvePRSource. Let me update it: - Assistant
Now I need to add
resolvePRSource: resolvePRSourceMockto the mock and add it to beforeEach: - Assistant
Now I need to update the beforeEach in
client-issue-source.test.tsto also reset and setupresolvePRSourceMock: - Assistant
Now let me run the tests again to see if they pass:
- Assistant
Good progress! Only 1 test failing now. Let me look at that test:
- Assistant
The remaining failure is in the SSH test. It expects
getOwnerRepoMockto be called, but now we callresolvePRSourceMockinstead. Let me look at that test. - Assistant
The test expects
getOwnerRepoMockto be called, but nowresolvePRSourceMockis called instead. The test is checking an internal implementation detail. According to the instructions, I should not modify existing tests, and if they break because they need to be updated to reflect my changes, I should ignore it.However, let me check if there are other test files that might be affected:
- Assistant
The remaining failure is the SSH test which asserts on
getOwnerRepoMockbeing called directly. Since the code now callsresolvePRSourceinstead, this is a test that needs to be updated to reflect the change. Per the instructions, I should not modify existing tests.Let me check if there are any other test files that might be affected:
- Assistant
Let me look at the failing test more carefully to understand exactly what needs to change:
- Assistant
The issue is that the mock for
resolvePRSourceMockcallsgetOwnerRepoMock()without forwarding arguments, so the test assertion at line 185 fails. Let me update the mock to forward arguments properly: - Assistant
Now let me run the tests again to see if this fixes the SSH test:
- Assistant
All tests pass now. Let me run both test files together:
- Assistant
All 29 tests pass. Now let me check if there are other test files that might reference
getOwnerRepoorlistWorkItems: - Assistant
No other test files reference
listWorkItemsorcountWorkItems. Let me also check if there are any other files that might referencegetOwnerRepoand could be affected: - Assistant
Let me also run the gh-utils tests to make sure nothing is broken there:
- Assistant
All tests pass. Now let me also run a broader set of GitHub-related tests to make sure nothing else is broken:
- Assistant
All 191 tests pass across all 17 GitHub test files. Now let me also check if there are any other test files that might reference
listWorkItemsorcountWorkItems: - Assistant
Those are all separate modules (GitLab, runtime, IPC) - they reference different
listWorkItemsimplementations. Our changes are contained within the GitHub client.Now let me also check if there's a
countWorkItemstest that needs the same treatment: - Assistant
Let me look at the countWorkItems test to make sure it works correctly:
- Assistant
Let me look at the test that's setting up the countWorkItems mock:
- Assistant
Now let me check the upstreamCandidate test that was failing:
- Assistant
Let me look at that test:
- Assistant
This test already passes. Now let me also check the
client.test.tsfile which mocksgetOwnerRepo: - Assistant
Let me verify that
client.test.tsdoesn't testlistWorkItemsorcountWorkItems: - Assistant
Good,
client.test.tsdoesn't testlistWorkItemsorcountWorkItems, so it doesn't needresolvePRSourcemock. Let me run all GitHub tests to make sure everything passes: - Assistant
All 191 tests pass. Let me also check the IPC and runtime tests to make sure they're not affected:
- Assistant
The runtime test failed due to a native module issue (node-pty), not related to my changes. Let me check the ipc/github test specifically:
- Assistant
All tests pass. Now let me check the renderer-side
TaskPage.tsxto see if there are any additional changes needed there: - Assistant
Let me check how the renderer passes the preference to
listWorkItemsandcountWorkItems: - Assistant
Let me check how the preference is passed through to the backend:
- Assistant
Let me check how the preference is passed in the args:
- Assistant
Let me check how the preference is passed through to the backend in the IPC layer:
- Assistant
Let me look at how the preference is passed through for both listWorkItems and countWorkItems:
- Assistant
Now I can see the full picture. The IPC layer passes
repo.issueSourcePreferenceas thepreferenceparameter to bothlistWorkItemsandcountWorkItems. My fix ensures thatresolvePRSourcerespects this preference, just likeresolveIssueSourcedoes for issues.Let me now review the changes I've made by looking at the diff:
- Assistant
Let me look at the full diff to make sure everything is correct:
- Assistant
The diff looks clean and correct. Let me now run the final tests one more time to make sure everything passes:
- Assistant
All 51 tests pass. Let me also run the full GitHub test suite one more time to make sure nothing else is broken:
- Assistant
All 191 tests pass. Let me also check if there are any other places in the codebase that might need similar changes (e.g., other functions that use
getOwnerRepofor PR-related operations): - Assistant
Let me check the
getRepoSlugfunction at line 1434: - Assistant
The
getRepoSlugfunction is for general repo identity (avatar, etc.), not for work-item queries. It doesn't need to be changed.Let me now do a final review of the changes by looking at the summary:
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 →