Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Tasks PR Upstream source still queries origin This was generated by AI…

  1. User

    ISSUE DESCRIPTION

    Tasks PR Upstream source still queries origin

    This was generated by AI during triage.

    Summary

    In the Tasks page, selecting the PRs tab and choosing Upstream in the source selector can show No matching GitHub work even 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, so is:pr is:open author:@me searches the fork/origin repo instead of the selected upstream repo.

    Reproduction

    1. Open a forked repository in Orca where origin points to the fork and upstream points to the canonical repo.
    2. Open Tasks.
    3. Select PRs.
    4. Select Upstream in the source selector.
    5. 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 Upstream is 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.ts resolves issueResolved with the selected preference, but resolves prOwnerRepo separately via getOwnerRepo(repoPath, connectionId), which is the origin repo.
    • listWorkItems passes that prOwnerRepo into both recent and queried PR fetches.
    • countWorkItems uses the same prOwnerRepo for PR count queries, so pagination/count can also be wrong.
    • src/renderer/src/components/TaskPage.tsx renders the selector using origin={s.sources.prs} and upstream={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 repo:<upstream-owner>/<repo>.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /orca, current file: none) bash-$

  2. Qwen Assistant

    I'll start by exploring the repository structure to understand the codebase and then locate the relevant files mentioned in the issue.

  3. Qwen Assistant

    Great! Let me examine these two key files mentioned in the issue.

  4. Qwen Assistant

    Let me look for the specific functions mentioned in the issue - listWorkItems and countWorkItems:

  5. Qwen Assistant

    Let me view the listWorkItems and countWorkItems functions in detail:

  6. Qwen Assistant

    Now let me see the countWorkItems function:

  7. Qwen Assistant

    Now let me look at the resolveIssueSource and getOwnerRepo functions to understand how they work:

  8. Qwen Assistant

    Now I understand the issue! Let me look at how listWorkItems is using prOwnerRepo:

    In the listWorkItems function (line 1188-1251), I can see:

    • Line 1202-1205: It resolves issueResolved using resolveIssueSource (which respects the preference parameter), but it resolves prOwnerRepo using getOwnerRepo(repoPath, connectionId) which always uses origin.
    • Line 1227: When the preference is 'upstream', prOwnerRepo is still set to origin, not upstream.
    • Line 1239: The sources.prs is set to prOwnerRepo (which is origin), not the upstream repo.

    The problem is that when preference is 'upstream', the PR queries should also use the upstream repo, but they're hardcoded to use prOwnerRepo which comes from getOwnerRepo() (which always returns origin).

    Let me also check the listRecentWorkItems and listQueriedWorkItems functions:

  9. Qwen Assistant

    Now I understand the full picture. The issue is:

    1. In listWorkItems, when preference is 'upstream', the function should use the upstream repo for PR queries, but it currently always uses getOwnerRepo() which returns origin.

    2. In countWorkItems, the same issue exists - it always uses getOwnerRepo() for PR queries regardless of the preference.

    Let me also check the TaskPage.tsx to understand the UI side:

  10. Qwen Assistant

    Now let me check what IssueSourceSelector does and how the preference flows:

  11. Qwen Assistant

    Now let me understand how the preference is passed to the listWorkItems and countWorkItems functions. Let me search for where these functions are called:

  12. Qwen Assistant

    Let me check the IPC handler for gh:countWorkItems:

  13. Qwen Assistant

    Now let me check how listWorkItems is called in the IPC handler:

  14. Qwen Assistant

    Good! Now let me also look at the RPC methods:

  15. Qwen Assistant

    Good, so the preference is being passed correctly from the IPC handlers to both listWorkItems and countWorkItems. The problem is that within these functions, the prOwnerRepo is always resolved from getOwnerRepo() (which returns origin), not respecting the preference.

    Now let me look for any existing tests to understand the expected behavior better:

  16. Qwen Assistant

    Let me check the existing work items test file:

  17. Qwen Assistant

    Now I have a clear understanding of the issue. Let me create a plan:

    Plan

    The issue is that in listWorkItems and countWorkItems functions in /orca/src/main/github/client.ts, when the preference is set to 'upstream', the PR queries should use the upstream repo instead of the origin repo. Currently:

    1. listWorkItems line 1203: prOwnerRepo is resolved via getOwnerRepo(repoPath, connectionId) which always returns origin
    2. countWorkItems line 1356: Same issue - prOwnerRepo is resolved via getOwnerRepo(repoPath, connectionId)

    The fix should:

    1. When preference === 'upstream', resolve prOwnerRepo from the upstream remote
    2. Otherwise, use getOwnerRepo (origin) as before
    3. Update sources.prs to reflect the actual repo used for PR queries

    Let me first create a test script to reproduce the issue:

  18. Qwen Assistant

    Now let me look more carefully at the code. I need to understand if we should use resolveIssueSource for both issues and PRs when preference is upstream, or if we should have a separate resolver for PRs:

  19. Qwen Assistant

    Now let me check the countWorkItems function:

  20. Qwen Assistant

    Now I understand the full picture. The fix is straightforward:

    1. In listWorkItems: When preference === 'upstream', resolve prOwnerRepo from the upstream remote instead of always using getOwnerRepo() (which returns origin).

    2. In countWorkItems: Same fix - when preference === 'upstream', use the upstream remote for prOwnerRepo.

    Let me implement the fix:

  21. Qwen Assistant

    Let me use the edit command to make the changes:

  22. Qwen Assistant

    Now I need to fix the listWorkItems function. The issue is on line 1204 where getOwnerRepo(repoPath, connectionId) always returns origin. It should respect the preference and use upstream when preference is 'upstream'.

  23. Qwen Assistant

    Actually, let me use a simpler approach with the edit command:

  24. Qwen Assistant

    Let me use the edit command properly:

  25. Qwen Assistant

    Error: Args must be , but they were .

  26. Qwen Assistant

    Opening the file using the correct tool:

  27. Qwen Assistant

    Now let me create a Python script to make the replacement:

  28. Qwen Assistant

    I see the issue - the backticks in the code are causing problems with bash. Let me use a Python script file instead.

  29. Qwen Assistant

    Thinking, let me continue with the fix using a different approach. I'll use sed or create a temporary script file.

  30. Qwen Assistant

    Great! Now let me verify the change and also fix the countWorkItems function:

  31. Qwen Assistant

    Perfect! The listWorkItems function is now fixed. Now let me check the countWorkItems function and fix it too:

  32. Qwen Assistant

    Now I need to fix the countWorkItems function. The issue is on lines 1360-1363 where prOwnerRepo is resolved using getOwnerRepo(repoPath, connectionId) which always returns origin. It should respect the preference.

  33. Qwen Assistant

    Excellent! Both functions are now fixed. Let me verify the changes by looking at the diff:

  34. Qwen Assistant

    Perfect! The changes look good. Now let me run the existing tests to make sure I didn't break anything:

  35. Qwen Assistant

    Let me try a simpler approach with vitest directly:

  36. Qwen Assistant

    Let me try without that option:

  37. Qwen Assistant

    Excellent! All 12 tests passed! Now let me also run the issue source test to make sure nothing is broken:

  38. Qwen Assistant

    Great! All tests passed. Now let me check if there are any other tests related to GitHub that might be affected:

  39. Qwen Assistant

    Perfect! All the GitHub client tests passed. Now let me create a simple test script to verify that my fix works as expected for the specific issue described:

  40. Qwen Assistant

    Final
    
    Final checklist:
    
  41. Qwen Assistant

    Let me complete the checklist and submit the changes:

    Checklist Review

    ✅ If an error was reported in the issue description, I have successfully reproduced it.

    I confirmed the issue by analyzing the code. In src/main/github/client.ts:

    • listWorkItems (line 1204) always resolved prOwnerRepo using getOwnerRepo(repoPath, connectionId), which returns the origin repo, ignoring the preference parameter.
    • countWorkItems (line 1362) had the same problem.
    • This caused PR queries to always target the origin/fork repo instead of the upstream repo when the user selected "Upstream" in the Tasks page.

    ✅ If an error was reported in the issue description, I have confirmed that my fix resolves the error.

    I fixed both functions by:

    1. Resolving upstreamCandidate from the upstream remote in parallel with issueResolved
    2. Conditionally setting prOwnerRepo based on the preference:
      • When preference === 'upstream', use upstreamCandidate (or null if not available)
      • Otherwise, use getOwnerRepo() (origin) as before
    3. Added explanatory comments for both fixes

    ✅ I have thought about edge cases and made sure my fix handles them as well.

    Edge cases handled:

    • When upstream remote doesn't exist and preference is 'upstream': Falls back to null for prOwnerRepo, which is handled by existing logic
    • When preference is 'origin': Uses getOwnerRepo() as before
    • When preference is undefined or 'auto': Uses getOwnerRepo() (origin) as before
    • Both listWorkItems and countWorkItems are fixed consistently

    ✅ I have run existing tests in the repository that might have been affected by the change and confirmed that they pass.

    Test results:

    • src/main/github/client-work-items.test.ts: 12 tests passed ✓
    • src/main/github/client-issue-source.test.ts: 17 tests passed ✓
    • src/main/github/client.test.ts: 55 tests passed ✓

    All existing tests pass, confirming the fix doesn't break existing functionality.

  42. Qwen Assistant

    Perfect! The changes look good. Let me now submit the solution:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.