What happened?
A clean worktree checked out on the repository's default branch (main) displays a merged pull request badge (PR #320 "Main", merged) as if that PR belonged to the worktree.
I expected a worktree on the default branch with no pending changes to show just the branch (default), with no PR attached.
This affects any workflow that opens sync PRs from the default branch into another branch (e.g. main → dev), because those PRs have headRefName: main and never go away for the default branch (the branch persists after merge instead of being deleted like a feature branch).
Steps to reproduce
- Use a repo whose default branch is
main, with a workflow that opens sync PRs from main into another branch (e.g. main → dev), so main has merged PRs whose headRefName is main.
- Open the repo in Supacode with the main worktree checked out on
main, clean, with no local changes.
- Observe the main worktree shows a merged PR badge (the most recently updated merged
head=main PR) instead of no PR.
Cause (from the source)
Tracing the PR auto-matching:
GithubCLIClient.makeBatchPullRequestsQuery fetches, per branch, pullRequests(first: 5, states: [OPEN, MERGED], headRefName: "<branch>", orderBy: {field: UPDATED_AT, direction: DESC}).
- For the default branch this matches historical
default → X sync PRs (they use the default branch as the head).
GithubGraphQLPullRequestResponse.pullRequestsByBranch ranks candidates by state (OPEN > MERGED) then recency, so with no open head=main PR it selects the newest merged one.
RepositoriesFeature.refreshRepositoryPullRequests then assigns it to the worktree via pullRequestsByWorktreeID[worktree.id] = prsByBranch[worktree.name].
The matcher never special-cases the repository's default branch, so a worktree on the default branch permanently shows a stale merged PR.
A possible direction (happy to implement once triaged): exclude the repository's default branch from PR association in refreshRepositoryPullRequests. One open question for triage — suppress all PRs on the default branch, or only merged/closed ones (keeping a currently-open sync PR visible)?
Supacode version and build
0.10.6 (1783877721)
macOS version
macOS 26.5
System locale
en_IL
Mac hardware
Apple M1 (MacBookPro17,1)
Disclosure: diagnosis assisted by an AI agent (Claude Code). All commits for any follow-up PR will be authored by me.
What happened?
A clean worktree checked out on the repository's default branch (
main) displays a merged pull request badge (PR #320 "Main", merged) as if that PR belonged to the worktree.I expected a worktree on the default branch with no pending changes to show just the branch (default), with no PR attached.
This affects any workflow that opens sync PRs from the default branch into another branch (e.g.
main → dev), because those PRs haveheadRefName: mainand never go away for the default branch (the branch persists after merge instead of being deleted like a feature branch).Steps to reproduce
main, with a workflow that opens sync PRs frommaininto another branch (e.g.main → dev), somainhas merged PRs whoseheadRefNameismain.main, clean, with no local changes.head=mainPR) instead of no PR.Cause (from the source)
Tracing the PR auto-matching:
GithubCLIClient.makeBatchPullRequestsQueryfetches, per branch,pullRequests(first: 5, states: [OPEN, MERGED], headRefName: "<branch>", orderBy: {field: UPDATED_AT, direction: DESC}).default → Xsync PRs (they use the default branch as the head).GithubGraphQLPullRequestResponse.pullRequestsByBranchranks candidates by state (OPEN > MERGED) then recency, so with no openhead=mainPR it selects the newest merged one.RepositoriesFeature.refreshRepositoryPullRequeststhen assigns it to the worktree viapullRequestsByWorktreeID[worktree.id] = prsByBranch[worktree.name].The matcher never special-cases the repository's default branch, so a worktree on the default branch permanently shows a stale merged PR.
A possible direction (happy to implement once triaged): exclude the repository's default branch from PR association in
refreshRepositoryPullRequests. One open question for triage — suppress all PRs on the default branch, or only merged/closed ones (keeping a currently-open sync PR visible)?Supacode version and build
0.10.6 (1783877721)
macOS version
macOS 26.5
System locale
en_IL
Mac hardware
Apple M1 (MacBookPro17,1)
Disclosure: diagnosis assisted by an AI agent (Claude Code). All commits for any follow-up PR will be authored by me.