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
I'll start by exploring the repository structure to understand the codebase and locate the files mentioned in the issue description.
- Assistant
Let me explore the structure more specifically.
- Assistant
Let me look at the src directory structure and find the files mentioned in the issue.
- Assistant
Let me look for the GitHub client file.
- Assistant
Let me examine the GitHub client file to understand the issue.
- Assistant
Let me search for key terms in the file to understand the issue.
- Assistant
Let me look at the
listWorkItemsandcountWorkItemsfunctions more closely to understand the issue. - Assistant
Let me look at the
countWorkItemsfunction and also check theresolveIssueSourcefunction to understand how preferences work. - Assistant
Let me look at the
resolveIssueSourcefunction to understand how it resolves the issue source. - Assistant
Let me check where
resolveIssueSourceis defined. - Assistant
Let me look at that function.
- Assistant
Let me check what
getOwnerRepodoes. - Assistant
Let me look at the
getOwnerRepofunction. - Assistant
Now I understand the issue. Let me look at the test files to understand the test structure.
- Assistant
The test files mentioned in the issue are likely
/orca/src/main/github/client-work-items.test.tsand/orca/src/main/github/client-issue-source.test.ts. Let me examine these. - Assistant
Let me now look at the
listQueriedWorkItemsandlistRecentWorkItemsto understand howprOwnerRepois passed. - Assistant
Let me also look at the renderer component to understand the issue.
- Assistant
Let me search for the issue source selector in TaskPage.tsx:
- Assistant
Now let me look at the test file to understand how to run tests:
- Assistant
Let me trace through the code more carefully. The fix should:
- In
listWorkItems: instead ofgetOwnerRepo(repoPath, connectionId)forprOwnerRepo, use the preference-aware resolved source (same asissueResolved.source) - In
countWorkItems: same fix - Update the test to reflect the new behavior where PRs also follow the preference
Let me first look at how the issue source preference works more closely and then look at the related types.
- In
- Assistant
Let me check the IssueSourcePreference type definition.
- Assistant
Now I understand the issue clearly. The core problem is:
- In
listWorkItemsandcountWorkItems,prOwnerRepois resolved viagetOwnerRepo(repoPath, connectionId)which always returns the origin repo. - When the user selects "upstream" preference, the issue queries use upstream (via
resolveIssueSource), but PR queries still use origin. - The fix should make PR queries also use the preference-aware source.
The simplest fix: instead of resolving
prOwnerReposeparately, derive it fromissueResolved.source- when the user selects 'upstream', both issues and PRs should query the upstream repo.Let me implement the fix now.
Now I have a clear understanding of the issue. Let me run the existing tests first to confirm they pass, then I'll implement the fix.
- In
- Assistant
Good, the tests pass. Now let me implement the fix. First, let me open the client.ts file:
- Assistant
Now I have a clear understanding of the issue. Let me implement the fix:
- In
listWorkItemsandcountWorkItems,prOwnerRepois always resolved viagetOwnerRepo(repoPath, connectionId)which always returns the origin repo, ignoring the user's preference. - When the user selects "Upstream", PR queries should also use the upstream owner/repo.
The fix: derive
prOwnerRepofromissueResolved.source(which already respects the preference) instead of always usinggetOwnerRepo(which always returns origin). - In
- Assistant
Now let me fix the
listWorkItemsfunction. I need to replacegetOwnerRepo(repoPath, connectionId)forprOwnerRepowith the preference-aware source fromissueResolved: - Assistant
Now let me fix the
countWorkItemsfunction similarly: - Assistant
Now let me fix the
countWorkItemsfunction similarly: - Assistant
Wait, I notice that since
prOwnerRepo = issueOwnerRepo, thesameOwnerRepocheck would always be true, making the split logic dead code. Let me simplify thecountWorkItemsfunction more: - Assistant
I see there's dead code left. Let me clean up the
countWorkItemsfunction properly: - Assistant
Let me verify the function looks correct now:
- Assistant
Good. Now let me verify the
listWorkItemsfunction looks correct: - Assistant
Good. Now I need to update the tests. Let me look at the test file again to understand what changes are needed:
- Assistant
Now I need to understand the test changes needed. Let me look at what
countWorkItemsForQuerydoes: - Assistant
Let me check the countWorkItemsForQuery function to understand how it builds the query:
- Assistant
Now I need to update the tests. With my fix, both issues and PRs use the same preference-aware source. Let me update the test file. First let me run the tests to see what fails:
- Assistant
I see the test failures. The tests expected different repos for issues vs PRs, but now both use the same preference-aware source. Let me update the tests. First, let me look at
listRecentWorkItemsto understand the call pattern better: - Assistant
Let me also look at the count test cases that might be affected:
- Assistant
Let me look at the rest of the test file to see all tests:
- Assistant
Now I need to update the tests. Since PRs now use the same preference-aware source as issues, the tests need to reflect that. Let me update them one by one:
- Assistant
Now let me update the no-cache test:
- Assistant
Now let me update the SSH repo test -
getOwnerRepois no longer called: - Assistant
Now let me update the issue/PR scope test - PRs now use the same upstream repo:
- Assistant
Now let me update the count test - now only one search API call is made:
- Assistant
Now let me update the 403 test -
prssource is now the same asissues: - Assistant
It looks like there's a duplication issue in the file. Let me check the current state:
- Assistant
There's a duplication issue. Let me fix the file by replacing the duplicated section. Let me see the full range that needs to be fixed:
- Assistant
I see the issue. There's a duplicated test and an orphaned code block. Let me fix this by replacing the entire duplicated section:
- Assistant
Good, the file looks correct now. Now let me update the preference tests in the describe block. Let me see what's left:
- Assistant
Now I need to update the preference tests to remove
getOwnerRepoMockexpectations since it's no longer called. Let me update them: - Assistant
Good. Now let me also check the 'typed PR lookup' and 'raw number lookup' tests. They use
getOwnerRepoMockbut those tests are forgetWorkItemnotlistWorkItems. Let me verify they don't need changes: - Assistant
These tests are for
getWorkItem, notlistWorkItems. Let me check ifgetWorkItemwas affected by my changes: - Assistant
Good,
getWorkItemis a separate function that doesn't use the preference parameter, so those tests should still be fine. Let me now run the tests again: - Assistant
All 17 tests pass. Now let me run other related test files to make sure I haven't broken anything:
- Assistant
Good. Let me also run the other test files that reference listWorkItems or countWorkItems:
- Assistant
Good. Let me also run the renderer test file:
- Assistant
That's a pre-existing issue with a missing module, not related to my changes. Let me run the runtime tests:
- Assistant
That's a pre-existing issue with native modules. Let me check the IPC runtime-environments test:
- Assistant
Good. Now let me verify the final state of the changes. Let me check the diff:
- Assistant
Let me check the full diff:
- Assistant
Now let me check the test file diff:
- Assistant
Good. Now let me add the specific test cases suggested in the issue description for regression coverage:
- Assistant
Now let me add the specific test cases suggested in the issue description for regression coverage. I'll add them at the end of the describe block:
- Assistant
There's a missing closing bracket. Let me fix the file:
- Assistant
There's a duplication issue again. Let me fix it properly:
- Assistant
Now let me run the tests again:
- Assistant
All 19 tests pass. Let me also run the other related test files again to confirm nothing is broken:
- Assistant
All tests pass. Let me verify the final state of my changes one more time:
- Assistant
Let me also check if there are any TypeScript compilation errors:
- Assistant
Good, no TypeScript errors. Let me verify that
getOwnerRepois still used elsewhere in the file so the import is still needed: - Assistant
Good,
getOwnerRepois still used elsewhere in the file. Let me now create a quick summary of the changes and do a final review:Summary of Changes
Problem
When the user selects "Upstream" in the Tasks PRs source selector, PR list and count queries were still resolved from the origin (fork) repo instead of the upstream repo.
Root Cause
In
listWorkItemsandcountWorkItems,prOwnerRepowas always resolved viagetOwnerRepo(repoPath, connectionId)which always returns the origin repo, ignoring the user's preference.Fix
src/main/github/client.ts:-
listWorkItems: Removed thegetOwnerRepocall forprOwnerRepoand derived it fromissueResolved.sourceinstead, so both issues and PRs use the same preference-aware source. -
countWorkItems: Simplified to useissueResolved.sourceas the single owner/repo for the search query, since both issues and PRs now target the same repo. This eliminates the need for the split-issue/PR counting logic.
-
- Assistant
All tests pass. Let me run all related tests one final time to confirm:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.