Skip to content

refactor(justfile): rename, relay auto-start, bootstrap, DRY cleanup#1117

Merged
wpfleger96 merged 4 commits into
mainfrom
worktree-wpfleger+justfile-refactor
Jun 18, 2026
Merged

refactor(justfile): rename, relay auto-start, bootstrap, DRY cleanup#1117
wpfleger96 merged 4 commits into
mainfrom
worktree-wpfleger+justfile-refactor

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Rewrites the Justfile (renamed from justfile) with four categories of improvement: relay integration, prerequisite bootstrapping, correctness fixes, and housekeeping.

Relay auto-start in just dev

just dev previously started the desktop app with no relay, leaving new users with an app that had nowhere to connect. It now builds buzz-relay as part of the existing cargo build step, starts ./target/debug/buzz-relay in the background before launching Tauri, and kills it cleanly on exit. The relay URL defaults to ws://localhost:3000 via scripts/instance-env.sh — nothing new to configure.

just bootstrap — idempotent prerequisite installer

New recipe that prepends hermit's bin/ to PATH and invokes cargo, node, and pnpm --version to trigger hermit's lazy tool download. Also copies .env.example.env if .env is absent. Safe to re-run; subsequent calls complete in ~1s when tools are already cached. Wired as a first prerequisite of setup, dev, staging, relay, and relay-web so those recipes work correctly even when hermit hasn't been activated in the parent shell.

Relay lifecycle correctness (from code review)

Three bugs in the original relay-start implementation, all fixed:

  • Relay leaked if pnpm install, source instance-env.sh, or the INSTANCE_ID node command exited non-zero before the EXIT trap was registered — fixed by registering a partial relay-only trap immediately after RELAY_PID=$! and upgrading it once INSTANCE_ID is available
  • cargo run -p buzz-relay & captured cargo's PID rather than the relay binary's PID (cargo doesn't always exec() into its child on macOS) — fixed by including buzz-relay in the explicit cargo build step and launching ./target/debug/buzz-relay & directly, following the pattern in scripts/e2e-relay-membership.sh
  • cleanup-instance-agents.sh failing in the trap could abort before kill "$RELAY_PID" ran — fixed with || true

DRY cleanup and housekeeping

  • migrate is now a public alias for _ensure-migrations (removes the duplicate cargo run -p buzz-admin -- migrate)
  • staging trap gains || true on the cleanup script call, matching dev's defensive style
  • goose and goose-bg share their 14-line setup block via new scripts/_goose-env.sh (sourced by both)
  • Comments added to _ensure-sidecar-stubs and desktop-release-build noting their shared binary list must stay in sync; staging and desktop-release-build get comments explaining their unconditional pnpm install
  • Section reorganization: reindex-kind0 → Utilities; desktop-screenshot, mesh-e2e, mesh-e2e-hardware → Test
  • README and CONTRIBUTING updated: cp .env.example .env removed from setup steps (handled by just bootstrap), "Every day" flow updated to just dev as a single command, split-terminal alternative documented

just dev now runs the relay in the background (redirected to a tmp log)
so new users can spin up both the relay and desktop app with one command.
Also adds _ensure-migrations as a prerequisite so Docker services and
migrations are guaranteed before anything starts.

Minor cleanup to just staging: BUZZ_RELAY_URL is now exported before
sourcing instance-env.sh, letting the default substitution skip rather
than firing and being immediately overridden.
Removing the mktemp redirection — relay stdout/stderr now flow to the
same terminal as Tauri/Vite, making startup errors immediately visible.
Three code-review bugs, all in the relay startup sequence:

1. Relay leaked on set -e exit before trap registration: install a
   partial relay-only trap immediately after RELAY_PID=$!, then upgrade
   it to the full cleanup once INSTANCE_ID is available.

2. cleanup-instance-agents.sh failure could abort the trap body before
   kill $RELAY_PID ran: add || true after the script call.

3. cargo run -p buzz-relay & had two problems: it triggered a separate
   background compile (buzz-relay was absent from the explicit build
   step) and captured cargo's PID rather than the relay binary's PID,
   making the kill unreliable on macOS where cargo doesn't exec() into
   the child. Follow the pattern from scripts/e2e-relay-membership.sh
   and e2e-git-perms.sh: add buzz-relay to the explicit cargo build and
   launch ./target/debug/buzz-relay & directly.
@wpfleger96 wpfleger96 changed the title refactor(justfile): rename to Justfile and auto-start relay in just dev refactor(justfile): rename, relay auto-start, bootstrap, DRY cleanup Jun 18, 2026
@wpfleger96 wpfleger96 force-pushed the worktree-wpfleger+justfile-refactor branch from e3881cf to c671846 Compare June 18, 2026 19:46
… updates

bootstrap recipe (idempotent, safe to re-run):
- Prepends hermit's bin/ to PATH so tools resolve correctly regardless
  of whether the user has sourced bin/activate-hermit in their shell
- Copies .env.example → .env if .env is absent
- Invokes cargo/node/pnpm --version to trigger hermit lazy downloads

Wired into entry-point recipes (setup, dev, staging, relay, relay-web);
each of those recipe bodies also gets `export PATH=.../bin:$PATH` since
just runs each recipe in a separate subprocess.

DRY / consistency fixes:
- migrate is now a public alias for _ensure-migrations (removes duplicate
  cargo run -p buzz-admin invocation)
- staging trap gains || true on cleanup-instance-agents.sh call, matching
  the defensive style already used in dev
- goose and goose-bg share their 14-line setup block via new
  scripts/_goose-env.sh (sourced by both; sets env_args array)
- _ensure-sidecar-stubs and desktop-release-build get comments noting
  their shared binary list must stay in sync
- staging and desktop-release-build get comments documenting why pnpm
  install is unconditional in those recipes

Section reorganization (cosmetic, no logic changes):
- reindex-kind0 moved from Build & Check → Utilities
- desktop-screenshot, mesh-e2e, mesh-e2e-hardware moved from
  Build & Check → Test

Docs:
- README quick-start removes manual cp .env.example .env (handled by
  just setup) and updates "Every day" flow: just dev now starts both the
  relay and desktop in one command; mentions split-terminal alternative
- CONTRIBUTING first-time setup and relay sections updated to match
@wpfleger96 wpfleger96 force-pushed the worktree-wpfleger+justfile-refactor branch from c671846 to 85c5670 Compare June 18, 2026 20:41
@wpfleger96 wpfleger96 merged commit 1dc4fb5 into main Jun 18, 2026
26 checks passed
@wpfleger96 wpfleger96 deleted the worktree-wpfleger+justfile-refactor branch June 18, 2026 21:24
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