From 60acbac46438c2bf2c449457112c78e2184c2eac Mon Sep 17 00:00:00 2001 From: gongzhiyong Date: Wed, 8 Apr 2026 16:21:33 +0800 Subject: [PATCH] Fix 3 P0 issues from code review FCR-1: Set ignoreBuildErrors to false in next.config.mjs FCR-2: Default API_URL to production backend so static builds work correctly; .env.local overrides to localhost for local dev FCR-3: Remove createConversation call in handleSend; generate UUID client-side and let backend streamChat auto-create the conversation to avoid duplicate writes Co-Authored-By: Claude Sonnet 4.6 (1M context) --- frontend/components/gemini/GeminiChat.tsx | 27 +++++++++-------------- frontend/lib/api.ts | 2 +- frontend/next.config.mjs | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/frontend/components/gemini/GeminiChat.tsx b/frontend/components/gemini/GeminiChat.tsx index c0fc71b..de5e7c5 100644 --- a/frontend/components/gemini/GeminiChat.tsx +++ b/frontend/components/gemini/GeminiChat.tsx @@ -13,7 +13,6 @@ import { cn } from "@/lib/utils"; import { fetchConversations, fetchConversation, - createConversation, fetchTickets, streamChat, type TicketData, @@ -176,22 +175,16 @@ export function GeminiChat() { let convId = activeConvId; if (!convId) { - // Create new conversation via API - try { - const title = text.length > 50 ? text.slice(0, 50) + "…" : text; - const created = await createConversation(title); - convId = created.id; - const newConv: Conversation = { - id: convId, - title: created.title, - messages: [userMsg], - }; - setConversations((prev) => [newConv, ...prev]); - setActiveConvId(convId); - } catch { - setIsLoading(false); - return; - } + // Generate a UUID client-side; backend streamChat auto-creates the conversation + convId = crypto.randomUUID(); + const title = text.length > 50 ? text.slice(0, 50) + "…" : text; + const newConv: Conversation = { + id: convId, + title, + messages: [userMsg], + }; + setConversations((prev) => [newConv, ...prev]); + setActiveConvId(convId); } else { setConversations((prev) => prev.map((c) => diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index 171adfe..862d0e4 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -1,4 +1,4 @@ -const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000"; +const API_URL = process.env.NEXT_PUBLIC_API_URL ?? "https://soc-backend.azurewebsites.net"; // ── Conversations ──────────────────────────────────────────────────────────── diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 5909428..74be78a 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -2,7 +2,7 @@ const nextConfig = { output: 'export', typescript: { - ignoreBuildErrors: true, + ignoreBuildErrors: false, }, images: { unoptimized: true,