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. The issue is about the Tasks page where selecting "Upstream" in the source selector for PRs doesn't actually query the upstream repo - it still queries origin. I need to find and fix the relevant code.
Let me first explore the repository structure and understand the codebase.
Assistant
Let me focus on the specific files mentioned in the issue description
Assistant
Let me look at the specific files mentioned in the issue:
Assistant
Let me examine these files, starting with the GitHub client:
Assistant
The open command might be different. Let me try just using
cator theopencommand correctly.Assistant
Let me search for the relevant functions in this file:
Assistant
Let me look at the
listWorkItemsfunction and the surrounding code:Assistant
The file is already open. Let me navigate to the relevant lines
Assistant
Let me use different commands to view the file content.
Assistant
Let me understand the difference between
resolveIssueSource,getOwnerRepo, and `getOwnerRepoForRemoteAssistant
Let me look at
resolveIssueSourceandgetIssueOwnerRepoin detailAssistant
Now let me look at how
prOwnerRepois used in the workerAssistant
Let me look at the
countWorkItemsfunction andIssueSourcePreferencetypeAssistant
Let me find the
IssueSourcePreferencetype and thegetOwnerRepofunctionAssistant
Let me see
getOwnerRepoandgetOwnerRepoForRemotein gh-utilsAssistant
Now let me look at the TaskPage.tsx to understand how the sources are used in the renderer
Assistant
Let me look at the key sections in TaskPage.tsx
Assistant
Let me look at the source selector UI around line 7037 and where the preference is sent
Assistant
Let me search for where
perRepoSourceStateis populatedAssistant
Let me see line 2937 to understand how
perRepoSourceStateis builtAssistant
Let me find the
fetchWorkItemsAcrossReposfunction andlistWorkItemscallsAssistant
Let me find the store that calls
listWorkItemsandcountWorkItemsAssistant
Let me look at the IPC handlers to see how
listWorkItemsandcountWorkItemsare calledAssistant
Let me find the
IssueSourceSelectorcomponent to understand how it worksAssistant
Let me check the types for sources and ListWorkItems
Assistant
Let me see the full type definition:
Assistant
Let me look at the full context of how the IssueSourceSelector is called in TaskPage.ts
Assistant
Let me look at the TaskPageRepoSourceState type
Assistant
Let me find the type definition and the build function:
Assistant
Let me see the type and build function:
Assistant
Let me look at
WorkItemsCacheSourcestypeAssistant
Let me look at how the renderer gets repo info and what fields are available
Assistant
Let me check what info repos have in the renderer
Assistant
Let me see the Repo type at line 90:
Assistant
Let me check GitHubRepositoryIdentity:
Assistant
Now I have a clear understanding of the problem. Let me plan the fix:
src/main/github/client.ts: MakeprOwnerReporespect thepreferenceparameter (likeissueResolveddoes). When preference is'upstream', use the upstream repo; otherwise use origin.src/main/github/client.ts: Updatesources.prsto reflect the effective PR source.src/renderer/src/components/TaskPage.tsx: The IssueSourceSelector'soriginprop should always be the origin repo, not the effective PR source.
However, for point 3, the renderer needs the origin repo info. Currently it gets it from
sources.prs(which is always origin). After the fix,sources.prswould change. I need to add anoriginfield to sources, or find another way.Let me check the existing source test to understand the expected behavior better, then implement the fix:
Assistant
Let me find test files for the GitHub client
Assistant
Let me look at the work items and issue source tests:
Assistant
Now I have a complete understanding. Let me implement the fix. I'll modify:
src/main/github/client.ts- MakeprOwnerReporespect preferencesrc/shared/types.ts- Addoriginfield tosources(for the selector)src/renderer/src/store/slices/github.ts- AddorigintoWorkItemsCacheSourcessrc/renderer/src/components/TaskPage.tsx- Usesources.originfor the selector
Let me start with the backend fix:
Assistant
Now let me implement the changes. First, let me update the types to add
originfieldAssistant
Now let me check the
WorkItemsCacheSourcesin the renderer store:Assistant
Let me now apply the changes. First, fix
listWorkItemsinclient.ts:Assistant
Let me use the proper syntax for the replace command:
Assistant
Let me use sed directly to make the changes
Assistant
Let me use sed to make the change:
Assistant
Let me verify the change:
Assistant
I see a duplicate line. Let me fix it:
Assistant
Let me verify the current state:
Assistant
Good. Now let me update the
sourcesreturn inlistWorkItemsto includeoriginAssistant
Now I need to update the types. Let me update
ListWorkItemsResultandWorkItemsCacheSourcesto includeorigin, and then update the renderer.First, let me update `shared/types.ts
Assistant
Let me update the
ListWorkItemsResulttype to add `originAssistant
Let me use sed to make the change. First let me open the types.ts file:
Assistant
Let me find the
ListWorkItemsResulttype and addorigin:Assistant
Now let me add the
originfield to the typesAssistant
Let me verify
Assistant
The field ordering is wrong. Let me fix it
Assistant
Let me fix the comment and field ordering properly
Assistant
Let me verify again:
Assistant
I severely corrupted the file. Let me restore and redo this more carefully.
Assistant
Let me verify the original state and redo this properly
Assistant
Let me use a more precise approach with Python to edit the types file
Assistant
Let me use node instead
Assistant
Let me verify the types.ts change
Assistant
Now let me update the
WorkItemsCacheSourcesin the renderer storeAssistant
Now update
listWorkItemsreturn to includeorigin:Assistant
Now let me update the sources to include
origin:Assistant
Now let me fix
countWorkItems:Assistant
Now let me fix
countWorkItems:Assistant
Let me verify the changes look correct:
Assistant
Let me also verify the
listWorkItemsfunctionAssistant
Now let me update the renderer. First, let me look at the relevant functions in TaskPage.tsx:
Assistant
Let me update the renderer functions and the selector call:
Assistant
Let me also check if there are other places where
sources.prsis used that need updatingAssistant
I need to fix another instance of
origin={s.sources.prs}at line 9704. Let me also check line 9694:Assistant
Let me fix this block too:
Assistant
Let me check the toast code at line 2971:
Assistant
Let me check the cache selectors file for other usages:
Assistant
Let me also check the
IssueSourceIndicatorto see if it needs changesAssistant
Let me check the IssueSourceIndicator component
Assistant
Let me verify the
sameGitHubOwnerRepofunctionAssistant
Now let me run the tests to see if my changes break
Assistant
Let me run the specific test files related to my changes
Assistant
Let me run the issue-source test:
Assistant
The test fails because it doesn't expect the
originfield. Let me fix the test:Assistant
Let me find all places in the test file that check
result.sources:Assistant
Let me see both test assertions:
Assistant
Let me fix the failing test at line 563:
Assistant
Let me rerun the tests:
Assistant
Let me also run all GitHub-related tests:
Assistant
Let me also run the task page related tests:
Assistant
That test failure is a pre-existing package resolution issue, not related to my changes. Let me verify by checking git status:
Assistant
I need to handle the fallback case when upstream doesn't exist. Let me fix
prOwnerRepoto fall back to origin:Assistant
Let me verify the change and run tests again:
Assistant
Let me also check countWorkItems:
Assistant
Let me run all GitHub-related tests again
Assistant
Let me search for other places that might need updating:
Assistant
Let me also check the main process for other usages:
Assistant
Let me check where
buildSearchQueryStringis used and verify it uses the correct ownerRepo:Assistant
Let me check
buildWorkItemListArgsto see how it usesownerRepo:Assistant
Let me check
countWorkItemsForQuery:Assistant
Let me verify the final state of
listWorkItemsreturn:Assistant
Let me check if there are other consumers of
ListWorkItemsResultthat need updating:Assistant
Let me check how sources are stored in the store slice:
Assistant
Let me check
fetchWorkItemsto see how sources are stored in theAssistant
Let me look at how sources are stored from the IPC response:
Assistant
Let me check if there are renderer store tests that might be affected:
Assistant
Let me check these test cases more closely to see if they need updating:
Assistant
Let me run the renderer store tests to confirm:
Assistant
Let me review the full diff of all changes
Assistant
Let me run all main GitHub tests one final time to confirm everything
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.