feat: restore opt-in first-run onboarding

This commit is contained in:
vorotamoroz
2026-07-20 11:28:41 +00:00
parent f70779c352
commit 52e7bd25da
12 changed files with 511 additions and 40 deletions
@@ -0,0 +1,39 @@
export interface ConfiguredStartupLifecycleRuntime {
databaseReady: boolean;
reportDatabaseNotReady(): void;
hasCompromisedChunks(): Promise<boolean>;
hasIncompleteDocuments(): Promise<boolean>;
runDoctor(): Promise<boolean>;
migrateBulkSend(): Promise<void>;
}
export interface StartupEntryLifecycleRuntime {
configured: boolean;
inviteToOnboarding(): void;
}
/**
* Keeps an unconfigured Vault outside database initialisation and all
* configured-only start-up work while offering an explicit setup action.
*/
export function runStartupEntryLifecycle(runtime: StartupEntryLifecycleRuntime): boolean {
if (runtime.configured) return true;
runtime.inviteToOnboarding();
return false;
}
/**
* Separates the inert, unconfigured startup path from checks which must run
* before an already configured device is allowed to synchronise.
*/
export async function runConfiguredStartupLifecycle(runtime: ConfiguredStartupLifecycleRuntime): Promise<boolean> {
if (!runtime.databaseReady) {
runtime.reportDatabaseNotReady();
return false;
}
if (!(await runtime.hasCompromisedChunks())) return false;
if (!(await runtime.hasIncompleteDocuments())) return false;
if (!(await runtime.runDoctor())) return false;
await runtime.migrateBulkSend();
return true;
}