Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· 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. GLM Assistant

    I'll start by exploring the repository structure and understanding the codebase, then reproduce the issue.

  3. GLM Assistant

    Let me run one command at a time.

  4. GLM Assistant

    Let me look at the listWorkItems and countWorkItems functions in detail.

  5. GLM Assistant

    Now let me look at the gh-utils.ts to understand resolveIssueSource, resolvePRRepositoryCandidates, getOwnerRepo, and getOwnerRepoForRemote.

  6. GLM Assistant

    Now let me look at the types involved.

  7. GLM Assistant

    Let me look at the existing tests for these functions.

  8. GLM Assistant

    Let me look at the client-issue-source.test.ts file to understand how the preference is tested.

  9. GLM Assistant

    Now let me look at the TaskPage.tsx and the source selector to understand the renderer side.

  10. GLM Assistant

    Let me look at the hasUpstreamCandidateDivergence and hasDivergentSources functions and the broader context.

  11. GLM Assistant

    Let me look at the second selector usage around line 9680-9720.

  12. GLM Assistant

    Let me look at the IssueSourceSelector component.

  13. GLM Assistant

    Let me search for all usages of sources.prs and .prs in the renderer and store.

  14. GLM Assistant

    Let me narrow the search for sources.prs usage specifically.

  15. GLM Assistant

    Let me look at how sources.prs is used in display logic (lines 4440-4460, 4750-4760, 2950-2975).

  16. GLM Assistant

    Let me look at the listRecentWorkItems and listQueriedWorkItems functions and the SSH assertion logic.

  17. GLM Assistant

    Let me look at the usages around lines 2950-2980 and 4745-4765.

  18. GLM Assistant

    Line 2971-2972: prSlug is used in the "fell back to origin" toast. This toast only shows when issueSourceFellBack is true (preference=upstream but no upstream remote → fell back to origin). In that case, PRs are also from origin (fallback). So sources.prs = origin = the repo we fell back to. The toast says "Using origin" with the origin slug. ✓. Correct.

    So this usage is fine with sources.prs = origin.

    Now line 4754.

  19. GLM Assistant

    Let me check how primaryGithubFilterSlug is used.

  20. GLM Assistant

    primaryGithubFilterSlug is passed to PRFilterDropdowns as primarySlug. Let me check what PRFilterDropdowns does with primarySlug.

  21. GLM Assistant

    Let me look at buildWorkItemListArgs and the work-item list args builder.

  22. GLM Assistant

    Let me check how tests are run in this repo.

  23. GLM Assistant

    Let me create a temporary reproduction test to confirm the bug.

  24. GLM Assistant

    I've reproduced the bug. Now let me check the renderer tests to understand the impact before deciding on the scope.

  25. GLM Assistant

    Let me look at the store test around line 3620-3660.

  26. GLM Assistant

    Let me check for renderer tests asserting the filter dropdown / external link behavior.

  27. GLM Assistant

    No tests directly assert primaryGithubFilterSlug or selectedGitHubRepoExternalLink. So renderer changes there would be low-risk for tests. But there might be component tests for PRFilterDropdowns. Let me check.

    Actually, the grep showed PRFilterDropdowns.tsx and PRFilterPickers.tsx but no test files for them. Let me confirm there are no test files referencing these.

    The grep for tests/ returned nothing (only src/renderer files). So no tests for these components. Good.

    But wait, there might be TaskPage tests. Let me check if there's a TaskPage.test.tsx.

  28. GLM Assistant

    Let me verify parseTaskQuery handles is:pr is:open author:@me as expected.

  29. GLM Assistant

    Now I understand the code. Let me implement the backend fix. First, let me open the listWorkItems function.

  30. GLM Assistant

    Now let me implement the fix in listWorkItems. I'll resolve the PR query target based on the preference while keeping sources.prs as the origin repo (which the renderer's selector relies on for its Origin pill).

  31. GLM Assistant

    The edit left duplicate lines (1255-1257). Let me remove them.

  32. GLM Assistant

    The listWorkItems fix looks good. Now let me update countWorkItems.

  33. GLM Assistant

    There's a stray } and I accidentally removed the if (!ownerRepo) null check. Let me fix that.

  34. GLM Assistant

    Both functions are updated. Now let me run my reproduction test to confirm the fix.

  35. GLM Assistant

    My reproduction tests now pass. Let me run the existing GitHub client tests to make sure I didn't break anything.

  36. GLM Assistant

    All existing tests pass. Let me run the broader GitHub-related test suite to be safe.

  37. GLM Assistant

    All 193 GitHub tests pass. Let me also run the IPC and runtime tests that call these functions.

  38. GLM Assistant

    The runtime/github.test.ts failure is a pre-existing environment issue (missing native pty.node module at load time, 0 tests collected) — unrelated to my TypeScript change. Let me verify getWorkItem (PR detail lookup used when clicking a PR) to see if it also needs the preference, since the PRs tab would use it.

  39. GLM Assistant

    getWorkItem doesn't take a preference parameter (out of scope, and the work items returned by listWorkItems carry their own prRepo). Let me verify that mapPullRequestWorkItem sets prRepo from the resolved owner repo, so PR detail lookups follow correctly.

  40. GLM Assistant

    mapPullRequestWorkItem sets prRepo from the resolved prOwnerRepo, so PR detail/checks/merge operations (which use the work item's prRepo) correctly target upstream. The fix is complete and consistent with the issue's scope (PR list/count queries, no new interfaces).

    Let me run the typecheck to ensure no type errors.

  41. GLM Assistant

    Typecheck passes. Let me run the linter on the changed file.

  42. GLM Assistant

    All checks pass. Now let me clean up my temporary reproduction test file (per the instructions, I shouldn't add tests to the repo).

  43. GLM Assistant

    Let me verify how the preference is threaded from the renderer/store to listWorkItems/countWorkItems to ensure the fix is reachable end-to-end.

  44. GLM Assistant

    Let me check how args (including the preference) is constructed when calling these functions.

  45. GLM Assistant

    GitHubWorkItemsListArgs doesn't include preference. Let me look at the callers around lines 1930-1960 and 2089-2110 to see how the preference reaches the IPC.

  46. GLM Assistant

    The preference isn't passed via args. Let me check the IPC layer to see how the preference reaches the main process.

  47. GLM Assistant

    The IPC layer threads repo.issueSourcePreference to both listWorkItems and countWorkItems (and even listLabels). So my fix is reachable end-to-end.

    Now let me check the perRepoSourceState to see if the preference is available there (relevant to the filter-dropdown slug which uses sources.prs).

  48. GLM Assistant

    The IPC layer threads repo.issueSourcePreference to both functions, so the fix is reachable end-to-end. My change preserves all existing behavior in auto/origin modes and only routes PR queries to upstream when preference === 'upstream' and an upstream remote exists.

    Let me run a final comprehensive check on the affected test areas (excluding the native-module-broken runtime test) and verify the diff.

  49. GLM Assistant

    All 330 tests pass. Let me confirm the runtime/github.test.ts failure is a pre-existing environmental issue (native pty.node module not built) by checking it against a clean checkout via git stash.

  50. GLM Assistant

    Confirmed — the runtime/github.test.ts failure is pre-existing (fails on a clean checkout too, due to the missing native pty.node binary in this environment). It's unrelated to my change.

    Let me review my final diff.

  51. GLM Assistant

    The diff is clean and correct. Let me do a final review of both modified functions to confirm correctness.

  52. GLM Assistant

    Both functions look correct. Let me verify countWorkItems once more.

  53. GLM Assistant

    Both functions are correct. Let me run one final temporary verification covering the recent (no-query) list path and the default count path with upstream, to be thorough, then remove it.

  54. GLM Assistant

    All verification scenarios pass (recent list, default count, and no-regression for auto mode). The temporary test is removed. Let me confirm the final git status shows only the intended change.

  55. GLM Assistant

    The change is clean — only src/main/github/client.ts is modified, with all temporary test files removed.

    Let me run the checklist review:

    Checklist review:

    • [✓] Reproduced the error: I wrote a temporary test confirming that with preference='upstream', PR list queries used --repo fork/orca (origin) and count queries used repo:fork/orca instead of the upstream stablyai/orca.

    • [✓] Confirmed the fix resolves the error: After the fix, the same scenarios route PR list (--repo stablyai/orca), PR count (repo:stablyai/orca), recent list, and default count queries to the upstream repo. I also verified auto mode keeps PRs on origin (no regression).

    • [✓] Thought about edge cases:

      • upstream + upstream remote exists → PRs target upstream ✓
      • upstream + no upstream remote → falls back to origin (mirrors resolveIssueSource, issueSourceFellBack still set) ✓
      • origin / auto / undefined → PRs stay on origin (unchanged) ✓
      • origin == upstream (non-fork) → no behavior change ✓
      • SSH repos → upstreamCandidate resolved with connectionId; the SSH source assertion uses the resolved prOwnerRepo ✓
      • countWorkItems' sameOwnerRepo gate: upstream mode collapses to a single combined query; auto mode still splits ✓
      • PR work items carry prRepo = resolved upstream, so PR detail/checks/merge ops follow ✓
      • sources.prs kept as origin so the renderer's selector (Origin pill + render gate) keeps working after picking Upstream ✓
    • [✓] Ran existing affected tests: src/main/github/ (193), ipc/github.test.ts, store/slices/github.test.ts (90), web-preload-api.test.ts (34) — all 330 pass. Typecheck (tsgo) and lint (oxlint) pass. The only failing suite (runtime/rpc/methods/github.test.ts) fails on a clean checkout too due to a missing native pty.node binary — unrelated to this change.

    The fix is minimal, backend-only (no new interfaces, matching the issue's scope), and directly addresses the root cause: listWorkItems/countWorkItems now resolve the PR query target from the selected source preference instead of always using origin.

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