mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-28 20:44:50 +02:00
defluff (frontend + backend): strip em-dashes + shorten docstrings + drop dead UI files (cosmetic only, no schedule code)
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
// One-shot launch-time migrations. Runs synchronously before React
|
||||
// mounts so any state-reset takes effect before the first selector
|
||||
// reads it.
|
||||
//
|
||||
// Each migration is gated by a localStorage flag so it only runs once
|
||||
// per install. Adding a new migration:
|
||||
// 1. Append a new entry to MIGRATIONS below with a unique `key`.
|
||||
// 2. The `run` function should be idempotent in case the flag check
|
||||
// races with a parallel reload.
|
||||
// Runs synchronously before React mounts so state-resets land before the first selector read.
|
||||
// Each migration is gated by a localStorage flag so it runs once per install; keep `run` idempotent.
|
||||
|
||||
interface Migration {
|
||||
/** Stable localStorage key. Never reused. */
|
||||
key: string;
|
||||
/** Human-readable description for telemetry / logs. */
|
||||
description: string;
|
||||
run: () => void;
|
||||
}
|
||||
@@ -19,37 +10,20 @@ interface Migration {
|
||||
const MIGRATIONS: Migration[] = [
|
||||
{
|
||||
key: 'openswarm.migrations.v131_force_relogin_and_reonboard',
|
||||
description:
|
||||
'1.0.31 — force every user to sign in again and walk the new ' +
|
||||
'onboarding flow, regardless of prior state',
|
||||
description: '1.0.31: force re-login and re-walk onboarding, regardless of prior state',
|
||||
run: () => {
|
||||
try {
|
||||
// Clear the persisted auth token. SignInGate will see no token
|
||||
// and show the sign-in screen on next render. Electron's main
|
||||
// process still has a copy, but the renderer will refetch via
|
||||
// IPC after the user re-authenticates.
|
||||
window.localStorage.removeItem('openswarm.auth.token');
|
||||
// Clear onboarding-v2 state so the tour starts fresh from
|
||||
// step 1 even for users who completed it on a prior version.
|
||||
// The slice's loadFromStorage() will return null on next
|
||||
// mount and init() will fire with a clean slate.
|
||||
window.localStorage.removeItem('openswarm.onboarding.v2');
|
||||
// Also clear the legacy v1 onboarding flag so v1.0.29-era
|
||||
// users who never opened v2 get the new flow too.
|
||||
window.localStorage.removeItem('openswarm_onboarding_seen');
|
||||
} catch {
|
||||
// localStorage can throw in private mode / quota-exceeded —
|
||||
// non-fatal, user will just keep prior state.
|
||||
// localStorage can throw in private mode / quota-exceeded; non-fatal.
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Run any migrations that haven't fired on this install yet. Idempotent;
|
||||
* safe to call on every launch. Errors in individual migrations don't
|
||||
* block subsequent ones.
|
||||
*/
|
||||
/** Run migrations that haven't fired on this install yet. Idempotent. */
|
||||
export function runStartupMigrations(): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
for (const m of MIGRATIONS) {
|
||||
|
||||
Reference in New Issue
Block a user