Skip to content

fix(pr-poller): detect cross-fork PRs via SHA search - #68

Merged
frenchie4111 merged 3 commits into
ness-dev:mainfrom
big-guy:more-missing-upstream-prs
May 25, 2026
Merged

fix(pr-poller): detect cross-fork PRs via SHA search#68
frenchie4111 merged 3 commits into
ness-dev:mainfrom
big-guy:more-missing-upstream-prs

Conversation

@big-guy

@big-guy big-guy commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Swaps the SHA-fallback alias in the batched GraphQL PR fetch from object(oid).associatedPullRequests to search(query:"type:pr repo:o/n <sha>", type:ISSUE).
  • associatedPullRequests against the upstream repo is empty for cross-fork PRs (the link only exists on the head fork's side, and we can't enumerate forks), so worktrees tracking commits whose PR lives on a fork — e.g. gradle/gradle PR #32046 from MattAlp/gradle — were silently failing to resolve.
  • GitHub's search index includes PR commit SHAs and finds the right PR from the upstream side in a single call. The same query also handles gh pr checkout-style synthetic local branch names whose name doesn't match the PR's head.ref.

Test plan

  • npx vitest run — 1168 tests pass, including new cross-fork and non-PR-issue-filter cases
  • In a worktree tracking a cross-fork PR (e.g. gradle/gradle PR #32046), confirm the PR status pane now shows the PR

🤖 Generated with Claude Code

@frenchie4111

Copy link
Copy Markdown
Collaborator

Is this related to #69 that I just found?

@big-guy

big-guy commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

It might, I'll look

big-guy and others added 3 commits May 23, 2026 00:58
associatedPullRequests against the upstream repo returns empty for
cross-fork PRs — the link between commit and PR only exists on the head
fork's side, and we can't know which of potentially thousands of forks
to query. GitHub's search index, however, includes PR commit SHAs and
returns the right PR with a single upstream call. Swap the alias for
search(query:\"type:pr repo:o/n <sha>\") so both cross-fork PRs and
synthetic-local-branch cases (gh pr checkout style) resolve in the
same single-round-trip GraphQL request.

Adds a test for the gradle #32046 cross-fork scenario plus filtering
of non-PR Issue nodes from search results.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A worktree sitting on main/master was being credited with the
most-recently-squashed PR's status. Root cause: the SHA-based search
fallback indexes the squash commit's SHA against the merged PR, so
search(query: \"... <main-HEAD-sha>\") returns the just-merged PR; that
PR's headRefOid is the original feature branch, not main's HEAD, so the
exact-SHA check missed but the old same-origin fallback then claimed it.

Two complementary guards:

* Skip the per-request resolution entirely when the worktree's branch
  equals the repository's default branch (from defaultBranchRef.name).
* Tighten resolvePRForWorktree so search-alias nodes require an exact
  SHA match — search results are too loose to trust via same-origin
  fallback the way branch-name nodes are.

Tests cover the main and master cases, plus a regression test that the
SHA-matched search hit still wins when branch-name returns a different
PR (the existing fork-disambiguation behavior).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tive

Extends the default-branch guard to any branch a PR is currently
targeting (develop, integration, release/*, …). After resolving PRs we
collect the union of baseBranch values; any worktree sitting on one of
those branches gets its PR assignment cleared. Self-derives — no config
or hardcoded list — and free, since every PR node already carries
baseRefName.

Renderer mirror: the no-PR / Active sidebar group now sorts merge-point
worktrees (main + any branch that's a PR base) immediately after the
main worktree, before feature worktrees, so the long-lived merge points
stay reachable at the top.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@big-guy
big-guy force-pushed the more-missing-upstream-prs branch from 6d164eb to 337c9aa Compare May 23, 2026 05:12
@big-guy

big-guy commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

@frenchie4111 give this a look and see if it fixes what you were seeing.

@frenchie4111
frenchie4111 merged commit 16b1264 into ness-dev:main May 25, 2026
1 check passed
@big-guy
big-guy deleted the more-missing-upstream-prs branch May 26, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants