From e802f1c9f618bfa31d4e8f72c37cc8ec234edce5 Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 16:28:53 -0400 Subject: [PATCH 1/5] feat(dev): support descriptive worktree labels Signed-off-by: John Tennant --- scripts/instance-env.sh | 9 ++++++-- scripts/test-instance-env.sh | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 scripts/test-instance-env.sh diff --git a/scripts/instance-env.sh b/scripts/instance-env.sh index bc185d98f18..f1b4300910d 100755 --- a/scripts/instance-env.sh +++ b/scripts/instance-env.sh @@ -39,8 +39,13 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then GIT_COMMON_DIR=$(git rev-parse --git-common-dir 2>/dev/null) if [[ -n "$GIT_COMMON_DIR" && "$GIT_DIR" != "$GIT_COMMON_DIR" ]]; then BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) - export BUZZ_WORKTREE_LABEL="${BRANCH_NAME##*/}" - export BUZZ_INSTANCE_SLUG=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//') + export BUZZ_WORKTREE_LABEL="${BUZZ_DEV_LABEL:-${BRANCH_NAME##*/}}" + INSTANCE_IDENTITY="${BUZZ_DEV_LABEL:-$BRANCH_NAME}" + export BUZZ_INSTANCE_SLUG=$(echo "$INSTANCE_IDENTITY" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//') + if [[ -z "$BUZZ_INSTANCE_SLUG" ]]; then + echo "BUZZ_DEV_LABEL must contain at least one letter or number" >&2 + return 1 2>/dev/null || exit 1 + fi # BUZZ_SHARE_IDENTITY=1: reuse the main dev checkout's Nostr key so # worktrees skip onboarding and share the same identity. The per-worktree diff --git a/scripts/test-instance-env.sh b/scripts/test-instance-env.sh new file mode 100755 index 00000000000..9e31a0ed23f --- /dev/null +++ b/scripts/test-instance-env.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +test_root=$(mktemp -d) +trap 'rm -rf "$test_root"' EXIT + +mkdir -p "$test_root/bin" "$test_root/checkout/desktop/src-tauri/icons" +touch "$test_root/checkout/desktop/src-tauri/icons/icon.icns" + +cat >"$test_root/bin/git" <"$test_root/bin/swift" <<'EOF' +#!/usr/bin/env bash +mkdir -p "$(dirname "$3")" +touch "$3" +EOF +chmod +x "$test_root/bin/swift" + +result=$( + PATH="$test_root/bin:$PATH" + BUZZ_DEV_LABEL="voice route fix" + BUZZ_SHARE_IDENTITY=0 + source "$repo_root/scripts/instance-env.sh" + printf '%s\n%s\n%s\n' \ + "$BUZZ_WORKTREE_LABEL" "$BUZZ_INSTANCE_SLUG" "$BUZZ_TAURI_CONFIG" +) + +[[ "$result" == *$'voice route fix\nvoice-route-fix\n'* ]] +[[ "$result" == *'Buzz Dev (voice route fix)'* ]] + +echo "instance-env tests passed" From 1af1b386ed5e423bc08c8ff83daae41d260515f4 Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 16:33:05 -0400 Subject: [PATCH 2/5] test(dev): cover worktree label contract Signed-off-by: John Tennant --- .github/workflows/ci.yml | 2 ++ scripts/instance-env.sh | 3 ++- scripts/test-instance-env.sh | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44966c28de6..fcf3384239c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,6 +89,8 @@ jobs: scripts/test-mobile-release-candidate-publisher.sh - name: Mobile worktree identity contract run: scripts/test-mobile-worktree-overrides.sh + - name: Desktop worktree identity contract + run: scripts/test-instance-env.sh - name: Codex security review contract run: just security-review-check - name: Rust cache contract diff --git a/scripts/instance-env.sh b/scripts/instance-env.sh index f1b4300910d..f926c74dc31 100755 --- a/scripts/instance-env.sh +++ b/scripts/instance-env.sh @@ -46,6 +46,7 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then echo "BUZZ_DEV_LABEL must contain at least one letter or number" >&2 return 1 2>/dev/null || exit 1 fi + WORKTREE_PRODUCT_NAME=$(python3 -c 'import json,sys; print(json.dumps(f"Buzz Dev ({sys.argv[1]})"))' "$BUZZ_WORKTREE_LABEL") # BUZZ_SHARE_IDENTITY=1: reuse the main dev checkout's Nostr key so # worktrees skip onboarding and share the same identity. The per-worktree @@ -94,7 +95,7 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then if swift "$GENERATE_DEV_ICON" "$BASE_ICON" "$DEV_ICON" "$BUZZ_WORKTREE_LABEL"; then echo "🌳 Worktree: ${BUZZ_WORKTREE_LABEL}" export VITE_DEV_BRANCH="$BUZZ_WORKTREE_LABEL" - BUZZ_TAURI_CONFIG="{\"build\":{\"devUrl\":\"${DEV_URL}\",\"beforeDevCommand\":\"exec ./node_modules/.bin/vite --port ${BUZZ_VITE_PORT} --strictPort\"},\"identifier\":\"xyz.block.buzz.app.dev.${BUZZ_INSTANCE_SLUG}\",\"productName\":\"Buzz Dev (${BUZZ_WORKTREE_LABEL})\",\"bundle\":{\"icon\":[\"$DEV_ICON\"]}}" + BUZZ_TAURI_CONFIG="{\"build\":{\"devUrl\":\"${DEV_URL}\",\"beforeDevCommand\":\"exec ./node_modules/.bin/vite --port ${BUZZ_VITE_PORT} --strictPort\"},\"identifier\":\"xyz.block.buzz.app.dev.${BUZZ_INSTANCE_SLUG}\",\"productName\":${WORKTREE_PRODUCT_NAME},\"bundle\":{\"icon\":[\"$DEV_ICON\"]}}" fi fi fi diff --git a/scripts/test-instance-env.sh b/scripts/test-instance-env.sh index 9e31a0ed23f..181d0faceb3 100755 --- a/scripts/test-instance-env.sh +++ b/scripts/test-instance-env.sh @@ -30,14 +30,15 @@ chmod +x "$test_root/bin/swift" result=$( PATH="$test_root/bin:$PATH" - BUZZ_DEV_LABEL="voice route fix" + BUZZ_DEV_LABEL='voice "route" \ fix' BUZZ_SHARE_IDENTITY=0 source "$repo_root/scripts/instance-env.sh" printf '%s\n%s\n%s\n' \ "$BUZZ_WORKTREE_LABEL" "$BUZZ_INSTANCE_SLUG" "$BUZZ_TAURI_CONFIG" ) -[[ "$result" == *$'voice route fix\nvoice-route-fix\n'* ]] -[[ "$result" == *'Buzz Dev (voice route fix)'* ]] +[[ "$result" == *$'voice "route" \ fix\nvoice-route-fix\n'* ]] +config=$(printf '%s\n' "$result" | tail -1) +[[ "$(node -e 'const c=JSON.parse(process.argv[1]); process.stdout.write(c.productName)' "$config")" == 'Buzz Dev (voice "route" \ fix)' ]] echo "instance-env tests passed" From e576cb7fde8ca23fa546ba85281d955d2dc1ad7e Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 16:37:46 -0400 Subject: [PATCH 3/5] test(dev): run worktree label contract with unit tests Signed-off-by: John Tennant --- .github/workflows/ci.yml | 2 -- Justfile | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b821101d7d8..5d59712a822 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,8 +89,6 @@ jobs: scripts/test-mobile-release-candidate-publisher.sh - name: Mobile worktree identity contract run: scripts/test-mobile-worktree-overrides.sh - - name: Desktop worktree identity contract - run: scripts/test-instance-env.sh - name: Codex security review contract run: just security-review-check - name: Rust cache contract diff --git a/Justfile b/Justfile index 359e5f16b46..6005f2169f3 100644 --- a/Justfile +++ b/Justfile @@ -314,6 +314,7 @@ test: test-unit: #!/usr/bin/env bash set -euo pipefail + ./scripts/test-instance-env.sh ./scripts/test-ensure-local-relay-key.sh if command -v cargo-nextest &>/dev/null; then cargo nextest run -p buzz-core -p buzz-auth --lib From 4453b6c00c7483740b7ff726f414358db4a242c5 Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 16:40:49 -0400 Subject: [PATCH 4/5] test(dev): run worktree label contract in CI Signed-off-by: John Tennant --- .github/workflows/ci.yml | 2 ++ Justfile | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d59712a822..b821101d7d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,6 +89,8 @@ jobs: scripts/test-mobile-release-candidate-publisher.sh - name: Mobile worktree identity contract run: scripts/test-mobile-worktree-overrides.sh + - name: Desktop worktree identity contract + run: scripts/test-instance-env.sh - name: Codex security review contract run: just security-review-check - name: Rust cache contract diff --git a/Justfile b/Justfile index 6005f2169f3..359e5f16b46 100644 --- a/Justfile +++ b/Justfile @@ -314,7 +314,6 @@ test: test-unit: #!/usr/bin/env bash set -euo pipefail - ./scripts/test-instance-env.sh ./scripts/test-ensure-local-relay-key.sh if command -v cargo-nextest &>/dev/null; then cargo nextest run -p buzz-core -p buzz-auth --lib From f06a2c0e537c23c32670589e0b4b518c621e691f Mon Sep 17 00:00:00 2001 From: John Tennant Date: Mon, 31 Aug 2026 16:42:14 -0400 Subject: [PATCH 5/5] test(dev): include worktree identity in desktop contracts Signed-off-by: John Tennant --- .github/workflows/ci.yml | 2 -- scripts/test-desktop-release-candidate.sh | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b821101d7d8..5d59712a822 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,8 +89,6 @@ jobs: scripts/test-mobile-release-candidate-publisher.sh - name: Mobile worktree identity contract run: scripts/test-mobile-worktree-overrides.sh - - name: Desktop worktree identity contract - run: scripts/test-instance-env.sh - name: Codex security review contract run: just security-review-check - name: Rust cache contract diff --git a/scripts/test-desktop-release-candidate.sh b/scripts/test-desktop-release-candidate.sh index 503c64eb37d..4b8fa69120c 100755 --- a/scripts/test-desktop-release-candidate.sh +++ b/scripts/test-desktop-release-candidate.sh @@ -225,4 +225,6 @@ root_sha=$(git -C "$initial" rev-parse HEAD) grep -Fq "$root_sha" "$initial/CHANGELOG.md" rm -rf "$initial" +"$repo_root/scripts/test-instance-env.sh" + echo "desktop release candidate contract passed"