Skip to content

Per-machine warm worktree counts, on a shared settings list - #8112

Merged
ymichael merged 11 commits into
mainfrom
bb/add-per-host-worktree-warming-counts-thr_jtqwi3qw8p
Nov 24, 2026
Merged

ymichael merged 11 commits into
mainfrom
bb/add-per-host-worktree-warming-counts-thr_jtqwi3qw8p

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A project's warm worktree count applied to every machine with a checkout of that project. A project checked out on a laptop and a build machine could only keep the same number of warm worktrees on both, or none on either, so you could not keep a big pool on a beefy machine without paying for it on a small one.

What changed

  • plugins/environment-git-worktree/warm-pools.ts: the stored warm-pools configuration gains a hosts map per project (entries saved before this change still parse; hosts defaults to {}). A machine's count is its own count if set, otherwise the project's. Reconcile, refill, discard and handoff all use the per-machine count, so a machine set to 0 drops its idle members and builds fresh worktrees, and a machine with its own count keeps its pool while the project's count is Off. Status adds size (the count in effect) and hostSize (the machine's own count, null when it follows the project) to each checkout.
  • server.ts: new setWarmPoolHostSize RPC (size: null follows the project again; rejected for a machine with no checkout of the project). bb worktree pool set gains --host <host-id>, and with it the size project. Status text now marks which machines have their own count.
  • warm-pool-settings.tsx: a project on more than one machine lists each machine as one row (Build box · 2 ready) with its own picker: Project (N) (muted while it follows the project) or Off/1–4. Split into a presentational WarmPoolSettingsContent with a Ladle story (plugins/Warm worktrees, registered in apps/app/.ladle/config.mjs). The heading moves to the slot's title/description.

