Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging 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. Assistant

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

  3. Assistant

    Let me look for the specific files mentioned in the issue.

  4. Assistant

    Let me check the structure and read the key files mentioned in the issue.

  5. Assistant

    Let me first explore the repository structure and understand the codebase.

  6. Assistant

    Let me examine the GitHub client.ts file:

  7. Assistant

    Let me search for the relevant functions mentioned in the issue:

  8. Assistant

    Let me examine the listWorkItems function more closely:

  9. Assistant

    Now let me understand the issue more clearly. The problem is that prOwnerRepo always resolves to the origin repo (via getOwnerRepo), while the user's preference parameter (which can be 'upstream') is only used for issueResolved. Let me look at resolveIssueSource and getOwnerRepo:

  10. Assistant

    Let me look at the resolveIssueSource function more closely to understand how it handles the preference parameter.

  11. Assistant

    Now I understand the issue. Let me look at the countWorkItems function as well:

  12. Assistant

    Now I understand the issue. The problem is clear: in both listWorkItems and countWorkItems, prOwnerRepo is always resolved using getOwnerRepo(repoPath, connectionId) which returns the origin repo, regardless of the user's preference. The preference parameter is only used for the issue source resolution. We need to make the PR repo also respect the preference.

    Let me look at the test files to understand the testing patterns:

  13. Assistant

    Let me examine the test file to understand the structure better.

  14. Assistant

    Let me look at the resolveIssueSource function more closely:

  15. Assistant

    Now let me check if there's already a function for resolving PR source based on preference:

  16. Assistant

    Let me look at the test file more carefully to understand the mock patterns:

  17. Assistant

    Now let me look at how the issue/PR source resolution works to understand the pattern:

  18. Assistant

    Now let me understand the full picture. The issue is that prOwnerRepo always uses getOwnerRepo() (which resolves to origin) regardless of the user's preference. When preference is 'upstream', PRs should also use the upstream repo. Let me also look at the getOwnerRepo function to confirm:

  19. Assistant

    Now I understand the issue clearly. The problem is in both listWorkItems and countWorkItems:

    1. issueResolved is correctly resolved using the user's preference (upstream/origin/auto)
    2. prOwnerRepo is always resolved using getOwnerRepo(repoPath, connectionId) which always returns the origin remote

    When the user selects "Upstream" in the source selector, PR queries should also use the upstream repo. Let me look at the full gh-utils.ts to understand the function signatures:

  20. Assistant

    Let me check what IssueSourcePreference looks like:

  21. Assistant

    Now I have a clear picture. Let me look at the listQueriedWorkItems and listRecentWorkItems to see how they use prOwnerRepo:

  22. Assistant

    Let me look at the listRecentWorkItems function:

  23. Assistant

    Now I have a clear understanding of the issue. Let me check the IssueSourcePreference type and see how getOwnerRepoForRemote is used:

  24. Assistant

    Now I have a clear understanding of the issue. Let me trace through the logic:

    1. In listWorkItems, when preference is passed (e.g., 'upstream'), it's used for resolveIssueSource which correctly resolves the issue owner/repo based on the preference.
    2. However, prOwnerRepo is always resolved via getOwnerRepo(repoPath, connectionId), which always returns the origin remote's owner/repo, regardless of the preference.
    3. Similarly in countWorkItems, prOwnerRepo is always resolved via getOwnerRepo.

    The fix should make prOwnerRepo resolution also respect the preference parameter. When preference is 'upstream', it should use the upstream owner/repo for PRs as well.

    Let me first check the existing tests to understand the test patterns:

  25. Assistant

    Let me search more broadly:

  26. Assistant

    Let me search for tests that use the preference parameter:

  27. Assistant

    Let me look at the listQueriedWorkItems function:

  28. Assistant

    Now I have a clear picture of the issue. The problem is:

    1. In listWorkItems and countWorkItems, prOwnerRepo is always resolved via getOwnerRepo(repoPath, connectionId) which always returns the origin remote
    2. When the user selects "Upstream" in the source selector, the preference parameter is passed but only affects resolveIssueSource for issues, not for PRs
    3. This means PR queries always search the origin repo even when "Upstream" is selected

    I need to create a function to resolve PR source based on preference (similar to resolveIssueSource), and use it in both listWorkItems and countWorkItems.

    Let me first check what's exported from gh-utils.ts:

  29. Assistant

    Now I understand the full picture. Let me create a plan:

    1. Create a resolvePRSource function in gh-utils.ts similar to resolveIssueSource that respects the preference
    2. Update listWorkItems in client.ts to use resolvePRSource instead of getOwnerRepo
    3. Update countWorkItems in client.ts to use resolvePRSource instead of getOwnerRepo

    Let me first look at the full resolveIssueSource implementation to understand the pattern:

  30. Assistant

    Now I understand the issue clearly. The problem is that prOwnerRepo is always resolved using getOwnerRepo() which always returns the origin remote, regardless of the user's preference. When the user selects Upstream, PR queries should also use the upstream repo.

    The fix is to create a resolvePRSource function similar to resolveIssueSource and use it in both listWorkItems and countWorkItems.

    Let me first run the existing tests to see the current state:

  31. Assistant

    Let me try running tests with vitest directly:

  32. Assistant

    Good, existing tests pass. Now I understand the issue clearly. The problem is:

    1. In listWorkItems and countWorkItems, prOwnerRepo is always resolved using getOwnerRepo(repoPath, connectionId) which always returns the origin remote
    2. When user selects "Upstream", the preference is 'upstream' but prOwnerRepo ignores this
    3. The fix should make prOwnerRepo respect the preference, similar to how issueResolved does

    I need to create a resolvePRSource function (similar to resolveIssueSource) and use it in both listWorkItems and countWorkItems. Let me start by adding this function to gh-utils.ts:

  33. Assistant

    Now I understand the full picture. I need to:

    1. Add a resolvePRSource function in gh-utils.ts similar to resolveIssueSource
    2. Update listWorkItems and countWorkItems in client.ts to use resolvePRSource instead of getOwnerRepo
    3. Update the test mocks to include the new function

    Let me first add the resolvePRSource function:

  34. Assistant

    Now I'll add the resolvePRSource function to gh-utils.ts. For PRs, the default auto behavior should be to use origin (same as getOwnerRepo), while respecting the user's explicit upstream preference:

  35. Assistant

    Now let me add this function to gh-utils.ts:

  36. Assistant

    Let me verify the addition:

  37. Assistant

    Good. Now I need to update client.ts to import and use resolvePRSource instead of getOwnerRepo in both listWorkItems and countWorkItems. Let me first check the import line:

  38. Assistant

    Now I'll update the import to include resolvePRSource:

  39. Assistant

    Now I need to update listWorkItems to use resolvePRSource instead of getOwnerRepo. Let me find the exact lines:

  40. Assistant

    Now I'll update the listWorkItems function to use resolvePRSource instead of getOwnerRepo:

  41. Assistant

    The heredoc syntax needs to be different. Let me use the replace command instead.

  42. Assistant

    Let me navigate to that line first.

  43. Assistant

    Now I can see the exact lines. Let me replace the relevant lines in listWorkItems:

  44. Assistant

    Now let me update the countWorkItems function similarly. Let me find it:

  45. Assistant

    Now I'll update the countWorkItems function to use resolvePRSource instead of getOwnerRepo:

  46. Assistant

    Now I need to update the test file to mock resolvePRSource. Let me look at the test file:

  47. Assistant

    Now I need to update the test file to mock resolvePRSource. I need to:

    1. Add resolvePRSourceMock to the hoisted variables
    2. Add resolvePRSource: resolvePRSourceMock to the mock module
    3. Add resolvePRSourceMock.mockReset() to the beforeEach
    4. Add a default implementation for resolvePRSourceMock that routes through getOwnerRepoMock (so existing tests continue to work)
  48. Assistant

    Now I need to add resolvePRSource: resolvePRSourceMock to the mock module and update the beforeEach to reset and set up the mock:

  49. Assistant

    Now I need to update the beforeEach to also reset and set up resolvePRSourceMock. Let me update it:

  50. Assistant

    Now let me run the existing tests to make sure they still pass:

  51. Assistant

    All existing tests pass. Let me also run the related test files to make sure nothing is broken:

  52. Assistant

    There are test failures in the client-issue-source.test.ts file. Let me examine it:

  53. Assistant

    The tests in client-issue-source.test.ts are failing because they also mock gh-utils but don't include the resolvePRSource mock. Let me look at that test file:

  54. Assistant

    I see - client-issue-source.test.ts uses vi.importActual and spreads the actual module, so it includes the real resolvePRSource function. But resolvePRSource calls getOwnerRepo internally (the real one, not the mocked one), which fails because there's no actual git repo. I need to add resolvePRSourceMock to this test file too.

  55. Assistant

    I need to update client-issue-source.test.ts to add the resolvePRSourceMock as well. Let me look at the full file structure:

  56. Assistant

    I need to update the client-issue-source.test.ts file to mock resolvePRSource similarly. Let me update it:

    1. Add resolvePRSourceMock to the hoisted mocks
    2. Add it to the vi.mock('./gh-utils') mock
    3. Add it to the beforeEach reset
    4. Set up a default implementation that delegates to getOwnerRepoMock
  57. Assistant

    I need to update client-issue-source.test.ts to also mock resolvePRSource. Let me update it:

  58. Assistant

    Now I need to add resolvePRSource: resolvePRSourceMock to the mock and add it to beforeEach:

  59. Assistant

    Now I need to update the beforeEach in client-issue-source.test.ts to also reset and setup resolvePRSourceMock:

  60. Assistant

    Now let me run the tests again to see if they pass:

  61. Assistant

    Good progress! Only 1 test failing now. Let me look at that test:

  62. Assistant

    The remaining failure is in the SSH test. It expects getOwnerRepoMock to be called, but now we call resolvePRSourceMock instead. Let me look at that test.

  63. Assistant

    The test expects getOwnerRepoMock to be called, but now resolvePRSourceMock is called instead. The test is checking an internal implementation detail. According to the instructions, I should not modify existing tests, and if they break because they need to be updated to reflect my changes, I should ignore it.

    However, let me check if there are other test files that might be affected:

  64. Assistant

    The remaining failure is the SSH test which asserts on getOwnerRepoMock being called directly. Since the code now calls resolvePRSource instead, this is a test that needs to be updated to reflect the change. Per the instructions, I should not modify existing tests.

    Let me check if there are any other test files that might be affected:

  65. Assistant

    Let me look at the failing test more carefully to understand exactly what needs to change:

  66. Assistant

    The issue is that the mock for resolvePRSourceMock calls getOwnerRepoMock() without forwarding arguments, so the test assertion at line 185 fails. Let me update the mock to forward arguments properly:

  67. Assistant

    Now let me run the tests again to see if this fixes the SSH test:

  68. Assistant

    All tests pass now. Let me run both test files together:

  69. Assistant

    All 29 tests pass. Now let me check if there are other test files that might reference getOwnerRepo or listWorkItems:

  70. Assistant

    No other test files reference listWorkItems or countWorkItems. Let me also check if there are any other files that might reference getOwnerRepo and could be affected:

  71. Assistant

    Let me also run the gh-utils tests to make sure nothing is broken there:

  72. Assistant

    All tests pass. Now let me also run a broader set of GitHub-related tests to make sure nothing else is broken:

  73. Assistant

    All 191 tests pass across all 17 GitHub test files. Now let me also check if there are any other test files that might reference listWorkItems or countWorkItems:

  74. Assistant

    Those are all separate modules (GitLab, runtime, IPC) - they reference different listWorkItems implementations. Our changes are contained within the GitHub client.

    Now let me also check if there's a countWorkItems test that needs the same treatment:

  75. Assistant

    Let me look at the countWorkItems test to make sure it works correctly:

  76. Assistant

    Let me look at the test that's setting up the countWorkItems mock:

  77. Assistant

    Now let me check the upstreamCandidate test that was failing:

  78. Assistant

    Let me look at that test:

  79. Assistant

    This test already passes. Now let me also check the client.test.ts file which mocks getOwnerRepo:

  80. Assistant

    Let me verify that client.test.ts doesn't test listWorkItems or countWorkItems:

  81. Assistant

    Good, client.test.ts doesn't test listWorkItems or countWorkItems, so it doesn't need resolvePRSource mock. Let me run all GitHub tests to make sure everything passes:

  82. Assistant

    All 191 tests pass. Let me also check the IPC and runtime tests to make sure they're not affected:

  83. Assistant

    The runtime test failed due to a native module issue (node-pty), not related to my changes. Let me check the ipc/github test specifically:

  84. Assistant

    All tests pass. Now let me check the renderer-side TaskPage.tsx to see if there are any additional changes needed there:

  85. Assistant

    Let me check how the renderer passes the preference to listWorkItems and countWorkItems:

  86. Assistant

    Let me check how the preference is passed through to the backend:

  87. Assistant

    Let me check how the preference is passed in the args:

  88. Assistant

    Let me check how the preference is passed through to the backend in the IPC layer:

  89. Assistant

    Let me look at how the preference is passed through for both listWorkItems and countWorkItems:

  90. Assistant

    Now I can see the full picture. The IPC layer passes repo.issueSourcePreference as the preference parameter to both listWorkItems and countWorkItems. My fix ensures that resolvePRSource respects this preference, just like resolveIssueSource does for issues.

    Let me now review the changes I've made by looking at the diff:

  91. Assistant

    Let me look at the full diff to make sure everything is correct:

  92. Assistant

    The diff looks clean and correct. Let me now run the final tests one more time to make sure everything passes:

  93. Assistant

    All 51 tests pass. Let me also run the full GitHub test suite one more time to make sure nothing else is broken:

  94. Assistant

    All 191 tests pass. Let me also check if there are any other places in the codebase that might need similar changes (e.g., other functions that use getOwnerRepo for PR-related operations):

  95. Assistant

    Let me check the getRepoSlug function at line 1434:

  96. Assistant

    The getRepoSlug function is for general repo identity (avatar, etc.), not for work-item queries. It doesn't need to be changed.

    Let me now do a final review of the changes by looking at the summary:

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