Skip to content

Always seed new worktrees from the fresh remote default - #153

Merged
ymichael merged 4 commits into
mainfrom
bb/default-new-worktree-behavior-thr_aiq4an33zy
Jun 16, 2026
Merged

ymichael merged 4 commits into
mainfrom
bb/default-new-worktree-behavior-thr_aiq4an33zy

Conversation

@ymichael

@ymichael ymichael commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

New worktrees always base off the fresh remote default, and that default keeps winning as you move around the composer.

  • Refresh remote-tracking refs before branch search so newly pushed remote branches appear without a manual git fetch.
  • Compute a smart worktree base default that uses origin/<default> when the local default is only behind, while keeping the local default for equal/ahead/diverged histories.
  • Wire the computed default through project branch responses, root-composer display/submission, and server-side managed worktree creation.
  • Re-seed the new-worktree base branch from that fresh default when switching environment modes (e.g. New Worktree -> Working Locally -> New Worktree), instead of restoring the previously-picked branch.
  • Drop the now-redundant per-environment localStorage persistence of the worktree base branch (previously added in Remember new worktree base branch selection #139): the smart default already surfaces origin/main on load, so remembering a stale pick only fought the "prefer fresh remote default" behavior.

Note

The re-seed is uniform across modes: Working Locally also re-seeds its branch (back to the current checkout) on a mode toggle, not just New Worktree.

Validation

Frontend (this change):

  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec turbo run test lint --filter=@bb/app

Backend (smart default, unchanged from earlier commits):

  • pnpm exec turbo run typecheck --filter=@bb/host-workspace --filter=@bb/host-daemon --filter=@bb/server-contract --filter=@bb/server --filter=@bb/app
  • pnpm exec turbo run test --filter=@bb/host-workspace
  • pnpm exec turbo run test --filter=@bb/host-daemon
  • pnpm exec turbo run test --filter=@bb/server-contract
  • pnpm exec turbo run test --filter=@bb/server -- worktree-base-branch
  • pnpm exec turbo run test --filter=@bb/host-daemon-contract
  • pnpm exec turbo run test --filter=@bb/domain
  • pnpm exec turbo run test --filter=@bb/server -- public-threads.defaults thread-default-policy thread-create

@ymichael
ymichael force-pushed the bb/default-new-worktree-behavior-thr_aiq4an33zy branch from ca1ae34 to 2671ea0 Compare June 15, 2026 23:11
Switching New Worktree -> Working Locally -> New Worktree now re-seeds the
base branch from the fresh smart remote default instead of restoring the
previously-picked branch. The picked branch is scoped to the active
environment and dropped whenever the scope (environment mode or project)
changes.

Removes the now-redundant per-environment localStorage persistence of the
worktree base branch (#139): the smart default added in this PR already
surfaces the fresh remote default (e.g. origin/main) on load, so remembering
a stale pick only fought the "prefer fresh remote default" intent.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ymichael ymichael changed the title Prefer fresh remote default for new worktrees Always seed new worktrees from the fresh remote default Jun 16, 2026
@ymichael
ymichael merged commit 36450e5 into main Jun 16, 2026
6 checks passed
@ymichael
ymichael deleted the bb/default-new-worktree-behavior-thr_aiq4an33zy branch June 16, 2026 17:05
ymichael added a commit that referenced this pull request Aug 24, 2026
## What was wrong

The new-thread composer kept the submitted draft visible until thread
creation completed. At the same time, #2152 made the server inspect
every named worktree base before provisioning. The root composer already
submits its smart default as an authoritative remote-qualified name such
as `origin/main`, so that path incurred a redundant `host.list_branches`
RPC even though provisioning fetches the exact remote branch. The added
creation latency made the delayed prompt clear especially noticeable.

## What changed

- Clear the matching submitted draft before awaiting thread creation. If
creation fails, restore it only when the optimistic clear succeeded and
the user has not started a newer draft.
- Treat `origin/...` managed-worktree bases as authoritative and pass
them directly to provisioning, while preserving the existing inspection
and local-vs-origin policy for defaults and plain names such as `main`.
- Preserve the smart named-default behavior introduced by #153.
- No wire, CLI, guide, or documentation changes;
`HOST_DAEMON_PROTOCOL_VERSION` remains 164.

## How you verified

- Added app regression coverage for clearing while submission is
pending, restoring after failure, and preserving a newer draft after
failure.
- Added route-level server coverage proving `origin/main` reaches
provisioning without a `host.list_branches` RPC.
- `pnpm exec turbo run test --filter=@bb/app --
src/components/plugin/PluginNewThreadComposer.test.tsx
src/views/root-compose-thread-environment.test.ts` — 28 tests passed.
- `pnpm exec turbo run test --filter=@bb/server --
test/public/public-threads.named-base-branch.test.ts` — 5 tests passed.
- `pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/server` —
5 tasks passed.
- `pnpm exec turbo run lint --filter=@bb/app --filter=@bb/server` — 0
errors.
- `pnpm exec oxfmt --check` on all five changed files.

Fixes the performance regression introduced by #2152.

> AGENT GENERATED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant