Repository navigation
Preserve new checkout branch comparison bases - #5856
Conversation
|
This fixes #5850 as reported. Two things it leaves:
#5853 has the checkout host report the ref it made the branch from, as the worktree host reports its base, and has restore re-report the recorded merge base. #5855, stacked on it, fixes #5851. The PR gate closed both pending contributor approval.
|
Project-checkout environments are never retired, so later threads at the same path reuse the first environment row, and core skipped merge-base writes on reused rows its provider already owned. A checkout that already had an environment never recorded a new branch's base, and one whose first thread branched from another ref kept that base for every later thread, listing the default branch's newer commits as the later thread's changes. Provider create results may now report mergeBaseBranch as null to clear it; omitting it keeps the recorded value. Core applies a reported value to reused rows. The checkout provider reports the base for a new branch, null for an existing branch, nothing for a plain attach, and the recorded base on restore. Plugin SDK 0.6.60. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the clone lacks them (#5855) ## Human comments Thanks @ymichael for rebuilding this on `main`. ## What was wrong A project bb clones onto a machine holds only the remote's default branch, and the picker lists origin's branches there without `origin/`. The host passed the bare name to git. On `main` at 81b48d3, after #5856, a new branch from `dev` fails with `fatal: invalid reference: dev`, and an existing `release` with `Cannot checkout missing branch release`. ## What changed - The host looks a branch up locally, then as `origin/<name>` (`locateBranch`, on the shared `hasRef`). - An existing branch that only origin holds is switched to with `git switch --track origin/<name>`, so the switch does not depend on `checkout.guess`. - A new branch starts from `origin/<base>` when no local branch has it. The host reports that ref, and the provider records it as the merge base in place of the requested name. `dev` does not resolve in that clone, so a recorded `dev` would leave the thread's diff empty. #5856's other cases are unchanged. - A new branch tracks nothing, as the worktree host's `worktree add --no-track -B` makes one. Otherwise a branch made from `origin/dev` would take it as its upstream. ## How you verified At ebe71b6: - `project-checkout-branches.test.ts` runs in a plain clone. A new branch from `dev` records `origin/dev`, and `release` ends up tracking `origin/release`. Both fail on `main` with the errors above. - #5885's test, run here, has the thread commit in that clone: its diff reads `A\tthread.txt`. - These pass: - the plugin's tests (46) - the smoke, multi-thread and environments integration suites, with #5885's two tests added (43) - #5885 makes the same fix and lists which test fails when each part is reverted alone. Fixes #5851 > AGENT GENERATED Co-authored-by: Claude Opus 5.5 <[email protected]>
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
When the project-checkout provider created a new branch, it did not tell core which ref the branch was based on. Core then recorded no merge base and compared the thread against the default branch, so commits inherited from the base showed up as the thread's own changes (#5850).
The first commit made the provider report the base. That only worked for the first environment created at a checkout path. Project-checkout environments are never retired. Every later thread at the same path reuses that environment row, and core skipped merge-base writes on reused rows owned by the same provider (
environment-engine.ts, theadoptedExistingEnvironment && existingProviderOwnsLifecycleguard). This had two effects:topic-basekepttopic-basefor every later thread. A later thread branched frommainthen showed commitsmaingained aftertopic-baseas its own changes. Onmaintoday, that later diff is correct. The first commit alone caused this regression.Reproduction and root-cause report for the original bug: https://get-bb.github.io/reports/issues/5850.html
What changed
PluginEnvironmentProviderCreateResult.mergeBaseBranchnow acceptsnull. A string records the base,nullclears it, and omitting the field keeps it. This only matters when core reuses an environment row the provider already owns at that path. The result schema acceptsnull. Plugin SDK patch bumped to 0.6.60, because the published declaration types change.apps/server/src/services/environments/environment-engine.ts): on a reused row owned by the same provider, a reportedmergeBaseBranch(string ornull) is now applied, and an omitted one leaves the row unchanged. New rows behave as before.server.ts):null, so the diff falls back to the default branch. Core did the same before Environment providers: plugins own where threads run #3227.How you verified
apps/server/test/threads/environment-providers.test.ts, "on a reused host row it …": three cases (reported,null, omitted).expected 'origin/old' to be 'origin/dev'.nullcase fails because the old schema rejectsnull.plugins/environment-project-checkout/server.test.ts:null; attach-only omits the field.server-merge-base.test.tsis kept. It fails onmainand passes here.tests/integrationharness: real server, host daemon and plugin, fake agent; not committed). It reads the diff throughGET /environments/:id/diff:topic-base: before, the merge base wasnulland the diff includedbase-only.txt. After, the merge base istopic-baseand the diff is empty.topic-base, then a later thread frommainaftermaingainedmain-only.txt: with this PR's first commit alone, the merge base staystopic-baseand the diff showsA main-only.txt. After the fix, the merge base ismainand the diff is empty.pnpm exec turbo run test --filter=bb-plugin-environment-project-checkout: 45 passed.pnpm exec turbo run test --filter=@bb/server -- test/threads/environment-providers.test.ts: 68 passed.pnpm exec turbo run typecheck lint --filter='...[origin/main]' --continue: 139 of 139 tasks passed.node .github/workflows/check-plugin-sdk-version.mjsandnode packages/plugin-sdk/scripts/check-npm-version-guard.mjs: both pass.Fixes #5850
🤖 Generated with Claude Code