Skip to content

Discover user-managed Git worktrees in the thread composer - #3698

Closed
banjerluke wants to merge 4 commits into
get-bb:mainfrom
banjerluke:feat/issue-1-worktree-discovery
Closed

banjerluke wants to merge 4 commits into
get-bb:mainfrom
banjerluke:feat/issue-1-worktree-discovery

Conversation

@banjerluke

Copy link
Copy Markdown

Human comments

This was a blocker for me using bb with an established project where I have work in progress going on different worktrees.

Closes #1624
Re-submission of #2482

What was wrong

The new-thread composer built its reuse choices from BB environments associated with threads. Git worktrees created outside BB were therefore invisible, even though the existing Project checkout provider could already attach a supplied path. The missing pieces were host-local Git discovery and canonical path matching against project sources and stored environments.

What changed

  • Added bounded, NUL-safe parsing of git worktree list --porcelain -z, including branch or detached checkout, lock state, prunable state, and canonical paths.
  • Added the host.list_worktrees daemon RPC and bumped HOST_DAEMON_PROTOCOL_VERSION from 208 to 209.
  • Added project-level aggregation that matches discovered worktrees with reusable BB environments, deduplicates canonical paths per machine, and reports partial per-machine failures.
  • Added an Existing worktree choice and clarified the creation choice as New worktree. The picker shows discovered paths, ownership, availability, and discovery failures with retry.
  • Kept discovery orchestration, option-building, and row presentation in dedicated UI modules. Integrated with the existing searchable machine/provider picker.
  • Discovered paths submit through the existing Project checkout provider with an existing host and inputs.path; the thread-create request shape is unchanged.
  • Added sdk.projects.worktrees(...) and bb project worktrees <project-id> [--json], with dedicated CLI formatting and matching guide, skill, and worktree documentation.

Discovery does not create or prune worktrees or add persistence. Existing checkout-provider lifecycle behavior preserves user-managed directories, branches, and Git registrations when their threads are archived or deleted.

How you verified

  • Turbo typechecks passed for the app, server, CLI, host daemon, host workspace, SDK, and server/daemon contracts.
  • 380 focused tests passed across discovery parsing, daemon dispatch, server aggregation and lifecycle, SDK, CLI, picker behavior, selection routing, and plugin composer seeding.
  • The 40-test server-contract suite passed on the combined branches.
  • Picker tests cover the current command-menu interaction, New worktree / Existing worktree labels, loading, failures, retry, and unavailable selections.
  • git diff --check origin/main...HEAD passed.

Earlier user verification covered desktop collision scrolling and the compact responsive drawer. Browser QA was not repeated after this rebase.

AGENT GENERATED

banjerluke and others added 4 commits September 15, 2026 09:18
Discover Git worktrees registered outside bb and expose them through the daemon, project API, SDK, CLI, and new-thread picker.

Use canonical host/path identity so reusable environments take precedence while locked, stale, detached, and unavailable worktrees remain explicit. Ownership follows the environment provider architecture: a discovered worktree starts a thread through the Project checkout provider at its path, which never removes an attached directory or its branch. Ephemeral sandbox machines are not scanned.

The new-thread composer merges discovered rows into the reuse environment picker and regains an "Existing environment" row so discovery is browsable; a selection that disappears after a refresh stays in reuse mode instead of silently retargeting the thread.

Bump the host-daemon protocol for the new host.list_worktrees command and cover discovery, merging, and lifecycle behavior end to end.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lukes-clanker
lukes-clanker Bot force-pushed the feat/issue-1-worktree-discovery branch from 7d5c250 to 963d906 Compare September 15, 2026 16:19
@ymichael

Copy link
Copy Markdown
Collaborator

Thank you for this! I added support for this in #3932

@ymichael ymichael closed this Sep 19, 2026
@ymichael

Copy link
Copy Markdown
Collaborator

This will go out with the next release

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.

Support discovered worktrees and continuing existing branches

2 participants