Resolve PR repo via `gh repo view` so fork clones target upstream (#261)
* Resolve PR repo via `gh repo view` so fork clones target upstream (#255)
`GitClient.remoteInfo` preferred the `origin` remote, so in fork
workflows Supacode queried the fork instead of the upstream repo
that actually hosts the PR. The worktree badge/CI ring never lit up
and `Merge PR` / `Close PR` / `Mark ready for review` from the command
palette ran `gh pr …` against the fork, where the PR does not exist.
- `GithubCLIClient.resolveRemoteInfo` shells `gh repo view --json
owner,name,url` in `repoRoot` and reuses `gh`'s own default-repo
resolution. The reducer prefers this result and only falls back to
`gitClient.remoteInfo` when `gh` is unavailable.
- `mergePullRequest` / `closePullRequest` / `markPullRequestReady`
now take the resolved `GithubRemoteInfo` and pass `--repo
HOST/OWNER/REPO`, so mutations run against the repository the
refresh pipeline just queried.
- CI/workflow calls (`gh run list`, rerun failed jobs, view run
logs) still target `repoRoot` — workflow runs live on the remote
that received the push, which in fork workflows is the fork.
* Include merged PRs from deleted forks in branch resolution
`pullRequestsByBranch` excluded every node with `headRepository:
null`, which GitHub returns when the PR's source fork has been
deleted — a routine outcome after a fork PR is merged and the
author removes their fork. The local branch still matches the
PR's `headRefName`, so Supacode should surface it.
Tier the candidates instead of the previous two-bucket split:
1. upstream PRs (head repo == queried repo),
2. fork PRs with an intact `headRepository` and
`baseRefName != branch` (guards against "user:main → main"),
3. deleted-fork PRs (`headRepository == nil`, same
`baseRefName` guard) — only consulted when tiers 1 and 2 are
empty so we never prefer a stub over a PR with verifiable
provenance.
The existing `skipsNilHeadRepositoryInForkFallback` still passes
because the intact-fork node lands in tier 2 and wins. New
`includesMergedPRWithDeletedForkHead` covers the regression this
uncovered (observed on PR #248 in `supabitapp/supacode`).
authored by