Skip to content

fix(onboarding): restore user state on warm start#71

Open
acslater00 wants to merge 1 commit intomasterfrom
acslater00/fix-warm-start-onboarding
Open

fix(onboarding): restore user state on warm start#71
acslater00 wants to merge 1 commit intomasterfrom
acslater00/fix-warm-start-onboarding

Conversation

@acslater00
Copy link
Copy Markdown

Summary

  • restore authenticated user state during preflight when a valid token already exists
  • carry that user through PreflightResolved into bootstrap state so sync completion can transition to chat
  • add a regression test covering the warm-start preflight path

Why

Warm starts could reach PowerSync Ready and then stall in onboarding. The root cause was that the fresh auth path populated bootstrap.State.User, but the preflight path only restored auth validity plus org/account state. After sync completed, onboarding rejected completion because User was still nil.

Implementation details

  • extend bootstrap.PreflightState with an optional User
  • in onboarding preflight, call GetUserID() after validating the access token and attach a minimal auth.User{ID: ...}
  • update ApplyPreflight to copy that user into bootstrap state
  • add a transition test asserting PreflightResolved carries user state forward

Verification

  • reproduced the bug locally by authenticating once, quitting, and launching again
  • confirmed logs showed sync completed without required onboarding state has_user=false ...
  • full go test was not runnable in this environment because the sandbox could not reach proxy.golang.org to fetch modules

Risk

  • low: this only affects the already-authenticated preflight path and only adds user hydration from the existing token
  • auth.User is populated minimally with ID because warm-start completion only requires presence of the user object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant