Skip to content

Setup Store Not Persisting - Onboarding Repeats Every Launch #334

@RayFernando1337

Description

@RayFernando1337

Bug Description

The setup/onboarding wizard repeats every time the Electron app is launched because the setupComplete state is not being persisted to localStorage.

Reproduction Steps

  1. Run npm run dev:electron
  2. Complete the onboarding/setup wizard
  3. Close the app
  4. Run npm run dev:electron again
  5. Onboarding wizard appears again

Expected Behavior

After completing setup once, setupComplete: true should be persisted and onboarding should be skipped on subsequent launches.

Actual Behavior

localStorage.getItem('automaker-setup') returns null - the Zustand persist middleware is not saving the setup state.

Root Cause

The setup-store.ts uses Zustand's persist middleware but lacks a version field, unlike app-store.ts which has version: 2. This may cause silent hydration failures.

Additionally, the early 401 errors (see related issue) may be interfering with the store's ability to persist.

Affected Files

  • apps/ui/src/store/setup-store.ts (lines 123-184) - persist configuration

Current Code

// setup-store.ts - MISSING version field
persist(
  (set, get) => ({...}),
  {
    name: 'automaker-setup',
    partialize: (state) => ({
      isFirstRun: state.isFirstRun,
      setupComplete: state.setupComplete,
      skipClaudeSetup: state.skipClaudeSetup,
      claudeAuthStatus: state.claudeAuthStatus,
    }),
  }
)

Suggested Fix

Add version field to match the pattern used in app-store.ts:

// setup-store.ts
persist(
  (set, get) => ({...}),
  {
    name: 'automaker-setup',
    version: 1,  // ADD THIS
    partialize: (state) => ({
      isFirstRun: state.isFirstRun,
      setupComplete: state.setupComplete,
      skipClaudeSetup: state.skipClaudeSetup,
      claudeAuthStatus: state.claudeAuthStatus,
    }),
    // Optional: add migrate function for future schema changes
    migrate: (persistedState, version) => {
      return persistedState as SetupState;
    },
  }
)

Workaround

Users can manually set localStorage to skip setup:

localStorage.setItem('automaker-setup', JSON.stringify({
  state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false, claudeAuthStatus: null },
  version: 0
}));

Or use env var: VITE_SKIP_SETUP=true npm run dev:electron

Comparison with app-store.ts

// app-store.ts - HAS version field (line ~2900)
persist(
  (set, get) => ({...}),
  {
    name: 'automaker-storage',
    version: 2,  // <-- setup-store is missing this
    merge: (persistedState, currentState) => {...},
    partialize: (state) => ({...}),
  }
)

Regression

Likely introduced or exposed by PR #321 (protect-api-with-api-key) due to the auth initialization race condition interfering with store hydration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions