Repository navigation
Let an automation choose its environment in the New thread composer - #6056
Closed
alexandre-vl wants to merge 22 commits into
Closed
alexandre-vl wants to merge 22 commits into
alexandre-vl wants to merge 22 commits into
Conversation
…ry host has no source A project-default thread always resolved on the primary host, so a project whose only source lives on another machine failed with 404 "Project has no local-path source for host". When the primary host has no source of the project, use the persistent machine that holds its default source, or its oldest source on a persistent machine. Projects with a source on the primary host keep today's placement; an offline project machine fails with 502 instead of moving the thread. Fixes get-bb#4446
A project had no default environment. The root composer remembered the last environment per browser, while threads created without one (automations, tasks presets, `bb thread spawn` with no environment flag) always got a worktree on the primary host, so "Project default" matched neither. Store a per-project default environment, set from Project settings, the CLI (`bb project default-environment`) or the API. The composer starts in it; a pick made in the composer lasts for that tab's draft. Threads created without an environment start in it too, a Project checkout default giving each its own worktree on that machine. An unusable default refuses thread creation with 409 and is reported on the project, instead of silently falling back.
An automation's editor changed only its prompt and model. Where each run worked was fixed at creation by CLI flags, and the plugin could not store a provider environment (a worktree from a named branch, a composition such as berth, a checkout on another machine) or agent options. Edit prompt now opens the SDK's experimental_NewThreadComposer, the New thread screen's own component, seeded with the stored execution. Six optional props let a plugin edit a saved request: a locked project, a Project default entry, an in-memory draft, no attachments, seeded agent options and no plugin customizations. The automation stores the composer's environment and agent options as threads.spawn takes them, refuses on save what every run would fail on, and `bb automation create|update` gains the same choices.
The SDK's bundled declarations include the project schemas, which now carry defaultEnvironment and defaultEnvironmentProblem. 0.6.65 is already on npm, so the npm version guard refused to republish it with different types.
get-bb#6055 now ships 0.6.66 with the project default environment types, so the composer props this branch adds need the next version, and the automations plugin that uses them requires it.
Main moved the SDK to 0.6.67 (get-bb#6048, get-bb#6051), so this branch's own type changes need the next version.
get-bb#6055 now carries main and ships 0.6.68, so the composer props this branch adds need 0.6.69, and the automations plugin that uses them requires it.
Tests (plugins) failed in plugins/connect-next/src/frp-e2e.test.ts:394, which this branch does not touch: frpc reported "read: connection reset by peer" where the test only accepts connection refused, EOF or dial. The same code passed on main and on get-bb#6055, and three local runs pass.
Main already carries "Start project-default threads on the project's machine when the primary host has no source" (get-bb#6054) and "Show why an automation failed" (get-bb#6005); the merge keeps their code and adds this branch's project default environment on top. The project default environment entry in docs/api_to_audit.md follows main's new entries.
Main's failed-run story (get-bb#6005) renders AutomationDetailView, which now requires projectDefaultEnvironment.
Main moved PromptBoxInternal into the bundled Composer plugin (get-bb#6122): the suppressed send-menu test now renders ComposerBox inside the composer test providers, and the dispatchThroughEditorTarget helper main removed stays removed. Main also carries "Show why an automation failed" (get-bb#6005), so its failed-run story passes the environment catalog the detail view now takes. The Automations plugin requires plugin SDK 0.6.75.
alexandre-vl
added a commit
to alexandre-vl/bb
that referenced
this pull request
Oct 23, 2026
…nment-composer Pick up get-bb#6055 and get-bb#6056 merged with main, with the plugin SDK at 0.6.75.
# Conflicts: # apps/server/test/public/public-threads.project-default.test.ts # packages/templates/src/templates/bb-guide-threads.md
# Conflicts: # packages/templates/src/templates/bb-guide-threads.md
ymichael
added a commit
that referenced
this pull request
Nov 3, 2026
## Human comments ## What was wrong The Automations CLI copies core's thread-spawn helpers, and the copies drifted. Its path check missed Windows paths (#4659), so `--environment C:\repo` was saved as an environment id. `--new-environment` and workspace paths picked the first host matching a `connected` field that doesn't exist, then any connected host, then `hosts[0]` even when offline. Core uses the CLI's own machine. `--at 2026-12-01` was read as UTC midnight, but core rejects a date with no time as ambiguous. ## What changed `plugins/automations/src/cli.ts` only: - The path check uses core's rules: a backslash or a leading drive letter makes the value a path. - New environments and workspace paths run on the calling thread's machine, falling back to `primaryHostId`. This reuses the thread-host lookup that `--script-file` already had. The old host-list scan is deleted. - A date-only `--at` is rejected. Other `--at` values parse as before. - The `--environment` help text now says where a path runs. No plugin SDK, host-daemon protocol, or RPC contract changes. Open #6056 makes the same default-machine change as part of a larger feature; whichever lands second will need a small conflict fix in `cli.ts`. ## How you verified New tests in `server-harness.test.ts` failed before the fix and pass after: - `--environment C:\repo` and `--new-environment worktree` from a thread land on that thread's machine. Before, the path was saved as `reuse` and the worktree went to the first connected host. - A date-only `--at` is rejected. Before, it was accepted. Three existing expectations moved from the first connected host to the primary host, so they now cover the no-thread fallback. `pnpm exec turbo run test typecheck lint --filter=bb-plugin-automations` passes: 166 tests; lint has 0 errors and 4 warnings, all pre-existing in other files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Opus 5.5 <[email protected]>
Contributor
|
This is an automated message. We have closed this pull request because it has been open for more than two weeks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
An automation's editor could change only the prompt, model, reasoning and permission mode. Only CLI flags could change where each run worked, and only to a workspace path, a new worktree or an existing environment. The plugin could not store the other choices the New thread composer offers:
agentEnvironmentSchemahad onlyreuse,hostandproject-default. It had no provider environment: no worktree from a named branch, no composition such as berth, no checkout on another machine. Executions had no agent options.devread "New worktree".bb automation create --new-environment worktree, or a workspace path, ran on the first connected host in the list, not on the invoking thread's machine.The SDK's
experimental_NewThreadComposeris the New thread screen's own component, but it could not hold a saved request:project-defaultseed;Stacked on #6055, which builds on the merged #6054. This branch contains their commits, so review only
9cb4299.eb49addand the merges45db005,ba0ef55andc7de022bring in #6055 andmain, and move the SDK version.What changed
Composer (
@get-bb/plugin-sdk0.6.75, after Let a project choose the environment its new threads start in #6055's 0.6.74; the automations plugin requires>=0.6.75): six optional props, mapped onto core's own options. The defaults keep today's behavior for the New thread screen, Settings and the showcase.allowProjectChangesets core's project lock.allowProjectDefaultEnvironmentadds a "Project default" entry that names what the default resolves to, and submits{type: "project-default"}.persistDraft={false}keeps the draft in memory.allowAttachments={false}removes attachments.defaultSessionOptionsseeds agent options. Returning to an earlier seed now resets edited options.allowPluginCustomizations={false}appliessuppressPluginComposerCustomizations, as the sent-message editor does. It hides send-menu rows, banners and commands from plugins.Automation data:
providerenvironment variant with the same shapethreads.spawntakes, andsessionOptions(nullclears them). Both are stored as JSON, so there is no migration.threads.spawnunchanged.Refused on save, because every run would fail (service, options, environment):
Changing the provider, or switching to re-prompting a thread, drops the stored options.
Editor UI (
detail-view.tsx,composer-request.ts):@thread:,@project:and@section:tokens. File and command mentions keep their text.CLI:
bb automation create|updategain these flags, which followbb thread spawn:--environment-providerand--environment-inputs;--machine, which must be persistent;--new-machineand--machine-inputs;--optionand--clear-options;--environment project-default.showandlistprint the environment and options. A workspace path or--new-environmentnow runs on the invoking thread's machine, or the server's.Docs:
bb thread spawn, the option check, and when options are dropped;PLUGIN_OVERVIEW.mdand the composer's TSDoc;docs/api_to_audit.md: its consumer, each prop, a corrected item 4, and why the New thread screen has no Project default entry;frontend-components.mdand the Plugin Guide surface.No server/daemon wire change, so no
HOST_DAEMON_PROTOCOL_VERSIONbump.Known limits
provider-orchestration.ts). Nothing in the checkout carries over from one run to the next.providerRoutingForEnvironmenthas no machine to ask yet. The check is skipped when the catalog fails to load or lacks the model.How you verified
Composer, in
PluginNewThreadComposer.test.tsx:Also in
new-thread-environment-seed,EnvironmentPicker,NewThreadPromptBox,PromptBoxInternal.test.tsx(suppressed send-menu rows, rendered throughComposerBoxsince Ship bb's composer as the bundled Composer plugin #6122 movedPromptBoxInternalintoplugins/composer) andPluginComposerBanners(suppressed plugin banners).Automations:
agent-environment.test.ts: the run request, permission routing, option checks and drops, environment refusals;composer-request.test.ts,automation-environment.test.tsand the editor indetail-view.test.tsx;server-harness.test.ts, including a temporary machine and options the model lacks.allowPluginCustomizations;pnpm exec turbo run typecheck lint test --continue --filter=@bb/app --filter=@get-bb/plugin-sdk --filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide --filter=bb-plugin-automations --filter=@bb/domain --filter=@bb/templates --filter=@bb/cli:@bb/app6277,@bb/cli900,@get-bb/plugin-sdk389,@bb/domain258,bb-plugin-automations225,bb-plugin-plugin-api-docs74,@bb/templates46,bb-plugin-bb-guide7;@bb/appcomes from a rerun after the last fix. In the full run before it,ThreadActionsMenu.test.tsx"coalesces rows that mount a moment apart into one change" failed under load; it passes alone and in the rerun.main:check-npm-version-guard.mjsprintednpm version guard: PASS — @get-bb/[email protected] is not on npm yet. The publish job will ship this version..github/workflows/check-plugin-sdk-version.mjsprintedPlugin SDK surface changed in 1 file(s) with a version bump.typecheck lintover the 14 packages this branch touches, Let a project choose the environment its new threads start in #6055's included, passed (25 tasks).@bb/app6361,@bb/server3694,@bb/cli898,@bb/db633,bb-plugin-tasks410,@get-bb/plugin-sdk398,@bb/domain259,bb-plugin-automations232,@bb/sdk123,@bb/server-contract78,bb-plugin-plugin-api-docs75,@bb/templates46,@bb/demo-server15,bb-plugin-bb-guide7.@bb/servertest failed on my machine:bb-official-generator.test.tsexpectsgit log --format=%cIto print2026-01-02T03:04:05Z, and git 2.43 prints2026-01-02T03:04:05+00:00. This PR does not touch that test or its script.9cb4299: a freshpnpm devwith one machine (david), project "Shop" whose default is Worktree ondavid, headless Chrome.Edit prompt → Environment → Worktree → Branch from: dev → Save:
bb automation show --jsonstored{"type":"provider","environmentProviderId":"git-worktree","machine":{"type":"existing","hostId":"host_…"},"inputs":{"branch":{"kind":"named","name":"dev"}}};An automation created with
--new-environment worktree --base-branch devread "Worktree on david · from dev". Onmainit read "New worktree".With the
environment-git-worktreeplugin disabled, the saved automation showed "Environment unavailable: the git-worktree environment provider is not installed. Runs fail until it is fixed."The CLI printed:
In an earlier live run, before the review fixes, choosing Project default stored
{"type":"project-default"}. UntilallowPluginCustomizationsexisted, the editor offered "Save draft…" and "Send later…"; the After editor below shows a single send button.Before / after
Before: #6055's head
44e31b5. The Worktree label row is frommainatb143a2286; #6055 renders it the same, "New worktree". After:9cb4299. Same setup as #6055: freshpnpm dev, project "Shop", one machinedavid, headless Chrome at 1280×860, cropped.dev, created by the CLI