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 start by understanding the repository structure and the issue at hand. The issue is that when selecting "Upstream" in the PRs tab source selector, the GitHub client still queries from
origininstead of the upstream repository.Let me first explore the repository structure to understand the codebase.
Assistant
Let me look at the key files mentioned in the issue:
src/main/github/client.tssrc/renderer/src/components/TaskPage.tsx
Assistant
I need to look at the file
src/main/github/client.tsmentioned in the issue to understand the problem. Let me examine it.Assistant
Let me look at the
listWorkItemsandcountWorkItemsfunctions specifically, as they are the core of the issue:Assistant
Now let me look at the
listWorkItemsfunction in detail:Assistant
Let me look at the
resolveIssueSourcefunction and thelistQueriedWorkItemsfunction more closely:Assistant
Let me look at the
listQueriedWorkItemsfunction in detail:Assistant
Let me look at the
resolveIssueSourcefunction ingh-utils.ts:Assistant
Now let me look at the
resolveIssueSourcefunction:<tool_call> <function=bash_terminal> <parameter=command> sed -n '366,450p' /orca/src/main/github/gh-utils.ts </tool_call>
Assistant
I need to include the proper tool call format. Let me look at the
resolveIssueSourcefunction in gh-utils.ts.Assistant
Assistant
Let me look at the
getIssueOwnerRepofunction to understand the current behavior.Assistant
Let me look at the
getIssueOwnerRepofunction to understand how it works.Assistant
Assistant
Let me search for the
getOwnerRepofunction definition.Assistant
Let me look at the
getOwnerRepofunction to understand its return value.Assistant
Let me look at the
countWorkItemsfunction to see the exact code:Assistant
Now I have a clear understanding of the issue. Let me now look at both functions side by side to understand exactly what needs to change:
Assistant
Now I have a clear understanding of the issue. The bug is that in both
listWorkItemsandcountWorkItems, whenpreference === 'upstream', the PR queries should use the upstream repo but they usegetOwnerRepo(repoPath, connectionId)which always returns the origin repo.Let me implement the fix for both functions:
Assistant
The edit tool failed because I need to use a different format. Let me try the edit command again with the correct syntax.
Assistant
Let me use bash commands to make the edit instead.
Assistant
Let me use sed to make the changes:
Assistant
Let me use the edit command with a heredoc to replace the problematic section.
Assistant
Let me use a different approach with sed to make the replacement:
Assistant
Let me try a different approach using Python to make the file edits:
Assistant
Let me try using sed to make the replacement:
Assistant
Good, perl is available. Let me use perl to make the edit:
Assistant
Let me verify the change was applied:
Assistant
The first edit for
listWorkItemswas successful. Now I need to apply the same fix tocountWorkItems. Let me find the exact location:Assistant
Let me look at the
countWorkItemsfunction to apply the same fix:Assistant
Now let me apply the same fix to
countWorkItems:Assistant
Let me verify the change to countWorkItems:
Assistant
Both fixes have been applied. Now let me verify that the TypeScript compiles correctly and run the existing tests:
Assistant
Let me check what test commands are available in the package.json.
Assistant
Let me first check if there are existing tests related to the GitHub client or listWorkItems/countWorkItems functions:
Assistant
Let me look at the relevant test files:
Assistant
Now let me run the existing tests to make sure my changes don't break anything:
Assistant
Let me try a different approach to run the tests:
Assistant
The test runner seems to be timing out. Let me try running it differently, perhaps using npx vitest directly.
Assistant
All 17 tests in
client-issue-source.test.tspassed. Let me also run the other related tests to make sure everything is working:Assistant
All tests pass. Let me also run the gh-utils tests to ensure the underlying utilities are still working:
Assistant
All tests pass. Let me verify my changes by reviewing the diff:
Assistant
The diff shows exactly the changes I intended:
-
In
listWorkItems: Whenpreference === 'upstream',prOwnerReponow usesissueResolved.source(which contains the upstream repo fromresolveIssueSource) instead of always usinggetOwnerRepo(repoPath, connectionId)(which is origin). -
In
countWorkItems: Same fix applied - whenpreference === 'upstream',prOwnerRepousesissueResolved.sourceinstead of always using origin.
All existing tests pass (17 in
client-issue-source.test.ts, 12 inclient-work-items.test.ts, and 22 ingh-utils.test.ts).Let me verify the fix handles all edge cases properly by examining the code flow once more:
-
Assistant
All tests pass and my fix is complete. Let me submit the solution.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.