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 search for the relevant functions mentioned in the issue:
Assistant
Now I can see the issue. In
listWorkItems, the code resolvesprOwnerRepousinggetOwnerRepo(repoPath, connectionId), which always returns the origin repo. It should respect thepreferenceparameter when it's 'upstream'.Let me look at the
countWorkItemsfunction:Assistant
Now let me look at the
resolveIssueSourcefunction to understand how it works:Assistant
Now I understand the issue. Let me look at the
getOwnerRepofunction and how it's used:Assistant
Now I understand the problem clearly:
- In
listWorkItems, the code callsgetOwnerRepo(repoPath, connectionId)which always returns theoriginremote - But it should respect the
preferenceparameter (like it does for issues viaresolveIssueSource) - When the user selects "Upstream" in the PRs tab, the PR queries should use the upstream repo, not origin
Let me also check the
TaskPage.tsxfile to understand the UI context:- In
Assistant
Let me look at where the preference is being set and used:
Assistant
Now let me look at the test file to understand the expected behavior better:
Assistant
Let me look at the test file more closely to understand the structure:
Assistant
Now let me check if there are any existing tests that test the upstream preference:
Assistant
No existing tests for the 'upstream' preference. Let me also check the type definition for
IssueSourcePreference:Assistant
Now I understand the full picture. The issue is:
listWorkItemsandcountWorkItemsboth callgetOwnerRepo(repoPath, connectionId)to getprOwnerRepo- This always returns the origin repo, ignoring the
preferenceparameter - When the user selects "Upstream", PR queries should use the upstream repo
The fix should:
- Add a function to resolve the PR owner/repo based on the preference (similar to
resolveIssueSource) - Use this new function in
listWorkItemsandcountWorkItems
Let me first create a test script to confirm the issue:
Assistant
Good. Now let me look at the full context of the functions I need to modify:
Assistant
Now, let me look at how
resolveIssueSourceis exported from gh-utils and what I need to do:Assistant
Looking at the code, I need to create a similar function to
resolveIssueSourcefor PRs, or simply reuse the existing logic. Let me examine the logic more carefully:For issues:
resolveIssueSource(repoPath, preference, connectionId)respects the preference
For PRs:
- Current code:
getOwnerRepo(repoPath, connectionId)which always returns origin - Should be: Use upstream when preference is 'upstream', origin otherwise
The simplest fix is to create a
resolvePRSourcefunction ingh-utils.ts(similar toresolveIssueSource) and use it inclient.ts. However, looking at the code more carefully, I see that theresolveIssueSourcealready handles this logic. Let me think about whether we can reuse it.Looking at
resolveIssueSource:- If preference is 'upstream', it returns upstream (or falls back to origin)
- If preference is 'origin', it returns origin
- If preference is 'auto' or undefined, it calls
getIssueOwnerRepowhich prefers upstream
For PRs, the behavior should be different. When the user selects "Upstream" in the PR source selector, PR queries should use the upstream repo. But the default behavior (auto/undefined) should still use origin for PRs (since PRs are typically in the fork/origin).
Let me look at the UI to understand better:
Assistant
Now I understand. The selector uses
s.sources.prsas the origin ands.sources.upstreamCandidateas upstream. When the user changes the preference, it callssetIssueSourcePreferencewhich affects both issues and PRs.So the fix is straightforward: the PR source should also respect the preference. Let me create a
resolvePRSourcefunction that works similarly toresolveIssueSourcebut with different defaults:Assistant
Looking at this more carefully, I realize that for PRs, the logic should be:
- When preference is 'upstream': use upstream
- When preference is 'origin': use origin
- When preference is 'auto' or undefined: use origin (since PRs are typically in the fork)
The key insight is that
resolveIssueSourcealready does what we need for the 'upstream' and 'origin' cases. The difference is in the 'auto' case:- For issues:
getIssueOwnerRepo(prefers upstream if it exists) - For PRs:
getOwnerRepo(always origin)
So I need to create a
resolvePRSourcefunction that uses the same logic but defaults to origin instead of upstream. Let me add this function togh-utils.ts:Assistant
Now I'll add the
resolvePRSourcefunction to gh-utils.ts after theresolveIssueSourcefunction:Assistant
Now I need to export this function from gh-utils and import it in client.ts. Let me first check the imports in client.ts:
Assistant
Now let me add the import for
resolvePRSource:Assistant
Let me verify the import was added correctly:
Assistant
Good! Now let me update the
listWorkItemsfunction to useresolvePRSourceinstead ofgetOwnerRepo:Assistant
Now I need to replace
getOwnerRepo(repoPath, connectionId)with a call toresolvePRSourceand extract its source:Assistant
Now I need to add the line that extracts prOwnerRepo from prResolved. Let me check the current state:
Assistant
Good. Now I need to add
const prOwnerRepo = prResolved.sourceafterconst issueOwnerRepo = issueResolved.source:Assistant
Let me verify the changes:
Assistant
Now I need to do the same for the
countWorkItemsfunction. Let me check its current state:Assistant
I see there's a problem - the sed command I ran earlier replaced
getOwnerRepo(repoPath, connectionId)globally, but there was already aconst prOwnerRepovariable assignment in countWorkItems, and now it has a duplicate line withprResolvedwhich doesn't exist in that function's scope. Let me fix this properly.Assistant
I need to fix the countWorkItems function. Let me first restore the file and make more targeted changes:
Assistant
Let me continue reviewing the git diff to understand what changes have been made and what still needs to be fixed.
Assistant
Looking at the diff, I see there are issues with the changes to
countWorkItemsandgetWorkItem. ThecountWorkItemsfunction's Promise.all still usesgetOwnerRepobut referencesprResolvedwhich doesn't exist. Let me fix this properly.Assistant
I see the problem. The
countWorkItemsfunction still hasgetOwnerRepo(repoPath, connectionId)in the Promise.all, but my earlier sed added a duplicateconst prOwnerRepo = prResolved.sourceline that references a non-existentprResolvedvariable. Let me fix this:Assistant
I need to fix the countWorkItems function. The Promise.all still uses
getOwnerRepobut should useresolvePRSource. Let me fix this:Assistant
Good, the
countWorkItemsfunction is now fixed. Now let me check thegetWorkItemfunction that was also modified by the earlier sed commands. Looking at the diff, I see thatgetWorkItemwas changed to useresolvePRSourcebut it returns aResolvedIssueSourceobject, not just anOwnerRepo. Let me check the current state of that function.Assistant
The
getWorkItemfunction is now callingresolvePRSourcebut that returns aResolvedIssueSourceobject{ source, fellBack }, not anOwnerRepo. I need to extract.sourcefrom it. Let me fix this.Assistant
Now let me verify the changes look correct:
Assistant
Good! The diff looks correct. Now let me verify the gh-utils.ts changes:
Assistant
Good! The changes look correct. Now let me run the existing tests to make sure I haven't broken anything. Let me first check if there are any tests related to work items.
Assistant
The test is timing out during setup (installing pnpm and rebuilding native deps). Let me try a different approach - I'll check if vitest is available directly or try to run tests with a timeout configuration.
Let me try running the test more directly or checking if there's a way to skip the native runtime setup.
Assistant
Let me try running vitest without the timeout option and see if I can get the tests to run. I'll also need to bypass the native runtime check that's causing issues.
Assistant
The tests are failing because the test file's mock for
./gh-utilsdoesn't include the newresolvePRSourcefunction. I need to add it to the mock setup. Let me examine the test file and update it.Assistant
I need to add the
resolvePRSourcemock to the test file. Let me update it:Assistant
I see the issue - the edit command duplicated the content. The file now has duplicate lines. I need to fix this by restoring the original file and making a cleaner edit. Let me restore the test file first and then make the changes more carefully.
Assistant
Now let me make the changes more carefully using replace commands:
Assistant
The replace command is having trouble with the multi-line syntax. Let me use the << 'EOF' syntax instead for the multi-line replacement.
Assistant
Let me try a different approach using sed:
Assistant
Now I need to add it to the vi.mock call:
Assistant
Now I need to add the mock setup in beforeEach:
Assistant
Now I need to add the mock implementation for resolvePRSourceMock that mirrors getOwnerRepoMock (since for PRs, the default is origin):
Assistant
Now let me verify the changes look correct:
Assistant
I see there's an error in the vi.mock section - there's an extra line
resolvePRSourceMock,that shouldn't be there. Let me fix this:Assistant
Let me verify the mock section now looks correct:
Assistant
I need to verify the test file changes are correct and run the tests. Let me check the current state:
Assistant
Good, the mock setup looks correct. Let me run the tests again to see if they pass now:
Assistant
The error says
resolvePRSourceMock is not definedat line 46. This is becausevi.mockis hoisted to the top of the file, butresolvePRSourceMockis defined in thevi.hoistedblock. The issue is that I addedresolvePRSource: resolvePRSourceMock,to the mock object, butresolvePRSourceMockis extracted fromvi.hoisted()and available at the module scope, so it should work.Let me check line 46 in the test file to see what's there.
Assistant
I see the issue. Line 46 is where
resolvePRSource: resolvePRSourceMock,is defined. The problem is thatvi.mockis hoisted to the top of the file, but thevi.hoistedblock is also hoisted. TheresolvePRSourceMockvariable should be available since it's extracted fromvi.hoisted().Let me look at how the file is structured to understand the hoisting better:
Assistant
I see the problem! The destructuring on the left side of
vi.hoisted()does NOT includeresolvePRSourceMock. Let me fix that:Assistant
I see the problem -
resolvePRSourceMockis missing from the destructuring pattern on the left side. Let me fix that:Assistant
Good, the sed command succeeded. Now let me verify the fix is correct by checking the destructuring pattern.
Assistant
Now the destructuring is correct. Let me run the tests again:
Assistant
All 12 tests passed. Let me also check if there are any other tests that might be affected by these changes:
Assistant
All tests pass! Now let me verify the changes are complete by reviewing all the files I modified.
Assistant
Good. Let me review all the changes I made:
Assistant
The user is reminding me that I need to use tool calls properly. Let me continue checking the git diff for the client.ts file to verify my changes are correct.
Assistant
Let me also verify the test file changes and then run all related tests to ensure everything works correctly.
Assistant
I notice there's a duplicate
resolvePRSourceMock,line in the vi.mock section. Let me check and fix that, then run the tests again to confirm everything works.Assistant
I see there's still a duplicate
resolvePRSourceMock,line on line 47. Let me remove it.Assistant
The user hasn't said anything, so I need to continue with my work. I was in the middle of fixing the test file and removing a duplicate line. Let me verify the fix worked and then run the tests again to make sure everything is correct.
Assistant
The duplicate line has been removed. Now I should run the tests again to make sure everything still passes, and then check if there are any other related tests that might be affected by my changes.
Assistant
All 12 tests pass. Now let me check the final state of the changes and make sure everything is correct. I should also run any other related tests to make sure I haven't broken anything.
Assistant
All tests pass. Let me verify the final state of all changes and make sure everything is correct before submitting.
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 →