Repository navigation
Description
Summary
In a project checkout, a thread on a new branch made from dev (default branch main) shows the commits dev has beyond main as its own changes, and main as its merge branch. The environment records no merge base, so bb falls back to the default branch. Before #3227, the server recorded the new branch's base as the merge base.
Versions and environment
- bb 0.46.1 (latest release). The host daemon runs on Debian 13 (Linux 6.12) with git 2.55.0.
- Also reproduced from source at
maine0f6fda, in the integration harness on macOS (Node 22.23.2). No commit has touched the code below since 0.46.1. - Project checkout environment provider, nothing else unusual.
Steps to reproduce
R=$(mktemp -d) && cd "$R"
git init -q --bare -b main origin.git
git init -q -b main seed
git -C seed commit -q --allow-empty -m "on main"
git -C seed push -q ../origin.git main
git -C seed switch -q -c dev
echo dev-only > seed/dev.txt && git -C seed add dev.txt && git -C seed commit -q -m "on dev only"
git -C seed push -q ../origin.git dev
git clone -q origin.git clone
bb thread spawn --project <any project on that machine> --host <machine> \
--environment-provider project-checkout \
--environment-inputs "{\"path\":\"$R/clone\",\"branch\":{\"kind\":\"new\",\"baseBranch\":\"origin/dev\"}}" \
--prompt "Reply with exactly: OK. Run no command, read no file."
bb environment show <environment> --jsonThe same steps run as an integration test in the linked PR (tests/integration/fake/environments/project-checkout-branches.test.ts).
Expected vs actual
Actual: bb environment show --json reports "baseBranch": null, "defaultBranch": "main", "mergeBaseBranch": null, while the thread's branch sits on origin/dev:
71e57ea (HEAD -> bb/claude-repro-a-merge-base-to-archive-thr_bz52jkjmfy, origin/dev) on dev only
d9097ca (origin/main, origin/HEAD, main) on main
resolveEnvironmentMergeBaseBranch then picks main, and the diff lists a file the thread never touched. In that checkout:
$ git diff --name-only main...HEAD
dev.txt
$ git diff --name-only origin/dev...HEAD
$
The integration test, reading the diff through GET /environments/:id/diff as the app does, fails at e0f6fda with:
AssertionError: expected 'A\tdev.txt\n' to be '' // Object.is equality
Expected: mergeBaseBranch is the ref the branch was made from (origin/dev), so the untouched thread's diff is empty.
Evidence
- The provider's result carries no
mergeBaseBranch: server.ts#L196-L201. - The engine stores what the provider reports, or null: environment-engine.ts#L510.
- With none, the merge base falls back to the default branch: environment.ts#L139-L147.
- The worktree provider reports the base its host made the branch from: host.ts#L115, server.ts#L160-L164.
- Before Environment providers: plugins own where threads run #3227, an unmanaged checkout on a new branch got
mergeBaseBranch: command.checkout.baseBranch: environment-provisioning-internal.ts#L466-L488 at Environment providers: plugins own where threads run #3227's parent. Environment providers: plugins own where threads run #3227 removed that function, and its description does not mention dropping the merge base. - Thread
thr_bz52jkjmfy, environmentenv_86xpa32cns, archived after the repro.
What you ruled out
- Not a duplicate: I searched issues and PRs for "merge base", "mergeBaseBranch", "project checkout" and "base branch". spawn --base-branch <name> resolves the stale local ref; only remote-prefixed names are fetched #1917 and Worktree provider provisions stale refs and long-lived manager turns can silently search old code #3955 are about stale refs in the worktree provider.
- Not the machine or its setup: the null comes from the provider's server code, and the harness reproduces it on macOS from source.
- Not the base's spelling:
origin/devexists in the checkout and the branch was made from it.
Suggested priority and effort
This hits every project-checkout thread on a new branch from a non-default base. The workaround is picking the merge base in the diff panel, or bb environment update <env> --merge-base-branch <base>. No work is lost. The fix is small, in the plugin only.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 20, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotworkspaces,confirmed-repro; no existing classification was replaced.git diff --checkpasses. No live user instance or linked PR code was run.Preserve new checkout branch comparison bases (get-bb#5856)