Skip to content

Probe environment provider availability per machine in the background - #3436

Merged
SawyerHood merged 1 commit into
mainfrom
bb/can-we-make-it-so-that-we-can-show-what-machines-thr_6ak45kwi62
Sep 10, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/can-we-make-it-so-that-we-can-show-what-machines-thr_6ak45kwi62

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The prompt-box environment picker offered every environment provider on every machine, so CoW copy showed up under Macs where its reflink probe can never succeed. Per-machine plugin availability existed briefly (#3227), but #3393 removed it from discovery because the app's per-machine fan-out blocked the picker on the slowest machine's Git inspection and plugin probe. That fix removed the information rather than making it non-blocking: discovery became structural only, availability is always null, and an unsupported choice now fails only at thread creation.

What changed

Server (apps/server/src/services/environments/provider-machine-availability.ts, new): a background per-machine availability probe. When a project's providers are listed, each structurally eligible provider and connected persistent machine is probed in the background (Git inspection when requires.gitCheckout, then the plugin's availability hook), keyed by provider, project, and machine. Listing never awaits a probe: it returns the cached answer or null. Results are cached for ten minutes, cleared when a plugin rechecks, and disconnected machines are never probed. When an answer changes, the server emits a new environment-availability-changed system change so clients refetch.

Contract (packages/server-contract/src/api/system.ts): each provider now carries machineAvailability, a map from host id to available, setup-required, unavailable, or null while unknown. availability is filled from that map when hostId is given. Thread creation still checks the selected provider and machine afresh, exactly as #3393 left it.

App: NewThreadComposer lists providers for the current project and derives each machine's rows from machineAvailability. The picker hides providers a machine reports as unavailable, except the currently selected one, which stays visible and disabled with its reason so the selection never disappears; setup-required rows stay selectable with their message; unknown rows show as before. The provider list is remembered per project in localStorage through the existing last-known cache and served as placeholder data, so the picker is already trimmed on the first open after a reload. The realtime registry maps the new system change to the provider query.

CLI: bb environment providers --project <id> --machine <id> prints each provider's availability on that machine, and --json includes machineAvailability. Guide template, bb-cli skill, docs/api_to_audit.md, the Plugin Guide surface text, and the SDK doc comment were updated to describe background probing.

No server/daemon wire fields changed, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.

How you verified

  • Server tests in apps/server/test/threads/environment-providers.test.ts rewritten for the new contract: listing answers null first, the background answer is served on the next listing and environment-availability-changed fires once; Git inspection runs in the background and a missing branch is reported as unavailable; disconnected machines are not probed; unmet structural requirements never probe; a plugin recheck invalidates the cache and probes again; a throwing hook is reported as unavailable without failing the listing; creation still checks afresh. 43 passed.
  • App tests: picker hides unavailable rows, keeps the selected unavailable row disabled with its reason, keeps setup-required selectable with its message, hides per machine in the grouped menu; provider query writes and serves the last-known cache and rejects a corrupt entry; realtime registry covers the new system change.
  • CLI test for the availability column with available, unavailable, and unknown rows.
  • pnpm exec turbo run typecheck for server, app, cli, domain, server-contract, sdk, plugin-sdk, plugin-api-map, and templates passes.
  • pnpm exec turbo run test for cli, server-contract, sdk, domain, templates, plugin-api-map, and plugin-sdk passes. Full server and app Vitest suites pass (the app's turbo test task fails before tests on this machine because its PWA icon check needs a libvips module that isn't installed, so the app suite was run with vitest directly).
  • Manual, on the earlier client-only version of this change: a dev server with the btrfs-cow plugin and two projects on one machine, one on btrfs and one on tmpfs; the tmpfs picker omitted CoW copy and was already trimmed on first open after a reload.

AGENT GENERATED

Reinstate per-machine plugin availability for the environment picker
without blocking discovery: listing a project's providers schedules a
background probe per connected machine, serves cached answers through a
new machineAvailability field, and emits an
environment-availability-changed system change when an answer settles.
The picker hides providers a machine reports unavailable, keeps the
selected one visible with its reason, and remembers each project's list
in localStorage so it is trimmed on first open. The CLI prints a
machine's availability with --machine.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/can-we-make-it-so-that-we-can-show-what-machines-thr_6ak45kwi62 branch from 15b2c38 to d94a439 Compare September 10, 2026 21:49
@SawyerHood SawyerHood changed the title Hide unsupported environment providers per machine in the picker Probe environment provider availability per machine in the background Sep 10, 2026
@SawyerHood
SawyerHood merged commit c02aa6f into main Sep 10, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the bb/can-we-make-it-so-that-we-can-show-what-machines-thr_6ak45kwi62 branch September 10, 2026 21:54
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