Repository navigation
fix(server): Changes counts only a fork branch's own work - #15
Merged
Merged
Conversation
The thread panel's Changes row showed +2,381 -1,165 for a branch whose
diff was +58 -63. The base name ("main") was only ever looked up on the
primary remote or as a local branch, so a branch cut from fork/main was
diffed against origin/main and counted every commit the fork has that
upstream lacks. Even gh-merge-base=fork/main resolved to origin/main.
The base name is chosen as before. When the remote the local base
branch tracks also has it, as with a local main that follows a fork,
Changes uses whichever of the two copies the branch was cut from: the
one that leaves the fewest of its commits outside. Remotes fetched only
for someone else's pull request are never compared, and the local
branch still wins when the primary remote lacks the name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The thread panel's Changes row showed +2,381 −1,165 for #14, whose diff is +58 −63. The base name (
main) was only ever looked up on the primary remote or as a local branch. So a branch cut fromfork/mainwas diffed againstorigin/mainand counted the fork's 13 commits that upstream doesn't have. Evengh-merge-base=fork/mainresolved toorigin/main.Summary
resolveBaseBranchForNoUpstream(apps/server/src/vcs/GitVcsDriverCore.ts) feeds the Changes row, the diff panel's Changes view, and the ahead count:origin/mainorigin/main, plus one cheapfor-each-refmaintracksfork/main, branch cut fromfork/mainorigin/main✗fork/mainorigin/mainorigin/mainorigin/mainmainitselforigin/main✗fork/mainmainorigin/mainorigin/main: the author's remote is never comparedOnly the remote the local base branch tracks counts. The push remote is excluded: in the common contributor setup (main tracks
origin, pushes to a fork), counting it would leave Changes onmainwith no committed work after a push.Evidence
Before: T3's real code on the PR fix(server): one runaway agent no longer freezes every agent #14 history, with
origin/mainandfork/mainas they were in the screenshot:After:
Before:
counts Changes from the copy of main a branch was cut fromfails on the old code:An earlier version of this fix compared every remote.
never counts Changes from a pull request author's copy of mainfails on that version with{ baseRef: 'author/main', insertions: 0 }.After: both pass.
GitVcsDriverCore.test.tspasses 156/156 andVcsStatusBroadcaster.test.ts27/27. The server typecheck, lint and format are clean.GitManager.test.ts: passed 143/143 in most runs. Two tests with tight timeouts ("stops probing head selectors…" at 12 s, "does not reuse a cross-repo PR…" at 20 s) failed once while the Proxmox host's load average was about 300. In an A/B run under that load, the unchanged code also took 22.3 s on the first one, and the fix took 1.3–2.6 s.Merge Danger
Door: two-way
Read-only base selection. It changes no stored state, so reverting restores the old numbers on the next status refresh.
Blast Radius: multi-remote
Repos with one remote get the same base as before. Repos whose local base branch tracks a second remote can get a different base in three places:
aheadCount/aheadOfDefaultCount, which gate the Create PR buttonKnown limit: a fork
mainthat already merged the branch through a merge commit has none of the branch's commits outside it, so it wins and Changes shows only uncommitted work. The old code does the same onorigin. This fork squash-merges.Not changed here: new worktrees start from the primary remote's default branch, and PR creation picks its base in
GitManager.resolveBaseBranch.Model and harness: Claude Opus 5.5 in Claude Code via T3 Code.
🤖 Generated with Claude Code