fix(persistence): serialize autosave generations before queue effects

Track settings input generations so an older asynchronous secret save cannot mark a newer value durable. Commit queue snapshots before cancellation, cleanup, or pause effects so SQLite failures leave runtime processes and files unchanged.
This commit is contained in:
Sucukdeluxe
2026-08-12 00:38:49 +02:00
parent 6f02e9aa3a
commit 421da7be77
5 changed files with 211 additions and 26 deletions
+14
View File
@@ -3,3 +3,17 @@ export function persistStateChange<T>(current: T, createNext: (current: T) => T,
persist(next);
return next;
}
export async function commitQueueMutation<T>(
current: T,
createNext: (current: T) => T,
persist: (next: T) => void,
apply: (next: T) => void,
effects: () => Promise<void>,
): Promise<T> {
const next = createNext(current);
persist(next);
apply(next);
await effects();
return next;
}