From 9f7f64b9eeaaac8aa06246c768f93a5d3e128c19 Mon Sep 17 00:00:00 2001 From: DJP Date: Fri, 3 Oct 2025 10:56:50 -0400 Subject: [PATCH] Fix synthesis loading from database - useQuery now returns data properly - useEffect sets synthesis state when loadedSynthesis changes - Synthesis will persist across page refreshes - No dependency on synthesis in useEffect (prevents loops) Synthesis persistence NOW WORKING! --- frontend/src/app/notebooks/[id]/page.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/notebooks/[id]/page.tsx b/frontend/src/app/notebooks/[id]/page.tsx index 8c5aad5..f289615 100644 --- a/frontend/src/app/notebooks/[id]/page.tsx +++ b/frontend/src/app/notebooks/[id]/page.tsx @@ -65,21 +65,28 @@ export default function NotebookDetailPage() { }); // Load saved synthesis from database - useQuery({ + const { data: loadedSynthesis } = useQuery({ queryKey: ['synthesis', notebookId], queryFn: async () => { try { const response = await notebookAPI.getSynthesis(notebookId); if (response.data && response.data.status !== 'none') { - setSynthesis(response.data); + return response.data; } - return response.data; + return null; } catch { return null; } }, }); + // Set synthesis from loaded data + useEffect(() => { + if (loadedSynthesis && !synthesis) { + setSynthesis(loadedSynthesis); + } + }, [loadedSynthesis]); + const synthesisMutation = useMutation({ mutationFn: async () => { const response = await notebookAPI.generateSynthesis(notebookId);