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 locate the relevant files mentioned in the issue.

  3. Qwen Assistant

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

  4. Qwen Assistant

    Now I can see the issue. In listWorkItems, the code resolves prOwnerRepo using getOwnerRepo(repoPath, connectionId), which always returns the origin repo. It should respect the preference parameter when it's 'upstream'.

    Let me look at the countWorkItems function:

  5. Qwen Assistant

    Now let me look at the resolveIssueSource function to understand how it works:

  6. Qwen Assistant

    Now I understand the issue. Let me look at the getOwnerRepo function and how it's used:

  7. Qwen Assistant

    Now I understand the problem clearly:

    1. In listWorkItems, the code calls getOwnerRepo(repoPath, connectionId) which always returns the origin remote
    2. But it should respect the preference parameter (like it does for issues via resolveIssueSource)
    3. When the user selects "Upstream" in the PRs tab, the PR queries should use the upstream repo, not origin

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

  8. Qwen Assistant

    Let me look at where the preference is being set and used:

  9. Qwen Assistant

    Now let me look at the test file to understand the expected behavior better:

  10. Qwen Assistant

    Let me look at the test file more closely to understand the structure:

  11. Qwen Assistant

    Now let me check if there are any existing tests that test the upstream preference:

  12. Qwen Assistant

    No existing tests for the 'upstream' preference. Let me also check the type definition for IssueSourcePreference:

  13. Qwen Assistant

    Now I understand the full picture. The issue is:

    1. listWorkItems and countWorkItems both call getOwnerRepo(repoPath, connectionId) to get prOwnerRepo
    2. This always returns the origin repo, ignoring the preference parameter
    3. When the user selects "Upstream", PR queries should use the upstream repo

    The fix should:

    1. Add a function to resolve the PR owner/repo based on the preference (similar to resolveIssueSource)
    2. Use this new function in listWorkItems and countWorkItems

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

  14. Qwen Assistant

    Good. Now let me look at the full context of the functions I need to modify:

  15. Qwen Assistant

    Now, let me look at how resolveIssueSource is exported from gh-utils and what I need to do:

  16. Qwen Assistant

    Looking at the code, I need to create a similar function to resolveIssueSource for PRs, or simply reuse the existing logic. Let me examine the logic more carefully:

    For issues:

    • resolveIssueSource(repoPath, preference, connectionId) respects the preference

    For PRs:

    • Current code: getOwnerRepo(repoPath, connectionId) which always returns origin
    • Should be: Use upstream when preference is 'upstream', origin otherwise

    The simplest fix is to create a resolvePRSource function in gh-utils.ts (similar to resolveIssueSource) and use it in client.ts. However, looking at the code more carefully, I see that the resolveIssueSource already handles this logic. Let me think about whether we can reuse it.

    Looking at resolveIssueSource:

    • If preference is 'upstream', it returns upstream (or falls back to origin)
    • If preference is 'origin', it returns origin
    • If preference is 'auto' or undefined, it calls getIssueOwnerRepo which prefers upstream

    For PRs, the behavior should be different. When the user selects "Upstream" in the PR source selector, PR queries should use the upstream repo. But the default behavior (auto/undefined) should still use origin for PRs (since PRs are typically in the fork/origin).

    Let me look at the UI to understand better:

  17. Qwen Assistant

    Now I understand. The selector uses s.sources.prs as the origin and s.sources.upstreamCandidate as upstream. When the user changes the preference, it calls setIssueSourcePreference which affects both issues and PRs.

    So the fix is straightforward: the PR source should also respect the preference. Let me create a resolvePRSource function that works similarly to resolveIssueSource but with different defaults:

  18. Qwen Assistant

    Looking at this more carefully, I realize that for PRs, the logic should be:

    • When preference is 'upstream': use upstream
    • When preference is 'origin': use origin
    • When preference is 'auto' or undefined: use origin (since PRs are typically in the fork)

    The key insight is that resolveIssueSource already does what we need for the 'upstream' and 'origin' cases. The difference is in the 'auto' case:

    • For issues: getIssueOwnerRepo (prefers upstream if it exists)
    • For PRs: getOwnerRepo (always origin)

    So I need to create a resolvePRSource function that uses the same logic but defaults to origin instead of upstream. Let me add this function to gh-utils.ts:

  19. Qwen Assistant

    Now I'll add the resolvePRSource function to gh-utils.ts after the resolveIssueSource function:

  20. Qwen Assistant

    Now I need to export this function from gh-utils and import it in client.ts. Let me first check the imports in client.ts:

  21. Qwen Assistant

    Now let me add the import for resolvePRSource:

  22. Qwen Assistant

    Let me verify the import was added correctly:

  23. Qwen Assistant

    Good! Now let me update the listWorkItems function to use resolvePRSource instead of getOwnerRepo:

  24. Qwen Assistant

    Now I need to replace getOwnerRepo(repoPath, connectionId) with a call to resolvePRSource and extract its source:

  25. Qwen Assistant

    Now I need to add the line that extracts prOwnerRepo from prResolved. Let me check the current state:

  26. Qwen Assistant

    Good. Now I need to add const prOwnerRepo = prResolved.source after const issueOwnerRepo = issueResolved.source:

  27. Qwen Assistant

    Let me verify the changes:

  28. Qwen Assistant

    Now I need to do the same for the countWorkItems function. Let me check its current state:

  29. Qwen Assistant

    I see there's a problem - the sed command I ran earlier replaced getOwnerRepo(repoPath, connectionId) globally, but there was already a const prOwnerRepo variable assignment in countWorkItems, and now it has a duplicate line with prResolved which doesn't exist in that function's scope. Let me fix this properly.

  30. Qwen Assistant

    I need to fix the countWorkItems function. Let me first restore the file and make more targeted changes:

  31. Qwen Assistant

    Let me continue reviewing the git diff to understand what changes have been made and what still needs to be fixed.

  32. Qwen Assistant

    Looking at the diff, I see there are issues with the changes to countWorkItems and getWorkItem. The countWorkItems function's Promise.all still uses getOwnerRepo but references prResolved which doesn't exist. Let me fix this properly.

  33. Qwen Assistant

    I see the problem. The countWorkItems function still has getOwnerRepo(repoPath, connectionId) in the Promise.all, but my earlier sed added a duplicate const prOwnerRepo = prResolved.source line that references a non-existent prResolved variable. Let me fix this:

  34. Qwen Assistant

    I need to fix the countWorkItems function. The Promise.all still uses getOwnerRepo but should use resolvePRSource. Let me fix this:

  35. Qwen Assistant

    Good, the countWorkItems function is now fixed. Now let me check the getWorkItem function that was also modified by the earlier sed commands. Looking at the diff, I see that getWorkItem was changed to use resolvePRSource but it returns a ResolvedIssueSource object, not just an OwnerRepo. Let me check the current state of that function.

  36. Qwen Assistant

    The getWorkItem function is now calling resolvePRSource but that returns a ResolvedIssueSource object { source, fellBack }, not an OwnerRepo. I need to extract .source from it. Let me fix this.

  37. Qwen Assistant

    Now let me verify the changes look correct:

  38. Qwen Assistant

    Good! The diff looks correct. Now let me verify the gh-utils.ts changes:

  39. Qwen Assistant

    Good! The changes look correct. Now let me run the existing tests to make sure I haven't broken anything. Let me first check if there are any tests related to work items.

  40. Qwen Assistant

    The test is timing out during setup (installing pnpm and rebuilding native deps). Let me try a different approach - I'll check if vitest is available directly or try to run tests with a timeout configuration.

    Let me try running the test more directly or checking if there's a way to skip the native runtime setup.

  41. Qwen Assistant

    Let me try running vitest without the timeout option and see if I can get the tests to run. I'll also need to bypass the native runtime check that's causing issues.

  42. Qwen Assistant

    The tests are failing because the test file's mock for ./gh-utils doesn't include the new resolvePRSource function. I need to add it to the mock setup. Let me examine the test file and update it.

  43. Qwen Assistant

    I need to add the resolvePRSource mock to the test file. Let me update it:

  44. Qwen Assistant

    I see the issue - the edit command duplicated the content. The file now has duplicate lines. I need to fix this by restoring the original file and making a cleaner edit. Let me restore the test file first and then make the changes more carefully.

  45. Qwen Assistant

    Now let me make the changes more carefully using replace commands:

  46. Qwen Assistant

    The replace command is having trouble with the multi-line syntax. Let me use the << 'EOF' syntax instead for the multi-line replacement.

  47. Qwen Assistant

    Let me try a different approach using sed:

  48. Qwen Assistant

    Now I need to add it to the vi.mock call:

  49. Qwen Assistant

    Now I need to add the mock setup in beforeEach:

  50. Qwen Assistant

    Now I need to add the mock implementation for resolvePRSourceMock that mirrors getOwnerRepoMock (since for PRs, the default is origin):

  51. Qwen Assistant

    Now let me verify the changes look correct:

  52. Qwen Assistant

    I see there's an error in the vi.mock section - there's an extra line resolvePRSourceMock, that shouldn't be there. Let me fix this:

  53. Qwen Assistant

    Let me verify the mock section now looks correct:

  54. Qwen Assistant

    I need to verify the test file changes are correct and run the tests. Let me check the current state:

  55. Qwen Assistant

    Good, the mock setup looks correct. Let me run the tests again to see if they pass now:

  56. Qwen Assistant

    The error says resolvePRSourceMock is not defined at line 46. This is because vi.mock is hoisted to the top of the file, but resolvePRSourceMock is defined in the vi.hoisted block. The issue is that I added resolvePRSource: resolvePRSourceMock, to the mock object, but resolvePRSourceMock is extracted from vi.hoisted() and available at the module scope, so it should work.

    Let me check line 46 in the test file to see what's there.

  57. Qwen Assistant

    I see the issue. Line 46 is where resolvePRSource: resolvePRSourceMock, is defined. The problem is that vi.mock is hoisted to the top of the file, but the vi.hoisted block is also hoisted. The resolvePRSourceMock variable should be available since it's extracted from vi.hoisted().

    Let me look at how the file is structured to understand the hoisting better:

  58. Qwen Assistant

    I see the problem! The destructuring on the left side of vi.hoisted() does NOT include resolvePRSourceMock. Let me fix that:

  59. Qwen Assistant

    I see the problem - resolvePRSourceMock is missing from the destructuring pattern on the left side. Let me fix that:

  60. Qwen Assistant

    Good, the sed command succeeded. Now let me verify the fix is correct by checking the destructuring pattern.

  61. Qwen Assistant

    Now the destructuring is correct. Let me run the tests again:

  62. Qwen Assistant

    All 12 tests passed. Let me also check if there are any other tests that might be affected by these changes:

  63. Qwen Assistant

    All tests pass! Now let me verify the changes are complete by reviewing all the files I modified.

  64. Qwen Assistant

    Good. Let me review all the changes I made:

  65. Qwen Assistant

    The user is reminding me that I need to use tool calls properly. Let me continue checking the git diff for the client.ts file to verify my changes are correct.

  66. Qwen Assistant

    Let me also verify the test file changes and then run all related tests to ensure everything works correctly.

  67. Qwen Assistant

    I notice there's a duplicate resolvePRSourceMock, line in the vi.mock section. Let me check and fix that, then run the tests again to confirm everything works.

  68. Qwen Assistant

    I see there's still a duplicate resolvePRSourceMock, line on line 47. Let me remove it.

  69. Qwen Assistant

    The user hasn't said anything, so I need to continue with my work. I was in the middle of fixing the test file and removing a duplicate line. Let me verify the fix worked and then run the tests again to make sure everything is correct.

  70. Qwen Assistant

    The duplicate line has been removed. Now I should run the tests again to make sure everything still passes, and then check if there are any other related tests that might be affected by my changes.

  71. Qwen Assistant

    All 12 tests pass. Now let me check the final state of the changes and make sure everything is correct. I should also run any other related tests to make sure I haven't broken anything.

  72. Qwen Assistant

    All tests pass. Let me verify the final state of all changes and make sure everything is correct before submitting.

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