diff --git a/src/plugins/built-in/globalSearch/src/core/index.ts b/src/plugins/built-in/globalSearch/src/core/index.ts index c86d9f34..a4b58b61 100644 --- a/src/plugins/built-in/globalSearch/src/core/index.ts +++ b/src/plugins/built-in/globalSearch/src/core/index.ts @@ -14,6 +14,7 @@ import { initVectorSearch } from "../search/vector/vectorSearch"; import { cleanupSearchBar, mountSearchBar } from "./mountSearchBar"; import { IndexedDbManager } from "embeddia"; import { VectorWorkerManager } from "../indexing/worker/vectorWorkerManager"; +import { checkAndHandleUpdate } from "../utils/versionCheck"; // Platform-aware default hotkey const getDefaultHotkey = () => { @@ -152,15 +153,25 @@ const globalSearchPlugin: Plugin = { const appRef = { current: null }; // Check for extension updates and clear caches if needed - try { - const { checkAndHandleUpdate } = await import("../utils/versionCheck"); - const wasUpdated = await checkAndHandleUpdate(); - if (wasUpdated) { - console.log("[Global Search] Extension updated - caches cleared"); + // Use a timeout to avoid blocking initialization + setTimeout(async () => { + try { + const wasUpdated = await checkAndHandleUpdate(); + if (wasUpdated) { + console.log("[Global Search] Extension updated - caches cleared"); + } + } catch (error: any) { + // Handle CSS preload errors and other failures gracefully + // These can happen in Firefox or when assets aren't available + if (error?.message?.includes("preload CSS") || + error?.message?.includes("MIME type") || + error?.message?.includes("NS_ERROR_CORRUPTED_CONTENT")) { + console.debug("[Global Search] Version check skipped due to asset loading restrictions:", error.message); + } else { + console.warn("[Global Search] Failed to check for updates:", error); + } } - } catch (error) { - console.warn("[Global Search] Failed to check for updates:", error); - } + }, 100); try { await IndexedDbManager.create("embeddiaDB", "embeddiaObjectStore", { diff --git a/src/plugins/built-in/globalSearch/src/core/styles.css b/src/plugins/built-in/globalSearch/src/core/styles.css index 2978dc46..1c50394e 100644 --- a/src/plugins/built-in/globalSearch/src/core/styles.css +++ b/src/plugins/built-in/globalSearch/src/core/styles.css @@ -90,6 +90,8 @@ gap: 8px; margin-left: 8px; min-width: 120px; + max-width: 200px; + height: 32px; } .search-progress-bar-wrapper { @@ -99,6 +101,7 @@ border-radius: 2px; overflow: hidden; display: none; + min-width: 60px; } .dark .search-progress-bar-wrapper { @@ -111,6 +114,7 @@ transition: width 0.3s ease-out; width: 0%; position: relative; + border-radius: 2px; } .search-progress-bar::after { @@ -119,6 +123,7 @@ inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation: shimmer 2s infinite; + border-radius: 2px; } .search-progress-text { @@ -126,6 +131,7 @@ color: #666; white-space: nowrap; display: none; + font-weight: 500; } .dark .search-progress-text { diff --git a/src/plugins/built-in/globalSearch/src/utils/versionCheck.ts b/src/plugins/built-in/globalSearch/src/utils/versionCheck.ts index c3dec89d..31f9aa3d 100644 --- a/src/plugins/built-in/globalSearch/src/utils/versionCheck.ts +++ b/src/plugins/built-in/globalSearch/src/utils/versionCheck.ts @@ -84,19 +84,28 @@ export async function clearAllCaches(): Promise { } // Also try to directly clear caches if modules are already loaded - try { - const { clearSearchCache } = await import("../search/searchUtils"); - clearSearchCache(); - } catch (e) { - // Module might not be loaded yet, that's okay - } - - try { - const { clearEmbeddingCache } = await import("../search/vector/vectorSearch"); - clearEmbeddingCache(); - } catch (e) { - // Module might not be loaded yet, that's okay - } + // Use setTimeout to avoid blocking and handle CSS preload errors + setTimeout(async () => { + try { + const { clearSearchCache } = await import("../search/searchUtils"); + clearSearchCache(); + } catch (e: any) { + // Module might not be loaded yet, or CSS preload error - that's okay + if (!e?.message?.includes("preload CSS") && !e?.message?.includes("MIME type")) { + console.debug("[Version Check] Could not clear search cache:", e); + } + } + + try { + const { clearEmbeddingCache } = await import("../search/vector/vectorSearch"); + clearEmbeddingCache(); + } catch (e: any) { + // Module might not be loaded yet, or CSS preload error - that's okay + if (!e?.message?.includes("preload CSS") && !e?.message?.includes("MIME type")) { + console.debug("[Version Check] Could not clear embedding cache:", e); + } + } + }, 50); console.debug("[Version Check] All caches cleared"); } catch (e) {