Skip to content

Remember new worktree base branch selection - #139

Merged
ymichael merged 3 commits into
mainfrom
bb/fix-new-worktree-selection-thr_69n7pn73c6
Jun 14, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/fix-new-worktree-selection-thr_69n7pn73c6

Conversation

@ymichael

@ymichael ymichael commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Persist the root-compose managed worktree base branch per project/environment so refresh restores remote refs like origin/main.
  • Keep remembering opt-in to worktree mode so local checkout branch selection remains session-only.
  • Pin origin/<default> into the first remote branch page so common refs like origin/main are available without waiting for search.
  • Remove the confusing Search to narrow branch results. branch picker hint and its dead prop plumbing.
  • Add focused coverage for remembered branch hydration and remote default branch pagination behavior.

Investigation notes

  • The picker locally filters the currently loaded branch page immediately, while the server search query is debounced. If origin/main is not in the first page, typing it can briefly show an empty/loading state before the debounced branch query returns.
  • There was no separate prefetch for origin/<default>; the first page only pinned the local default branch. This PR makes the host branch response include the matching origin remote ref up front.

Validation

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

@ymichael
ymichael merged commit 0ea261a into main Jun 14, 2026
6 checks passed
@ymichael
ymichael deleted the bb/fix-new-worktree-selection-thr_69n7pn73c6 branch June 14, 2026 03:14
ymichael added a commit that referenced this pull request Jun 16, 2026
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 added a commit that referenced this pull request Jun 16, 2026
## 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 #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`

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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