Skip to content

Add user-managed worktrees to thread composer - #2482

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

Add user-managed worktrees to thread composer#2482
banjerluke wants to merge 2 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

What was wrong

The new-thread composer built its Existing worktree choices only from bb environments associated with active threads. Git worktrees created and owned by the user were therefore invisible in the app, even though thread creation could already attach an explicit unmanaged path. The missing piece was host-local Git discovery plus canonical path matching across discovered worktrees, 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 host-canonical paths.
  • Added the host.list_worktrees daemon RPC and bumped HOST_DAEMON_PROTOCOL_VERSION from 170 to 171.
  • Added project-level server aggregation that merges discovered worktrees with reusable bb environments, deduplicates canonical (host, path) identities, preserves bb-managed precedence, and reports partial per-machine failures.
  • Added sdk.projects.worktrees(...) and bb project worktrees <project-id> [--json], with matching guide and built-in skill documentation.
  • Updated the root and plugin new-thread composers to list discovered worktrees and attach a selection through the existing unmanaged-workspace path.
  • Kept user-managed lifecycle ownership explicit: archiving or deleting the last thread does not delete the worktree, its branch, or user-owned processes.
  • Made the worktree dropdown viewport-aware and vertically scrollable for long worktree lists.
  • Updated worktree documentation and added focused parser, contract, daemon, server, SDK, CLI, picker, and lifecycle coverage.

This remains discovery-only. It does not add branch continuation, change generated branch naming, prune user worktrees, add persistence, or alter the thread-create request shape.

How you verified

  • pnpm exec turbo run typecheck with filters for @bb/db, @bb/server, @bb/cli, @bb/app, @bb/host-daemon-contract, @bb/host-workspace, @bb/host-daemon, @bb/sdk, and @bb/server-contract — 12/12 Turbo tasks passed after rebasing onto current upstream main.
  • Focused changed-file suites — 269 tests passed after the rebase.
  • git diff --check upstream/main...HEAD passed.
  • Independent GPT-5.6-Luna max and Claude Fable high reviews found no implementation, accessibility, Radix, Tailwind, or overengineering issues.

Live browser QA of desktop collision scrolling and the compact responsive drawer was performed by the user.

AGENT GENERATED - GPT 5.6 Sol high with Fable high review

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. Preserve user-owned worktrees after their last thread is archived or deleted.

Bump the host-daemon protocol for the wire-contract change and cover discovery and lifecycle behavior end to end.
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

1 participant