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 with .
- Open a forked repository in Orca where
Assistant
Let me analyze this issue. The problem is that in the Tasks page, when the user selects "Upstream" as the source for PRs, the GitHub client still queries the origin repository instead of the upstream repository.
Let me first explore the codebase to understand the structure and find the relevant files mentioned in the issue:
src/main/github/client.ts- whereissueResolvedandprOwnerRepoare resolvedsrc/renderer/src/components/TaskPage.tsx- where the selector is rendered
Let me start by exploring the repository structure.
Assistant
The user is asking me to list the checklist items and explain my reasoning for each. Let me first continue exploring the codebase to understand the issue, then I'll provide the checklist at the end when I'm ready to submit.
Let me open the client.ts file to understand the current implementation.
Assistant
I need to read the file in chunks to avoid the broken pipe error. Let me continue reading the client.ts file to understand the structure, particularly focusing on
listWorkItemsandcountWorkItemsfunctions mentioned in the issue.Assistant
Now let me read the
listWorkItemsandcountWorkItemsfunctions more carefully:Assistant
Now let me see the
countWorkItemsfunction and understand howprOwnerRepois being used:Assistant
Now I can see the issue clearly. In both
listWorkItemsandcountWorkItems:prOwnerRepois always resolved viagetOwnerRepo(repoPath, connectionId)which gets the origin repoissueResolvedis resolved viaresolveIssueSource(repoPath, preference, connectionId)which respects thepreferenceparameter (which can be 'upstream')- When the user selects "Upstream" for PRs, the
preferenceis 'upstream', butprOwnerRepostill uses origin
The fix should be to also respect the
preferenceparameter when resolving the PR owner/repo, similar to how issues are resolved. Let me look atresolveIssueSourceto understand how it works:Assistant
Good. Now I understand the issue. The
resolveIssueSourcefunction respects thepreferenceparameter ('origin', 'upstream', 'auto'), but for PRs, the code always usesgetOwnerRepo(repoPath, connectionId)which always returns the origin.Let me also check how the
preferenceparameter is used in the type definitions:Assistant
Now let me look at how
listRecentWorkItemsandlistQueriedWorkItemsuseprOwnerRepo:Assistant
Now let me also look at
listQueriedWorkItems:Assistant
Now I fully understand the issue. The problem is:
- In
listWorkItems,prOwnerRepois always set togetOwnerRepo(repoPath, connectionId)(origin), ignoring thepreferenceparameter. - In
countWorkItems, same issue -prOwnerRepois always from origin.
The fix is to make
prOwnerRepoalso respect thepreferenceparameter, similar to howissueOwnerRepodoes viaresolveIssueSource.Let me also check what happens when the preference is 'upstream' and how the
resolveIssueSourcehandles it:Looking at the code:
resolveIssueSource(repoPath, preference, connectionId)returns the upstream repo when preference is 'upstream'getOwnerRepo(repoPath, connectionId)always returns origin
The fix should be to use
resolveIssueSourcefor both issues and PRs when the preference is 'upstream'. Let me verify the function signatures and what needs to change:- In
Assistant
Now I understand. The
getOwnerRepofunction is essentiallygetOwnerRepoForRemote(repoPath, 'origin', connectionId). The fix should changeprOwnerReporesolution to useresolveIssueSource(or a similar logic) based on the preference parameter.Let me create a test script first to understand the behavior, then implement the fix:
Assistant
Now let me look at any existing tests for
listWorkItemsandcountWorkItemsto understand the expected behavior:Assistant
Let me look at the existing work items test file to understand the test patterns:
Assistant
Now I have a good understanding of the codebase. Let me now implement the fix. The issue is that in both
listWorkItemsandcountWorkItems, theprOwnerRepois always resolved from origin, ignoring thepreferenceparameter.The fix is to:
- In
listWorkItems: ChangeprOwnerRepoto useresolveIssueSourcewhen preference is specified, similar toissueOwnerRepo - In
countWorkItems: Same change
Let me first look at the exact lines I need to modify:
- In
Assistant
Now I understand the issue. The fix should change the
prOwnerReporesolution from always usinggetOwnerRepo(repoPath, connectionId)(which is origin) to using the sameresolveIssueSourcelogic based on the preference.The key insight is:
- When
preference === 'upstream', bothissueOwnerRepoandprOwnerReposhould resolve to the upstream repo - When
preference === 'origin', both should resolve to origin - When
preferenceis undefined or'auto', the current behavior (both using origin or auto-detection) is fine
Looking at the code more carefully, I see that
resolveIssueSourcealready handles all these cases. So the fix is to use the same resolved source for both issues and PRs when the preference is set.Let me now make the fix:
- When
Assistant
Now I need to understand the fix more carefully. The current code:
issueResolvedusesresolveIssueSource(repoPath, preference, connectionId)- respects preferenceprOwnerRepousesgetOwnerRepo(repoPath, connectionId)- always origin
The fix should make
prOwnerRepoalso respect the preference. SinceresolveIssueSourcealready returns the correct source based on preference, I can simply deriveprOwnerRepofromissueResolved.sourceas well, OR callresolveIssueSourceagain.But wait - looking more carefully, the issue is that when the user selects "Upstream" for PRs specifically, we want PR queries to use the upstream repo. The current
resolveIssueSourceis designed for issues, but the logic is the same.The simplest fix is to also use
resolveIssueSourcefor PRs, which would give us the same source for both issues and PRs when a preference is set. This is exactly what the issue describes - when "Upstream" is selected, both PR list and count queries should use the upstream owner/repo.Let me implement the fix:
Assistant
I'll replace the
getOwnerRepo(repoPath, connectionId)call withresolveIssueSource(repoPath, preference, connectionId)so that PR queries also respect the preference setting.Assistant
The sed command duplicated the lines. Let me revert and fix properly:
Assistant
Let me verify the file is restored:
Assistant
Good. Now let me use the edit command properly. I need to replace lines 1202-1207:
Assistant
Assistant
Let me create a proper patch file and apply it:
Assistant
Let me use Python to make this edit properly:
Assistant
system_invoke_errored: could not process careeration between tool and codebarrel, reason: most likely codebarrel-heavy part ">>>>>>> REPLACE" is malformed or overlaps with codebarrel-heavy part ">>>>>>> SEARCH" Let me check the file and try again with a simpler approach.
Assistant
Let me use Node.js to make the edit:
Assistant
Now let me verify the change was applied correctly:
Assistant
Now I need to apply the same fix to
countWorkItems. Let me check that function:Assistant
Let me verify both changes:
Assistant
Now let me check the diff to see all my changes:
Assistant
Wait, I notice an issue with my changes. Looking at the diff, the old code had
resolveIssueSourcecalled twice now instead ofresolveIssueSourceandgetOwnerRepo. This is functionally correct but redundant - both calls will return the same result since they use the same parameters. Let me optimize this by reusing the same resolved source for both:Actually, looking at the issue more carefully, the problem is that when
preference === 'upstream':issueOwnerRepocorrectly resolves to upstreamprOwnerRepoincorrectly still uses origin
With my fix, both now use
resolveIssueSource, which means whenpreference === 'upstream', both will correctly resolve to upstream.However, I'm calling
resolveIssueSourcetwice with the same parameters, which is wasteful. Let me optimize this to only call it once and reuse the result:Assistant
Let me think about this more carefully. The
resolveIssueSourcefunction is async and may do remote lookups. Calling it twice with the same parameters would be inefficient. Instead, I should just reuse the same source for both issues and PRs when the preference is set.Looking at the logic:
- When
preference === 'upstream': both issues and PRs should use upstream - When
preference === 'origin': both issues and PRs should use origin - When
preferenceis undefined or'auto': the current behavior (using origin for PRs) is acceptable since there's no explicit preference
So the simplest fix is to just derive
prOwnerRepofromissueOwnerRepowhen the preference is explicitly set:- When
Assistant
The cleanest fix is to replace
getOwnerRepo(repoPath, connectionId)withresolveIssueSource(repoPath, preference, connectionId)and extract the source from the result. Let me do this properly:Assistant
The changes look correct. Now let me run the existing tests to make sure I haven't broken anything:
Assistant
I see the test failures. The issue is that the tests mock
resolveIssueSourceto return a value based ongetIssueOwnerRepoMock, but now I'm callingresolveIssueSourcetwice, and the mock only has one return value set up.Assistant
Let me think about this differently. The issue is that the
preferenceparameter controls which source (origin vs upstream) should be used for both issues and PRs. But the tests mockgetIssueOwnerRepoMockandgetOwnerRepoMockseparately, and they expect different functions to be called.A cleaner approach would be to only resolve the source once and use it for both issues and PRs when a preference is explicitly set:
Assistant
The key insight is: when
preferenceis explicitly set to'upstream'or'origin', bothissueOwnerRepoandprOwnerReposhould use the same resolved source. When preference is not set (or'auto'), the existing behavior (separate resolution) is fine.Let me implement this logic:
Assistant
Now let me run the tests again:
Assistant
Excellent! All 12 tests pass! Now let me run more tests related to the GitHub client to make sure I haven't broken anything else:
Assistant
All tests pass. Let me also run the issue source tests to make sure:
Assistant
All tests pass! Let me also run a broader set of GitHub-related tests to make sure nothing is broken:
Assistant
I need to check the IPC layer and any other places where
listWorkItemsandcountWorkItemsare called to make sure the preference parameter is being passed through correctly.Assistant
I need to check the IPC layer to make sure the preference parameter is being passed through correctly to
listWorkItemsandcountWorkItems.Assistant
Let me look at the IPC handlers to see how the preference is being passed.
Assistant
The IPC layer correctly passes
repo.issueSourcePreferenceto both functions. Let me run the IPC tests to verify everything passes.Assistant
The IPC tests pass. Now let me verify the fix is correct by looking at the final diff and making sure the logic is sound. )
<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git diff src/main/github/client.ts </tool_call>
Assistant
I need to use the bash_terminal function to run the git diff command.
Assistant
The fix looks correct. Let me now run a broader test suite to ensure nothing is broken elsewhere.
Assistant
The 7 failed tests are due to a missing native module (
pty.node) which is an environment issue unrelated to my code changes. All 930 tests that could run passed successfully.Let me verify the final state of my changes and make sure everything is correct:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.