From 30928fd938ec7039aaf5e33b667cb4897a32f374 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Wed, 8 Oct 2025 23:28:08 -0300 Subject: [PATCH] fix(desktop): ajustar store do agente para build --- apps/desktop/src/main.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 43f2065..838c96a 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -105,23 +105,23 @@ function setStatus(message: string) { } } -const store = new Store(STORE_FILENAME) -let storeLoaded = false +let storeInstance: Store | null = null -async function ensureStoreLoaded() { - if (!storeLoaded) { +async function ensureStoreLoaded(): Promise { + if (!storeInstance) { try { - await store.load() + storeInstance = await Store.load(STORE_FILENAME) } catch (error) { console.error("[agent] Falha ao carregar store", error) + throw error } - storeLoaded = true } + return storeInstance } async function loadConfig(): Promise { try { - await ensureStoreLoaded() + const store = await ensureStoreLoaded() const record = await store.get("config") if (!record) return null return record @@ -132,13 +132,13 @@ async function loadConfig(): Promise { } async function saveConfig(config: AgentConfig) { - await ensureStoreLoaded() + const store = await ensureStoreLoaded() await store.set("config", config) await store.save() } async function clearConfig() { - await ensureStoreLoaded() + const store = await ensureStoreLoaded() await store.delete("config") await store.save() }