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 and understanding the codebase to reproduce and fix the issue.
Assistant
Let me explore the repository structure first.
Assistant
Now let me look at the key file mentioned in the issue.
Assistant
Let me search for the relevant functions mentioned in the issue.
Assistant
Let me look at the
listWorkItemsandcountWorkItemsfunctions in detail.Assistant
Let me look at the
gh-utils.tsfile to understandresolveIssueSource,getOwnerRepo, andresolvePRRepositoryCandidates.Assistant
Now let me look at the renderer side to understand the UI flow.
Assistant
Let me look at the relevant parts of TaskPage.tsx, particularly around the source selector and how the preference is used.
Assistant
Now let me look at the
IssueSourcePreferencetype and how the preference is passed to the backend functions.Assistant
Let me look at the existing test file to understand how the tests are structured, especially how they handle the preference parameter.
Assistant
Now I understand the structure. Let me look at how
listWorkItemsandcountWorkItemsare called from the main process to understand the full flow.Assistant
Now I understand the issue clearly. The
listWorkItemsandcountWorkItemsfunctions resolve the PR owner/repo viagetOwnerRepo(repoPath, connectionId)which always resolves toorigin. However, when a user selects "Upstream" in the source selector (which setsissueSourcePreferenceto'upstream'), the PR queries should also use the upstream repo, not origin.Let me look at the
ListWorkItemsResulttype andGitHubWorkItemtypes to understand thesourcesstructure.Assistant
Let me look at the
buildWorkItemListArgsfunction and the surrounding code for the queried work items.Assistant
Let me see the full
listQueriedWorkItemsfunction.Assistant
Let me see the full signatures of
listWorkItemsandcountWorkItems.Assistant
Now I have a clear understanding. Let me write a reproduction test to confirm the issue before fixing it.
Assistant
The issue is confirmed. Both PR list and count queries use origin (
fork/orca) instead of upstream (stablyai/orca). Now let me look at howsources.prsis used in the renderer to make sure I handle it correctly.Assistant
Let me look at the key usages of
sources.prsin the renderer.Assistant
Let me look at the
IssueSourceSelectorcomponent to understand how it uses origin/upstream.Assistant
Let me look at how
hasDivergentSourcesand the selector renderable are used.Assistant
Now I understand the full picture. The
sources.prsfield is used by the renderer as the "origin" option in the selector (lines 7089, 9704) and as the divergence check reference (line 2437-2441). Sosources.prsmust remain the origin repo for the selector to keep working. But the actual PR queries (inlistRecentWorkItems,listQueriedWorkItems, andcountWorkItemsForQuery) need to use a preference-awareprOwnerRepo.Let me implement the fix in
listWorkItemsfirst.Assistant
Now let me make the edit to
listWorkItems:Assistant
Let me use the
editcommand instead.Assistant
Now let me update
sources.prsto useoriginRepo:Assistant
Now let me update the
countWorkItemsfunction. Let me view it first.Assistant
Now let me run my reproduction test to verify the fixworks.
Assistant
The
listWorkItemstest passes. ThecountWorkItems"failure" is actually a false negative in my test — the query IS usingrepo:stablyai/orcabut it's URL-encoded (repo%3Astablyai%2Forca). Let me verify by decoding:Assistant
The fix is confirmed working — the search query uses
repo:stablyai/orca(upstream), notrepo:fork/orca(origin). Let me update my reproduction test to decode the URL and confirm both tests pass:Assistant
Both tests pass now. Now let me run the existing tests to make sure I haven't broken anything.
Assistant
All existing tests pass. Now let me also test some edge cases. Let me think about edge cases:
- preference='upstream' but no upstream exists (fellBack): PRs should fall back to origin.
- preference='origin': PRs should use origin.
- preference='auto': PRs should use origin (default).
- preference='upstream' with upstream in count with mixed query scope: should use upstream for PRs.
Let me write a more comprehensive edge-case test:
Assistant
All edge cases pass. Now let me clean up my temporary test files and run the broader test suite to make sure nothing else is broken.
Assistant
Let me run the broader GitHub test suite to ensure nothing else broke:
Assistant
All 191 tests pass across 17 test files. Now let me also verify that the
listWorkItemsrecent (unqueried) path also handles the upstream preference correctly. The recent path uses the RESTrepos/.../pullsendpoint. Let me check that the recent path also routes correctly with my fix by examining thelistRecentWorkItemsflow once more, and run a quick test:Assistant
The test file needs to be in the src directory. Let me put it there.
Assistant
Let me see the full output to understand what's happening.
Assistant
The issue is just the query string appended. Let me fix the test assertions to use substring matching.
Assistant
The recent (unqueried) path also correctly routes PRs to upstream. Let me clean up the temporary test and verify the renderer doesn't need any changes. Let me also double check the external link behavior in the renderer.
Assistant
Let me look at the external link logic and whether the repo's preference is available there.
Assistant
Let me check other places where
sources.prsis used as the actual PR source (not the origin reference). Let me look at lines 4750-4760 and 7050-7065.Assistant
Let me check what
primaryGithubFilterSlugis used for.Assistant
Let me check how
PRFilterDropdownsusesprimarySlug.Assistant
I need to understand how
perRepoSourceStateis structured and whether the repo's preference is available. Let me look at the state definition.Assistant
Let me check whether the repo object in the renderer has
issueSourcePreference.Assistant
Let me check the
Repotype to confirmissueSourcePreferenceis a field.Assistant
Let me check the
WorkItemsCacheSourcestype.Assistant
Let me check if there are renderer tests that might be affected, and look at the helper imports in TaskPage.tsx.
Assistant
Now let me decide on the renderer fix. The
primaryGithubFilterSlug(used for label/assignee filter dropdowns) andselectedGitHubRepoExternalLinkboth usesources.prsas the PR source. With my backend fix, when preference is 'upstream', PRs come from upstream, so these should also use the upstream repo. Let me add a helper and update both usages.Let me first check what
repoMapis and if it's available in theprimaryGithubFilterSlugscope.Assistant
Let me add a helper function in
task-page-cache-selectors.ts. First let me check the existing imports.Assistant
Now let me add the
effectivePRSourcehelper function. First, update the import to includeIssueSourcePreferenceandGitHubOwnerRepo:Assistant
Now let me add the
effectivePRSourcehelper function afterbuildTaskPageRepoSourceState:Assistant
Now let me update the
TaskPage.tsxto import and useeffectivePRSource. First, let me check the existing imports fromtask-page-cache-selectors.Assistant
Let me add
effectivePRSourceto the import:Assistant
Now let me update the
selectedGitHubRepoExternalLinkto useeffectivePRSource:Assistant
Now let me update the
primaryGithubFilterSlug. Let me view it:Assistant
Now I need to update
primaryGithubFilterSlugto useeffectivePRSourcefor the PRs view. TheperRepoSourceStatedoesn't have the preference, so I need to look it up fromrepoMap. Let me update:const primaryGithubFilterSlug = useMemo(() => { for (const state of perRepoSourceState) { const source = activeGithubTaskKind === 'prs' ? effectivePRSource(repoMap.get(state.repoId)?.issueSourcePreference, state.sources) : state.sources?.issues if (source) { return source } } return null }, [activeGithubTaskKind, perRepoSourceState, repoMap])Wait,
repoMap.get(state.repoId)?.issueSourcePreference- does the repo type inrepoMaphaveissueSourcePreference? Let me verify. TheRepotype has it (line 112 of types.ts). SorepoMap.get(state.repoId)?.issueSourcePreferenceshould work.But wait -
effectivePRSourcealready handles the case whensourcesis null (returns null). And it already handles the fallback chain. So for the PRs view, I can just useeffectivePRSource(preference, state.sources).Let me make the change.
Assistant
Now let me check the
IssueSourceIndicatorusage at line 7059 (prs={s.sources.prs}) to see if it needs updating.Assistant
Let me look at the
IssueSourceIndicatorcomponent to understand what it does with theprsprop.Assistant
The
IssueSourceIndicatorusesprsonly for a suppression rule (showing "Issues from {slug}" when issues and PRs differ). Sincesources.prs= origin andsources.issues= upstream (when preference is 'upstream'), this correctly shows the issues source. No change needed there.Now let me run the typecheck and tests to make sure everything compiles and passes.
Assistant
All tests pass. Now let me run the typecheck to ensure the TypeScript compiles correctly.
Assistant
There's a type error —
sourceState?.sourcesisundefined-able. Let me update theeffectivePRSourceparameter type to acceptundefined:Assistant
Now let me re-run the web typecheck:
Assistant
The web typecheck passes. Let me also run the CLI typecheck:
Assistant
All typechecks pass. Now let me run the linter to make sure my changes follow the code style.
Assistant
No lint errors. Now let me write a comprehensive reproduction test one more time to confirm the full fix works end-to-end, including the renderer helper:
Assistant
All tests pass. Let me clean up the temporary test file.
Assistant
Now let me run the broader test suite to make sure nothing is broken across the renderer and main process:
Assistant
Let me check the full list of failures to determine if they're related to my changes or pre-existing:
Assistant
These failures are in
WorktreeCard,BrowserTab,status-bar,TabBartests — all unrelated to my changes (which only touch GitHub work-item client code and TaskPage). They appear to be timeout issues. Let me verify by stashing my changes and running one of the failing tests:Assistant
The test passes in isolation — the failures are due to timeouts when running the full suite concurrently (resource contention), not my changes. Let me restore my changes:
Assistant
Let me verify my changes are still intact and run the directly affected tests once more to confirm they pass:
Assistant
All affected tests pass. Now let me review the complete diff of my changes:
Assistant
The diff looks clean and complete. Let me verify there are no other callers of the GitHub
listWorkItems/countWorkItemsthat might need attention, and double-check the GitLab version is separate.Assistant
The preference is correctly threaded through all callers (IPC handlers and runtime). Let me do a final check for any leftover temp files and verify the final state:
Assistant
No temp files remain. Let me run the format check to ensure my changes match the project's formatting style:
Assistant
All formatting is correct. Let me do a final comprehensive test run of all the directly affected test files to make a final confirmation:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.