Skip to content

Simplify thread fork environment selection - #3018

Merged
ymichael merged 4 commits into
mainfrom
bb/simplify-thread-forking-reuse-or-a-new-environme-thr_2qre9f9jgc
Sep 3, 2026
Merged

ymichael merged 4 commits into
mainfrom
bb/simplify-thread-forking-reuse-or-a-new-environme-thr_2qre9f9jgc

Conversation

@ymichael

@ymichael ymichael commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Thread forking exposed a fork-specific workspace policy even though continuing a provider session already requires the child environment to live on the source thread's host. That split environment selection between fork-specific core logic and normal thread placement, allowed invalid cross-host requests to fail late, and caused Claude forks into a new directory to look for the source session under the new working directory.

What changed

  • Replaced the fork request's workspace field with the create-style environment argument. Omitting it now reuses the source environment.
  • Routed explicit fork environments through normal thread placement and reject a different host before provisioning.
  • Updated the SDK, side-chat plugin, CLI guide, and built-in CLI skill. bb thread fork now supports --environment, --new-environment worktree, and --base-branch; --workspace was removed.
  • Bumped @get-bb/plugin-sdk to 0.4.42 and refreshed the Plugin Guide API inventory for the changed threads.fork declaration.
  • The CLI derives the required host from the source thread. It does not expose --host or --machine, because another host is never valid for a fork.
  • Kept the Claude bridge fix that finds the source session independently of the fork's new working directory.
  • There are no database model, lifecycle, or host-daemon wire changes, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.

The user-visible default changes from creating an isolated environment to reusing the source environment. Explicit new worktrees use normal create placement and the project's default base branch unless --base-branch is supplied.

How you verified

Added regression coverage that failed before the implementation and passes after for default reuse, early cross-host rejection, SDK serialization, CLI environment flags, side-chat requests, and Claude forks across directories.

  • Server fork/create suites: 61 tests passed.
  • Contract, SDK, CLI, side-chat, Claude bridge, and template suites: 299 tests passed.
  • Turbo typechecks passed for the affected server-contract, SDK, CLI, server, side-chat, Claude bridge, and templates packages.
  • Plugin SDK npm version guard and Plugin Guide build passed.

No linked issue.

AGENT GENERATED

ymichael and others added 4 commits September 3, 2026 13:53
An isolated fork runs in a new directory, but the Claude bridge asked the
Agent SDK to find the source session under that new directory, so every
fork into a fresh worktree or personal workspace failed with "Session … not
found in project directory for <new cwd>". Reuse forks, which the app uses,
were unaffected. Codex was unaffected because its sessions are global.

Omit the directory hint: the SDK then searches every project directory for
the source session, and the forked session resumes in the new cwd as before.
Verified on a dev server: a Claude thread forked isolated into a new
personal workspace now answers from the source's context.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ymichael
ymichael force-pushed the bb/simplify-thread-forking-reuse-or-a-new-environme-thr_2qre9f9jgc branch from 07da8b6 to 81680eb Compare September 3, 2026 20:56
@ymichael
ymichael merged commit 8e95b29 into main Sep 3, 2026
15 checks passed
@ymichael
ymichael deleted the bb/simplify-thread-forking-reuse-or-a-new-environme-thr_2qre9f9jgc branch September 3, 2026 21:02
ymichael added a commit that referenced this pull request Sep 3, 2026
## Human comments

## What was wrong

[PR #3018](#3018) replaced the
fork-specific workspace switch with normal environment selection, but
the shared CLI environment builder recognized only `worktree`. The
server and SDK still accepted fresh personal workspaces, so
personal-project users lost the CLI path that the former isolated fork
option provided.

## What changed

- Accept `--new-environment personal` through the existing
host-placement path, which makes forks use their derived source host.
- Advertise and document both supported fresh environment choices in CLI
help, the generated guide source, and the bundled bb-cli skill.
- Add focused builder, fork-request, source-host, and help coverage
while preserving default reuse, worktree/base-branch behavior, and the
absence of a cross-host fork selector.
- No server/daemon wire contract changed, so
`HOST_DAEMON_PROTOCOL_VERSION` is unchanged.

## How you verified

- The new focused assertions failed before the implementation and pass
afterward: 40/40 tests across `spawn-helpers.test.ts` and
`command-output/thread-fork.test.ts`.
- `pnpm exec turbo run test --filter=@bb/templates -- --run
test/templates.test.ts` — 7/7 passed.
- `pnpm exec turbo run build typecheck --filter=@bb/cli
--filter=@bb/templates` — 6/6 tasks passed.
- `pnpm exec oxfmt --check ...` and `git diff --check` passed.

Fixes #3018

> 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