From b7cde589e471573a32d71924efe93e121d5a096e Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Thu, 29 Oct 2026 09:14:53 +0100 Subject: [PATCH] ui: request persistent storage on startup (#31299) Ask the browser to keep IndexedDB and localStorage data under storage pressure, so conversations and settings are less likely to be evicted. Assisted-by: Claude (Opus 5.5 Medium) --- tools/ui/src/lib/stores/init.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/ui/src/lib/stores/init.ts b/tools/ui/src/lib/stores/init.ts index ce2dcfbd0..4473349f9 100644 --- a/tools/ui/src/lib/stores/init.ts +++ b/tools/ui/src/lib/stores/init.ts @@ -11,12 +11,25 @@ import { validateApiKey } from '$lib/utils/api-key-validation'; let startup: Promise | null = null; +/** Ask the browser not to evict conversations and settings under storage pressure, best effort. */ +async function requestPersistentStorage(): Promise { + try { + if (!navigator.storage?.persist || (await navigator.storage.persisted())) return; + + await navigator.storage.persist(); + } catch { + // unsupported or denied, storage stays best-effort + } +} + export function initStores(): Promise { if (!browser) return Promise.resolve(); startup ??= (async () => { await MigrationService.runAllMigrations(); + void requestPersistentStorage(); + settingsStore.initialize(); permissionsStore.initialize(); toolsStore.initialize();