From 019d9e37d8678c5a667d2f64ed41300a4c25a0ab Mon Sep 17 00:00:00 2001 From: Vishakh Date: Thu, 11 Dec 2025 10:04:44 -0500 Subject: [PATCH 1/3] Fixed bug with switching to the Premium tab becoming an app refresh. --- app/components/AuthProvider.tsx | 33 ++++++++------------------------- app/layout.tsx | 13 ++++++++++++- app/page.tsx | 15 +++------------ 3 files changed, 23 insertions(+), 38 deletions(-) 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 && ( + + )} - {children} + + + + + {children} + + + + ); diff --git a/app/page.tsx b/app/page.tsx index 4e8b7d2..cd8ebc6 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,9 +1,8 @@ "use client"; import { useEffect, useMemo, useState, useCallback, useRef } from "react"; -import { GenotypeProvider, useGenotype } from "./components/UserDataUpload"; -import { ResultsProvider, useResults } from "./components/ResultsContext"; -import { CustomizationProvider } from "./components/CustomizationContext"; +import { useGenotype } from "./components/UserDataUpload"; +import { useResults } from "./components/ResultsContext"; import { AuthButton, useAuth } from "./components/AuthProvider"; import { RunAllIcon, LLMChatIcon, OverviewReportIcon } from "./components/Icons"; import StudyResultReveal from "./components/StudyResultReveal"; @@ -1412,13 +1411,5 @@ function MainContent() { } export default function HomePage() { - return ( - - - - - - - - ); + return ; } From ce4ceb59ce0be042444fa6b97342074e63787e61 Mon Sep 17 00:00:00 2001 From: Vishakh Date: Thu, 11 Dec 2025 10:42:14 -0500 Subject: [PATCH 2/3] Fixed cache indicator bug. --- app/components/MenuBar.tsx | 47 +++++++++++++++++++++++++++++--------- app/page.tsx | 3 +++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/app/components/MenuBar.tsx b/app/components/MenuBar.tsx index 2248afc..dcf5331 100644 --- a/app/components/MenuBar.tsx +++ b/app/components/MenuBar.tsx @@ -33,6 +33,21 @@ export default function MenuBar() { const [cacheInfo, setCacheInfo] = useState<{ studies: number; sizeMB: number } | null>(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/page.tsx b/app/page.tsx index cd8ebc6..4f7a250 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -624,6 +624,9 @@ function MainContent() { await addResultsBatch(results); // Embeddings will be fetched on-demand during LLM analysis const addTime = Date.now() - startAdd; console.log(`Finished adding ${results.length} results in ${addTime}ms`); + + // Notify MenuBar that cache has been updated + window.dispatchEvent(new CustomEvent('cacheUpdated')); } catch (error) { console.error('Run All failed:', error); setRunAllStatus(prev => ({ From d44c60a75bc5ec759f424f310224be0c166bce50 Mon Sep 17 00:00:00 2001 From: Vishakh Date: Thu, 11 Dec 2025 10:49:12 -0500 Subject: [PATCH 3/3] Set better defaults for Explore --- app/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 4f7a250..f6a397b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -99,7 +99,7 @@ type QualitySummary = { }; const defaultFilters: Filters = { - search: "", + search: "sleep", searchMode: "similarity", trait: "", minSampleSize: "500", @@ -109,7 +109,7 @@ const defaultFilters: Filters = { requireUserSNPs: false, sort: "relevance", sortDirection: "desc", - limit: 200, + limit: 1000, confidenceBand: null, offset: 0, };