diff --git a/src/auth/setup-ui.tsx b/src/auth/setup-ui.tsx index 444f733..79f6e00 100644 --- a/src/auth/setup-ui.tsx +++ b/src/auth/setup-ui.tsx @@ -100,6 +100,10 @@ export function SetupUI({ onComplete }: SetupUIProps) { tokenExpiresAt: now + tokens.expires_in * 1000, }); + // Wait for all pending writes (keychain, disk) to complete before continuing + // This prevents a race condition where main() validation runs before tokens are persisted + await settingsManager.flush(); + setMode("done"); setTimeout(() => onComplete(), 1000); } catch (err) {