Fix SPROUT_SHARE_IDENTITY worktree dev workflow breaks#702
Merged
Conversation
c0e80a5 to
38d5342
Compare
…ntity worktrees SPROUT_SHARE_IDENTITY=1 shares the Nostr private key across worktrees but each worktree gets a unique Tauri identifier, isolating localStorage. This left two gaps: no workspace config (forcing WelcomeSetup on every new worktree) and no onboarding completion marker (forcing re-onboarding despite the user already having a profile on the relay). Add an is_shared_identity Tauri command that exposes the env var to the frontend. When true, useWorkspaceInit auto-creates a workspace from the default relay URL (mirroring WelcomeSetup.handleConnect) and the onboarding gate writes the completion marker immediately after the identity query succeeds, bypassing the fragile relay profile check.
The initial implementation (38d5342) auto-skipped onboarding for shared-identity worktrees but had several issues surfaced by review: is_shared_identity() returned true without a valid key, double IPC calls raced with stale initial state, the onboarding effect allowed infinite re-entry, and cancelled guards were missing before window.location.reload(). Strengthen is_shared_identity() to require both SPROUT_SHARE_IDENTITY=1 and a parseable SPROUT_PRIVATE_KEY. Hoist the IPC call to App.tsx and gate rendering until it resolves, eliminating the flash-of-WelcomeSetup race. Restructure the onboarding effect so the shared-identity fast-path runs before the hasSettledCurrentPubkey guard with a once-guard on hasCompletedCurrentPubkey. Extract initFirstWorkspace() to deduplicate workspace creation between useWorkspaceInit and WelcomeSetup.
374af16 to
5750e16
Compare
This was referenced May 28, 2026
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.
Two UX breaks made
SPROUT_SHARE_IDENTITY=1unusable for testing feature branches against the staging relay: every fresh worktree showed theWelcomeSetupscreen (requiring a manual "Connect to Stage" click), and after connecting, the onboarding gate fired again despite the profile already existing on the relay.Root cause: each worktree gets a unique Tauri app identifier (
xyz.block.sprout.app.dev.{slug}), which fully isolates itslocalStoragefrom the main checkout.SPROUT_SHARE_IDENTITY=1bridges the Nostr private key but nothing bridged workspace config or the onboarding completion marker.Rust:
is_shared_identity()requires bothSPROUT_SHARE_IDENTITY=1AND a parseable nostr key inSPROUT_PRIVATE_KEY— prevents auto-skipping onboarding when the flag is set but no key was actually shared (e.g. missingidentity.key)Frontend — single IPC call, gated render:
App.tsxqueriesis_shared_identityonce on mount and gates all child rendering until the call resolves, eliminating the flash-of-WelcomeSetup race where children briefly sawisSharedIdentity=falseuseWorkspaceInitandAppReady— no more double IPC calls or silent.catch(() => {})Workspace auto-setup (
useWorkspaceInit):localStorage, auto-creates one fromdefaultRelayUrland reloads — noWelcomeSetupinteraction neededcancelledguards beforewindow.location.reload()and precedinglocalStoragewrites prevent writes after unmountOnboarding fast-path (
useFirstRunOnboardingGate):hasSettledCurrentPubkeyguard, so it runs regardless of identity error state!hasCompletedCurrentPubkey(fires exactly once) instead of the old guard that allowed infinite re-entryDedup:
initFirstWorkspace(relayUrl, pubkey)inworkspaceStorage.ts— used by bothuseWorkspaceInitandWelcomeSetup, replacing duplicated normalize→construct→save logicNo behavior change for end users or developers not using
SPROUT_SHARE_IDENTITY=1.