Add production-style worktree start command - #2045
Conversation
|
🚨 SLOP COP 🚨 · Plain-English summary: This PR adds a command that starts a worktree with production-style settings. I am SlopCop. I am reviewing this PR for security, code quality, performance, reuse, and end-to-end behavior. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: This PR adds a worktree start command. It builds production files and starts BB with worktree data and ports.
I found two important defects and one small documentation gap.
-
High — Saved settings can defeat the worktree rules.
The wrapper sets worktree data, worktree ports, and disabled telemetry. The production launcher then loads saved settings over those values.
A saved setting can select other data or ports. It can also enable telemetry or restore
BB_DEV_APP_PORT.Apply a typed worktree policy after all saved settings load. Test the final launcher state with conflicting saved values.
-
Medium — A direct stop during the build leaves child processes alive.
The wrapper sends
SIGTERMtostart-bb.mjsonly. That script does not send the signal to its active Turbo child.We reproduced this result during a forced build. Turbo and Vite continued under PID 1 after the wrapper stopped.
Forward stop signals through the full process tree. Add a process test that checks every child after
SIGTERM. -
Low — The support list omits the new command.
docs/platform-support.mdlists onlypnpm startfor source checkout startup. Addpnpm start:worktreeto that support entry.
The design reuses toDevProcessEnv, scripts/start-bb.mjs, and runScriptProcess. I found no duplicate implementation that needs a separate refactor.
The focused Turbo tests passed all 95 tests. The scripts typecheck and format checks passed.
The end-to-end run returned HTTP 200. Doobie loaded the bb page and showed the new-thread interface.
All continuous-integration checks passed. All test processes stopped, and the worktree stayed clean.
I posted this review as a comment. I did not use an approval or change-request action.
|
Addressed all SlopCop findings in
Focused typechecks pass. |
What was wrong
Production-bundle QA required choosing between the convenient worktree isolation of
pnpm devand the production build/serving behavior ofpnpm start. The dev launcher already derived stable checkout-specific data and ports, but only launched the Vite development server; the production launcher used the desired optimized, same-origin bundle path without applying those worktree selectors.What changed
pnpm start:worktree, which reuses the development dotenv cascade and checkout-specific data/server/host-daemon selectors before invoking the existing production-style source launcher.config.json/env.jsonsettings are loaded, locking the worktree data directory, ports, inherited skills, listener host, absent Vite port, and disabled telemetry.start-bb.mjsbuild children lead process groups and forward SIGINT/SIGTERM with leader-first shutdown and escalation, waiting until descendant processes are gone.HOST_DAEMON_PROTOCOL_VERSIONis unchanged.How you verified
pnpm exec turbo run typecheck --filter=@bb/scripts --filter=bb-apppnpm exec turbo run test --filter=@bb/scripts --filter=bb-app --force(@bb/scripts: 18 files/97 tests;bb-app: 1 file/65 tests)pnpm exec prettier scripts/start-bb.mjs packages/bb-app/src/launcher.ts packages/bb-app/src/index.ts packages/bb-app/test/index.test.ts packages/scripts/src/commands/run-dev.ts packages/scripts/test/run-dev.test.ts packages/scripts/test/start-bb.test.mjs docs/configuration.md docs/platform-support.md --checkBB_TELEMETRY=false pnpm start:worktree, fetched the worktree server URL, and confirmed it returned hashed/assets/*.jsproduction bundles with no Vite client or source-module entry. Ctrl-C stopped both listeners.Fixes #2044