[FEATURE] PR list diff stats should use each PR's actual base, not main

Resolved 💬 1 comment Opened May 21, 2026 by sarahmaas Closed Jun 21, 2026

Problem Statement

In the PR list view (the stacked PR rows shown in the Claude Code UI), each row shows a diff stat like +3,827 −2. The number is computed against main (the repo's default branch), not against each PR's actual base. In a stack of related PRs the numbers become identical or otherwise misleading:

| PR | Branch | Shown diff |
|--------|---------------------|--------------|
| #31361 | PROJECT-68525-... | +3,827 −2 |
| #31335 | PROJECT-68523-... | Merged |
| #31342 | PROJECT-68524-... | +4,457 −5 |
| #31362 | PROJECT-68174-... | +3,827 −2 |

#31361 and #31362 are on completely different branches with different contents, but show identical totals because both are being measured against main. The diff stat appears next to a PR row, so users read it as "the diff of this PR" — but it's actually the cumulative delta from the branch head all the way back to main, which for a stacked PR includes every parent PR's changes too.

Proposed Solution

For open PRs specifically, the base is not ambiguous — GitHub stores it on the PR object. The fix is cheap:

  • Use gh pr view <num> --json baseRefName,additions,deletions (or the equivalent API call) and show the additions/deletions GitHub already computed against the declared base.
  • Stacks then render correctly because each PR's base is its parent branch.

This is narrower than #51738 (which is about the branch status badge and argues for commit-centric info generally). Both would be welcome — but even without rethinking the metric, computing it against the right base for open PRs would fix the most egregious error.

Alternative Solutions

None currently — the displayed number is the only signal in that row.

Use Case Example

  1. Open Claude Code in a repo with a stack of related PRs (e.g. a 4-PR stack).
  2. Bring up the PR list view.
  3. Observe that PRs on totally different branches show identical diff numbers, and that each PR's number includes its parents' changes.
  4. With this fix, each row would show that PR's own contribution against its declared base.

Additional Context

This suggestion is GitHub-specific. A fully general fix would need equivalent base-ref lookups for GitLab, Bitbucket, etc. — out of scope for this issue but worth flagging.

Related: #51738 — branch status badge shows diff-vs-base line count instead of branch content.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