From d3757f511569cdc0fbb775fb45da2cee01367923 Mon Sep 17 00:00:00 2001 From: Will Pfleger Date: Wed, 22 Jul 2026 14:25:04 -0400 Subject: [PATCH] fix(dev): restore shared worktree identity from keyring (#2400) Signed-off-by: Will Pfleger Co-authored-by: npub1067mpdna4vy22u9eltmmhtdfw56kww6ve2aze025dtfm4pxg07nqztjfhm <7ebdb0b67dab08a570b9faf7bbada97535673b4ccaba2cbd546ad3ba84c87fa6@sprout-oss.stage.blox.sqprod.co> --- scripts/instance-env.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/instance-env.sh b/scripts/instance-env.sh index 53c7cc242..bc185d98f 100755 --- a/scripts/instance-env.sh +++ b/scripts/instance-env.sh @@ -47,14 +47,36 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then # identifier is kept so concurrent instances don't collide on # tauri-plugin-single-instance or the app data directory. if [[ "${BUZZ_SHARE_IDENTITY:-0}" == "1" ]]; then + KEYRING_SERVICE="buzz-desktop-dev" + KEYRING_BLOB="" + case "$(uname -s)" in + Darwin) + if command -v security &>/dev/null; then + KEYRING_BLOB="$(security find-generic-password -s "$KEYRING_SERVICE" -a secrets -w 2>/dev/null || true)" + fi + ;; + Linux) + if command -v secret-tool &>/dev/null; then + KEYRING_BLOB="$(secret-tool lookup service "$KEYRING_SERVICE" username secrets target default 2>/dev/null || true)" + fi + ;; + esac + + KEYRING_IDENTITY="$(printf '%s' "$KEYRING_BLOB" | python3 -c 'import json, sys; value = json.load(sys.stdin).get("identity", ""); print(value if isinstance(value, str) else "")' 2>/dev/null || true)" CANONICAL_KEY="$HOME/Library/Application Support/xyz.block.buzz.app.dev/identity.key" LEGACY_CANONICAL_KEY="$HOME/Library/Application Support/xyz.block.sprout.app.dev/identity.key" - if [[ -f "$CANONICAL_KEY" ]]; then - export BUZZ_PRIVATE_KEY="$(cat "$CANONICAL_KEY")" - elif [[ -f "$LEGACY_CANONICAL_KEY" ]]; then - export BUZZ_PRIVATE_KEY="$(cat "$LEGACY_CANONICAL_KEY")" + + SHARED_IDENTITY="$KEYRING_IDENTITY" + if [[ -z "$SHARED_IDENTITY" && -f "$CANONICAL_KEY" ]]; then + SHARED_IDENTITY="$(cat "$CANONICAL_KEY")" + elif [[ -z "$SHARED_IDENTITY" && -f "$LEGACY_CANONICAL_KEY" ]]; then + SHARED_IDENTITY="$(cat "$LEGACY_CANONICAL_KEY")" + fi + + if [[ -n "$SHARED_IDENTITY" ]]; then + export BUZZ_PRIVATE_KEY="$SHARED_IDENTITY" else - echo "⚠ BUZZ_SHARE_IDENTITY=1 but no identity found at $CANONICAL_KEY or $LEGACY_CANONICAL_KEY — run Buzz from repo root first" >&2 + echo "⚠ BUZZ_SHARE_IDENTITY=1 but no identity found in keyring service $KEYRING_SERVICE, at $CANONICAL_KEY, or at $LEGACY_CANONICAL_KEY — run Buzz from repo root first" >&2 fi fi