Skip to content

Fix SPROUT_SHARE_IDENTITY worktree dev workflow breaks#702

Merged
wpfleger96 merged 3 commits into
mainfrom
fix/share-identity-worktree-onboarding
May 21, 2026
Merged

Fix SPROUT_SHARE_IDENTITY worktree dev workflow breaks#702
wpfleger96 merged 3 commits into
mainfrom
fix/share-identity-worktree-onboarding

Conversation

@wpfleger96
Copy link
Copy Markdown
Collaborator

@wpfleger96 wpfleger96 commented May 21, 2026

Two UX breaks made SPROUT_SHARE_IDENTITY=1 unusable for testing feature branches against the staging relay: every fresh worktree showed the WelcomeSetup screen (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 its localStorage from the main checkout. SPROUT_SHARE_IDENTITY=1 bridges the Nostr private key but nothing bridged workspace config or the onboarding completion marker.

Rust:

  • is_shared_identity() requires both SPROUT_SHARE_IDENTITY=1 AND a parseable nostr key in SPROUT_PRIVATE_KEY — prevents auto-skipping onboarding when the flag is set but no key was actually shared (e.g. missing identity.key)

Frontend — single IPC call, gated render:

  • App.tsx queries is_shared_identity once on mount and gates all child rendering until the call resolves, eliminating the flash-of-WelcomeSetup race where children briefly saw isSharedIdentity=false
  • The resolved boolean is threaded as a prop to useWorkspaceInit and AppReady — no more double IPC calls or silent .catch(() => {})

Workspace auto-setup (useWorkspaceInit):

  • When shared identity and no workspace in localStorage, auto-creates one from defaultRelayUrl and reloads — no WelcomeSetup interaction needed
  • cancelled guards before window.location.reload() and preceding localStorage writes prevent writes after unmount

Onboarding fast-path (useFirstRunOnboardingGate):

  • Shared-identity fast-path moved before the hasSettledCurrentPubkey guard, so it runs regardless of identity error state
  • Guarded by !hasCompletedCurrentPubkey (fires exactly once) instead of the old guard that allowed infinite re-entry

Dedup:

  • Extracted initFirstWorkspace(relayUrl, pubkey) in workspaceStorage.ts — used by both useWorkspaceInit and WelcomeSetup, replacing duplicated normalize→construct→save logic

No behavior change for end users or developers not using SPROUT_SHARE_IDENTITY=1.

@wpfleger96 wpfleger96 requested a review from a team as a code owner May 21, 2026 20:52
@wpfleger96 wpfleger96 force-pushed the fix/share-identity-worktree-onboarding branch from c0e80a5 to 38d5342 Compare May 21, 2026 20:55
…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.
@wpfleger96 wpfleger96 force-pushed the fix/share-identity-worktree-onboarding branch from 374af16 to 5750e16 Compare May 21, 2026 21:41
@wpfleger96 wpfleger96 merged commit 091e38f into main May 21, 2026
15 checks passed
@wpfleger96 wpfleger96 deleted the fix/share-identity-worktree-onboarding branch May 21, 2026 21:53
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