diff --git a/app/components/AuthProvider.tsx b/app/components/AuthProvider.tsx
index ec756a4..93a67c0 100644
--- a/app/components/AuthProvider.tsx
+++ b/app/components/AuthProvider.tsx
@@ -261,27 +261,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
);
}
- // Render without Dynamic until explicitly initialized
- if (!isDynamicInitialized) {
- return (
- {},
- }}
- >
- {children}
-
- );
- }
-
+ // Always render DynamicContextProvider to avoid unmounting/remounting children
+ // Control visibility through isDynamicInitialized flag
return (
-
+ {isDynamicInitialized && (
+
+ )}
(null);
const [llmProvider, setLlmProvider] = useState('');
+ // Extract loadCacheInfo for reusability
+ const loadCacheInfo = async () => {
+ const { gwasDB } = await import('@/lib/gwas-db');
+ const metadata = await gwasDB.getMetadata();
+ if (metadata) {
+ const size = await gwasDB.getStorageSize();
+ setCacheInfo({
+ studies: metadata.totalStudies,
+ sizeMB: Math.round(size / 1024 / 1024)
+ });
+ } else {
+ setCacheInfo(null);
+ }
+ };
+
useEffect(() => {
// Mark component as mounted
setMounted(true);
@@ -45,19 +60,29 @@ export default function MenuBar() {
const config = getLLMConfig();
setLlmProvider(getProviderDisplayName(config.provider));
- // Load cache info
- const loadCacheInfo = async () => {
- const { gwasDB } = await import('@/lib/gwas-db');
- const metadata = await gwasDB.getMetadata();
- if (metadata) {
- const size = await gwasDB.getStorageSize();
- setCacheInfo({
- studies: metadata.totalStudies,
- sizeMB: Math.round(size / 1024 / 1024)
- });
+ // Load cache info on mount
+ loadCacheInfo();
+
+ // Listen for cache updates
+ const handleCacheUpdated = () => {
+ console.log('[MenuBar] Cache updated event received, refreshing cache info');
+ loadCacheInfo();
+ };
+
+ // Listen for visibility changes to refresh cache when user returns to tab
+ const handleVisibilityChange = () => {
+ if (document.visibilityState === 'visible') {
+ loadCacheInfo();
}
};
- loadCacheInfo();
+
+ window.addEventListener('cacheUpdated', handleCacheUpdated);
+ document.addEventListener('visibilitychange', handleVisibilityChange);
+
+ return () => {
+ window.removeEventListener('cacheUpdated', handleCacheUpdated);
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
+ };
}, []);
useEffect(() => {
diff --git a/app/layout.tsx b/app/layout.tsx
index 1e0d028..2ddb51a 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -2,6 +2,9 @@ import type { Metadata } from "next";
import Script from "next/script";
import "./globals.css";
import { AuthProvider } from "./components/AuthProvider";
+import { GenotypeProvider } from "./components/UserDataUpload";
+import { ResultsProvider } from "./components/ResultsContext";
+import { CustomizationProvider } from "./components/CustomizationContext";
export const metadata: Metadata = {
title: "Monadic DNA Explorer",
@@ -72,7 +75,15 @@ export default function RootLayout({
- {children}
+
+
+
+
+ {children}
+
+
+
+