Shared settings list. Core settings pages built on SettingsSection/SettingsRowList in apps/app, which plugins cannot import, so every plugin settings section hand-rolled its own list (a hairline rail, an inner bordered box, or a copy of core's classes).

  • settings-section.tsx moves unchanged from apps/app/src/components/ui to @bb/shared-ui/settings-section (25 core imports updated) and joins the plugin component registry (npx shadcn add @bb/settings-section).
  • New in that file: SettingsList (the settings card, optional sub-heading), SettingsListItem (title, middot-joined meta, badge, description, leading, trailing control, per-row error, nested child items) and SettingsListMessage (loading/empty/error rows). Nested rows align under the parent's title.
  • Migrated: warm worktrees (nested per-machine rows), concurrency limit (overall limit + host limits), keep awake (host checkboxes now nest under "Specific hosts"), and the ACP agent registry (heading moved to the slot title; Refresh sits beside search).
  • Core: a project's Folders section (Settings → Projects → a project) builds on the same rows: machines with their main and extra folders nested under a hairline aligned with the machine icon, an Add folder row per machine, no dividers between machines, Set up named per machine, Offline as a status note instead of a dot plus an "Offline" button, and a missing folder as an error line. SettingsListRows is the list without the card, for sections already inside a SettingsSection.
  • Rows are a grid: the title line and control share the first row; description and error sit under the title, so errors never run under the control. dividers={false} drops dividers where items nest; SettingsListAction is the "Add …" row.
  • Story: settings/Settings list shows every shape. Plugin-authoring docs describe the primitives.
  • app.tsx: the base-branch picker's ready count uses the machine's count in effect.
  • Docs: docs/worktrees.md, docs/configuration.md, the plugin's worktree skill and README.

No server/daemon wire change: this is plugin RPC and plugin KV only.

How you verified

  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-environment-git-worktree: 199 tests pass. New tests in warm-pools.test.ts: a machine set to 0 discards its members, persists hosts, and builds fresh worktrees, then refills once set back to follow the project; a machine with its own count keeps and hands off its member while the project is Off; a count for a machine without a checkout is rejected.
  • pnpm exec turbo run typecheck lint --filter='...[origin/main]' (97 tasks) and tests for shared-ui, plugin-registry, bb-guide and the four migrated plugins pass, as do the app tests covering the moved file (theme anatomy, settings search anchors, machines/projects/plugin settings).
  • On a pnpm start:worktree instance with two enrolled machines: changed counts from the UI and CLI and watched each machine fill to its own count; clicked through keep awake (enable, Specific hosts, uncheck a host) and confirmed bb keep-awake status; checked the concurrency limit and ACP registry pages render.
  • Checked the settings page in Ladle with three projects (one on three machines with follow/4/Off, one with the project Off and one machine on 1 with a setup error, and single-machine projects).

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 3 commits November 24, 2026 10:08
A project's warm worktree count applied to every machine with a checkout.
Each machine can now keep its own count, which wins over the project's,
from the settings page, the setWarmPoolHostSize RPC, or
`bb worktree pool set <project-id> <size> --host <host-id>` (`project`
follows the project's count again).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One hairline for the project list instead of a nested second one. Each
machine is a single line with its name, a short ready count and its
picker; paths move to a tooltip, the base branch and the per-project
explainer are gone, and the intro is shorter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Core settings pages used SettingsSection/SettingsRowList from apps/app,
which plugins cannot import, so each plugin settings section hand-rolled
its own list: a hairline rail (warm worktrees, concurrency limit), an
inner bordered box (keep awake, ACP registry) or a copy of core's classes.

settings-section moves to @bb/shared-ui (and the plugin component
registry) unchanged, and gains SettingsList, SettingsListItem and
SettingsListMessage: the settings card with an optional sub-heading, and
rows with a title, middot-joined meta, badge, description, leading and
trailing controls, a per-row error and nested rows for per-machine or
per-account overrides. Warm worktrees, concurrency limit, keep awake and
the ACP agent registry now build on them, and section headings move to
the settingsSection slot's title and description.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Let each machine keep its own warm worktree count Per-machine warm worktree counts, on a shared settings list Nov 24, 2026
ymichael and others added 8 commits November 24, 2026 11:07
Machines are SettingsListItems with their main and extra folders nested
under them, replacing the hand-rolled hairline and folder entries. Add
folder and Set up move into the machine row's control slot (named per
machine), the status dot becomes an Offline note, and a missing folder
shows as an error line. SettingsListRows is the list without the card,
for sections that already sit in a SettingsSection.

The plugin-authoring detail moves into the settingsSection slot
reference so frontend-hooks-and-ui.md stays within the 500-line cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A row is now a grid: leading, title line and control share the first
row, and the description and error sit under the title in the text
column, so a long error never runs under the control. Nested items hang
off a hairline aligned with the parent's leading icon (or its title),
lists can drop dividers where items nest, and SettingsListAction is the
"Add …" row at the end of a nested group.

Project Folders goes back to an Add folder row per machine, with no
dividers between machines; warm worktrees and keep awake drop dividers
too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rail sat flush under the parent title's first letter, reading as a
border. It now hangs a few pixels into the title, with the nested rows
indented past it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Below 30rem of list width, a row's control drops under its title and
details, aligned with the title, so text keeps the full width; switches
stay trailing as in SettingsWithControl. The query sits on the list, so
nested rows switch with their parents. Titles and meta wrap instead of
truncating, each middot stays glued to the text before it, and badges
follow the meta so a wrapped line never starts with a separator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An overflow menu is icon-sized, so like a switch it stays beside the
title instead of dropping under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The per-machine counts were full form selects: a heavy column of boxes
on desktop and a zig-zag of stacked fields on narrow screens.
SETTINGS_INLINE_SELECT_CLASS is a borderless value-plus-chevron trigger
that stays trailing at every width (dropdowns join switches and menus as
compact controls); inherited values render muted. Meta items no longer
break mid-item and rows are 32px minimum to match the controls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit c68606f into main Nov 24, 2026
52 checks passed
@ymichael
ymichael deleted the bb/add-per-host-worktree-warming-counts-thr_jtqwi3qw8p branch November 24, 2026 19:40
ymichael added a commit that referenced this pull request Nov 24, 2026
…per-machine pools

Main added 0169 and per-machine warm pool counts (#8112). The branch's
migrations become 0170 (setup_folder_paths) and 0171 (additional path
entries). Pool folders are stored next to the project's and machines'
counts, and the settings list shows the folder choices as nested rows under
a project that keeps warm worktrees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 24, 2026
… them up and keep them warm (#8065)

## Human comments

## What was wrong

#8007 added `additionalPaths` so an environment provider can give a
thread extra folders, but no provider returned any, and nothing let an
environment take a project folder out of the thread's workspace. A
worktree thread in a multi-folder project could only branch the main
repository: every other repository in `bb project folder` stayed a
shared checkout that all threads wrote to. Setup scripts also ran only
in the main workspace, and warm worktrees could not carry extra
repositories.

## What changed

**Core contract (experimental, documented in `docs/api_to_audit.md`).**
- `additionalPaths` becomes a list of `{ path, replaces? }` entries
(domain: `replaces: string | null`, filled once when the create result
is parsed). `replaces` names the project folder an entry stands in for.
`mergeWorkspaceFolderPaths` (`workspace-folder-paths.ts`) is the one
place that builds the session's folders: project folders minus the
replaced ones, plus each entry's `path`. A replaced folder stays out
even when its replacement is missing, so a thread never falls back to
writing the shared checkout. Migration 0171 converts recorded
`additional_paths` strings into entries that replace nothing. `bb
environment show` prints `Folder: <path> (replaces project folder
<folder>)`.
- `setup(path, { folders })`: a create can name the extra folders it
made. Core stores them (`environments.setup_folder_paths`, migration
0170), runs each folder's `.bb-env-setup.sh` once, in order, before the
main one (each as its own hook operation, `…:setup:folder:<i>`), and
runs teardown in the main workspace first, then the folders in reverse.
A create fails if it set up a folder it did not return in
`additionalPaths`. After `adopt`, `folders` may name only folders the
adopted environment recorded: core forgets their finished setup records
(`forgetFinishedEnvironmentHookOperations`) and runs them again, then
the main one. Recovery inspects and acknowledges each folder's hooks.
- Plugin SDK 0.6.197. No daemon wire change: hooks already run per path,
and the daemon still receives the merged folder list.

**Worktree provider (`plugins/environment-git-worktree`).**
- Inputs gain `folders: string[]` (default `[]`). `validate`/`create`
refuse a folder that is not one of the project's folders on that
machine.
- New host RPC `createFolders` (`host/folders.ts`): each folder must be
the top folder of a repository with a commit, and no two (including the
main checkout) may share a git common dir. It makes a worktree of each
folder next to the main one, detached at that repository's default base.
If one fails, everything made is removed.
- Create and restore pass the new folder worktrees to `setup`, so their
setup scripts run before the main worktree's.
- Removal removes every worktree in the environment's directory and
deletes each repository's bb-owned branch under the #7242 rules.
- Picker: "Also branch:" lists the machine's project folders that are
git repositories (`listBranchableFolders`).
- Warm pools: folders are set per machine (each checkout has its own
folder paths), on the settings page under each machine or with `bb
worktree pool folders <project-id> <folder>... [--host <host-id>]`, and
stored next to #8112's per-machine counts. Members are created with
those folders and handed only to a create that branches exactly that
set. On handoff the provider checks each folder worktree like the main
one, fast-forwards any that is behind its remote, renames the
placeholder in every worktree, and calls `setup(main, { folders: moved
})`, so only moved folders (and then the main worktree) are set up
again. Reconcile replaces members whose folder set differs or whose
folder worktree left the placeholder or its base.
- Settings: each machine's folder checkboxes sit under it and are shown
only while it keeps warm worktrees; a chosen folder that is no longer a
git project folder there is flagged. Ladle stories cover every state.

**Storage retention.** An environment's `additionalPaths` count as
bb-owned (never offered as external worktrees), their uncommitted
changes block automatic recovery of an interrupted cleanup, and their
size is added to the leftover worktree's.

**Docs.** README, the worktree skill, the bb guide's environments and
projects chapters, and the plugin-authoring references.

## How you verified

- New and updated tests: `environment-holds.test.ts` (folder setups run
in order before the main one and teardowns in reverse; setup after adopt
reruns only named recorded folders; unrecorded folder refused;
unreturned set-up folder fails the create),
`provider-orchestration.test.ts` (entries canonicalized, relative
`replaces` rejected), `thread-runtime-config.test.ts`,
`environment-additional-path-entries-migration.test.ts`, `host.test.ts`
(real git folder worktrees), `server.test.ts`, `warm-pools.test.ts`
(folder handoff, exact-set matching, fast-forward and re-setup of a
behind folder, reconcile replacement, per-machine folder config),
`storage.test.ts` (folder worktree changes block recovery and folder
worktrees are never external; both fail without the fix).
- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`
passes; affected package tests pass locally.
- Live on an isolated `pnpm start:worktree` instance with real
repositories whose setup/teardown scripts log their order: a create with
`docs` and `api` ran setup docs → api → app and teardown app → api →
docs, removing every worktree and branch; a warm pool branching `api`
set up api → app, was handed to a thread branching `api` without new
setup and with the branch renamed in both repositories; a thread
branching nothing missed and built fresh; after a push to `api`'s
remote, the handoff fast-forwarded the `api` worktree to the new commit
and reran setup api → app; the settings checkboxes saved per machine.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 24, 2026
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.200.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 25, 2026
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.203.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 25, 2026
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.208.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 26, 2026
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.208.

Co-Authored-By: Claude Opus 5.5 <[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