From 8f93e587856aea3bc7230622001c15cd1859849b Mon Sep 17 00:00:00 2001 From: Gemini AI Date: Sun, 28 Dec 2025 12:48:04 +0400 Subject: [PATCH] fix: enhanced HTML detection, fallback mode, blue theme and improved streaming reliability --- components/AIAssist.tsx | 169 +++++++++++++++++++++++----------- lib/services/model-adapter.ts | 38 +++++--- 2 files changed, 140 insertions(+), 67 deletions(-) diff --git a/components/AIAssist.tsx b/components/AIAssist.tsx index 8090f76..690c00d 100644 --- a/components/AIAssist.tsx +++ b/components/AIAssist.tsx @@ -52,15 +52,26 @@ const LiveCanvas = memo(({ data, type, isStreaming }: { data: string, type: stri : data; // Check if the content is a full HTML document or a fragment - const isFullDocument = normalized.trim().startsWith("]/i.test(normalized); let doc: string; if (isFullDocument) { // If it's a full document, inject Tailwind CSS but keep the structure - doc = normalized.replace(//i, ` - - - `); + if (hasHeadTag) { + doc = normalized.replace(//i, ` + + + `); + } else { + doc = normalized.replace(/]*>/i, (match) => `${match} + + + + + `); + } } else { // Wrap fragments in a styled container doc = ` @@ -117,8 +128,8 @@ const LiveCanvas = memo(({ data, type, isStreaming }: { data: string, type: stri sandbox="allow-scripts" /> {isStreaming && ( -
-
+
+
)}