auto-claude: subtask-5-1 - Add settings migration logic - set onboardingCompleted

Add migration logic in settings-store.ts to automatically set
onboardingCompleted=true for existing users. The migration checks if:
- globalClaudeOAuthToken is configured
- autoBuildPath is configured

If either condition is true, the user is considered an existing user
and will skip the onboarding wizard. New users (no tokens or paths
configured) will have onboardingCompleted set to false.

The migration runs during loadSettings() and persists the change
if the onboardingCompleted value was previously undefined.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
AndyMik90
2025-12-15 17:34:28 +01:00
parent 9144e7fa86
commit f57c28e5d8
@@ -31,6 +31,34 @@ export const useSettingsStore = create<SettingsState>((set) => ({
setError: (error) => set({ error }) setError: (error) => set({ error })
})); }));
/**
* Check if settings need migration for onboardingCompleted flag.
* Existing users (with tokens or projects configured) should have
* onboardingCompleted set to true to skip the onboarding wizard.
*/
function migrateOnboardingCompleted(settings: AppSettings): AppSettings {
// Only migrate if onboardingCompleted is undefined (not explicitly set)
if (settings.onboardingCompleted !== undefined) {
return settings;
}
// Check for signs of an existing user:
// - Has a Claude OAuth token configured
// - Has the auto-build source path configured
const hasOAuthToken = Boolean(settings.globalClaudeOAuthToken);
const hasAutoBuildPath = Boolean(settings.autoBuildPath);
const isExistingUser = hasOAuthToken || hasAutoBuildPath;
if (isExistingUser) {
// Mark onboarding as completed for existing users
return { ...settings, onboardingCompleted: true };
}
// New user - set to false to trigger onboarding wizard
return { ...settings, onboardingCompleted: false };
}
/** /**
* Load settings from main process * Load settings from main process
*/ */
@@ -41,7 +69,16 @@ export async function loadSettings(): Promise<void> {
try { try {
const result = await window.electronAPI.getSettings(); const result = await window.electronAPI.getSettings();
if (result.success && result.data) { if (result.success && result.data) {
store.setSettings(result.data); // Apply migration for onboardingCompleted flag
const migratedSettings = migrateOnboardingCompleted(result.data);
store.setSettings(migratedSettings);
// If migration changed the settings, persist them
if (migratedSettings.onboardingCompleted !== result.data.onboardingCompleted) {
await window.electronAPI.saveSettings({
onboardingCompleted: migratedSettings.onboardingCompleted
});
}
} }
} catch (error) { } catch (error) {
store.setError(error instanceof Error ? error.message : 'Failed to load settings'); store.setError(error instanceof Error ? error.message : 'Failed to load settings');