Repository navigation
Add bb server install-machine-service - #4174
Merged
SawyerHood merged 1 commit intoSep 23, 2026
Merged
Conversation
After a server moves off a desktop app or bb-app, the old computer stays a machine only while that app runs, and its daemon cannot update itself. `bb server install-machine-service` gives that data directory the persistent, self-updating service a CLI-installed machine gets: it requires a move lock, the machine's auth.json and config.json, and Node.js 22.19+ on the PATH, then stops the bb recorded in bb-app-runtime.json and runs `install-machine.sh --adopt --data-dir <dir>` from the bb-app package (the launcher passes its path to the CLI as BB_MACHINE_INSTALLER). `@bb/config/machine-service` finds the launchd or systemd service that runs a daemon for a data directory. `bb server unlock` uses it to refuse while such a service exists, since unlocking would start a second daemon on the same data. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood
marked this pull request as ready for review
September 23, 2026 17:37
SawyerHood
added a commit
that referenced
this pull request
Sep 23, 2026
…4175) ## Human comments ## What was wrong This is the part that fixes the desktop case directly. After its local server moved, the desktop app ran this computer's daemon through its own bb-app process in moved mode. That process was killed when the app quit and restarted on the next launch, and its bundled daemon never updated itself. So the machine was offline whenever the app was closed, and it dropped off entirely after the next protocol bump on the server. Stacked on #4174, which adds `bb server install-machine-service` and `@bb/config/machine-service`. ## What changed - **Desktop** (`apps/desktop/src/moved-machine-service.ts`, `main.ts`). When the app activates a move, either live or on a later launch, and no machine service exists for its data directory, it does this in the background: - stops its own runtime and runs the bundled `install-machine.sh --adopt`, found through `resolveDesktopMachineInstallerPath` - logs the installer's output to `<data-dir>/logs/install-machine-service.log` - restarts its runtime afterwards - on failure (for example, no Node.js 22.19+), keeps today's app-owned machine, shows one dialog per move with the installer's reason, and tries again on the next launch - move activation no longer waits for the runtime, so app startup isn't blocked by the install - **bb-app moved mode** (`packages/bb-app/src/launcher.ts`): - when a machine service runs the data directory, it doesn't start a host daemon and only answers the old address with the move notice, so neither the desktop app nor `npx bb-app` competes with the service for the daemon lock - without a service, its ready output points at `bb server install-machine-service` - **Docs:** the machines guide template, the bb-cli thread-creation reference, and `docs/server-move-plan.md`. No server/daemon wire change. ## How you verified - `apps/desktop/test/moved-machine-service.test.ts`: - runs a real `/bin/sh` fake installer and checks the arguments, log append, reason from this run's `✗` line, and fallback exit description - existing service → no action - no service → the runtime stops before the install - a failed install is explained once per move - `apps/desktop/test/app-paths.test.ts`: the installer path inside the asar-unpacked `bb-app` package. - `packages/bb-app/test/moved-mode.test.ts`: with a service, moved mode never starts a daemon, keeps the responder, and exits on shutdown. - `pnpm exec turbo run test --filter=bb-app`: 149 passed. - Desktop typecheck passes. Desktop tests pass except two Electron-launch tests that also fail here without this change (`preload-build.test.ts`, SIGABRT launching Electron) or are flaky under load (`electron-builder-config.test.ts` passes alone). - **Not verified:** a packaged desktop app through a real server move. The installer asset ships in the desktop bundle because the desktop-hosted server already serves `/install.sh` from `server/dist/assets`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
After a server moves off
bb-appor the desktop app, there was no supported way to turn the old computer into a persistent, self-updating machine while keeping its identity and threads. The only way to get an auto-updating daemon was to enroll a new machine, and threads can't move or fork onto a different machine.Stacked on #4173, which adds
install-machine.sh --adopt.What changed
bb server install-machine-service [--data-dir <dir>] [--yes] [--json](apps/cli/src/commands/server-machine-service.ts):server-moved.jsonlock,auth.json, a server address inconfig.json, and Node.js 22.19+ on the PATH--yesbb-app-runtime.json, using the same verified stop asbb-app stopinstall-machine.sh --adopt --data-dir <dir>--jsonprintsdataDir,serverUrl,toHostNameandserviceFileserver/dist/assets/install-machine.sh) to the CLI asBB_MACHINE_INSTALLER, the same way it already passesBB_APP_VERSION. The CLI ships its own installer rather than downloading the server's, so people already stuck on an older server can still adopt.@bb/config/machine-service:findMachineServiceFilefinds the launchd plist or systemd unit whoseBB_DATA_DIRmatches a data directory, comparing canonical paths and undoing the installer's escaping.bb server unlockrefuses while such a service exists, because unlocking would start a second daemon on the same data. The error gives the command that removes the service.docs/api_to_audit.md,docs/server-move-plan.md, anddocs/cli-guide-and-skill.md.No server/daemon wire change.
How you verified
apps/cli/src/__tests__/command-output/server-machine-service.test.ts, run with a fake installer against a real live process:--adopt --data-dirnodeon PATH is 20.18.1unlockrefuses while the service existspackages/config/test/machine-service.test.ts: launchd and systemd matching, symlinked data directories, escaping, and no match.packages/bb-app/test/index.test.ts: the CLI receivesBB_MACHINE_INSTALLER.pnpm exec turbo run test --filter=@bb/cli --filter=@bb/templates: 841 + 47 passed.pnpm exec turbo run test --filter=@bb/config --filter=bb-app: passed.@bb/cli,@bb/configandbb-app.🤖 Generated with Claude Code