From a7f1ea1dc0bea90c5d15d85d0f5dbe8a53572f60 Mon Sep 17 00:00:00 2001 From: Gemini AI Date: Mon, 29 Dec 2025 03:53:19 +0400 Subject: [PATCH] fix: resolve blank preview in new tabs by using computed state - Implemented computed 'currentPreviewData' and 'currentShowCanvas' - Uses local state during streaming (isProcessing=true) for immediate feedback - Uses tab state (activeTab) when idle for persistence and isolation - Updated LiveCanvas and UI to use these computed values - Ensures new tabs usually show their own streaming content immediately --- components/AIAssist.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/AIAssist.tsx b/components/AIAssist.tsx index 62f2428..262ff87 100644 --- a/components/AIAssist.tsx +++ b/components/AIAssist.tsx @@ -475,6 +475,11 @@ export default function AIAssist() { setIsProcessing(false); }, [activeTabId]); + // CRITICAL: Use local previewData during streaming, sync from tab otherwise + // This ensures live updates during streaming AND proper isolation when switching tabs + const currentPreviewData = isProcessing ? previewData : (activeTab?.previewData || previewData); + const currentShowCanvas = isProcessing ? showCanvas : (activeTab?.showCanvas === true || showCanvas); + const [status, setStatus] = useState(null); const scrollRef = useRef(null); @@ -684,7 +689,7 @@ export default function AIAssist() { {/* --- Chat Panel --- */}
{/* Header */} @@ -983,7 +988,7 @@ export default function AIAssist() { {/* --- Canvas Panel --- */} { - (activeTab?.showCanvas === true && activeTab?.previewData) && ( + (currentShowCanvas && currentPreviewData) && (
@@ -992,7 +997,7 @@ export default function AIAssist() { {viewMode === "preview" ? : }
-

{previewData?.type || "Live"} Canvas

+

{currentPreviewData?.type || "Live"} Canvas

- {viewMode === "preview" && activeTab?.previewData ? ( + {viewMode === "preview" && currentPreviewData ? ( ) : (
-                                            {activeTab?.previewData?.data}
+                                            {currentPreviewData?.data}
                                         
)} @@ -1052,13 +1057,13 @@ export default function AIAssist() {
-
+
- {activeTab?.previewData?.isStreaming ? "Neural Link Active" : "Sync Complete"} + {currentPreviewData?.isStreaming ? "Neural Link Active" : "Sync Complete"}
- {activeTab?.previewData?.language?.toUpperCase()} UTF-8 + {currentPreviewData?.language?.toUpperCase()} UTF-8