diff --git a/apps/web/app/global-error.tsx b/apps/web/app/global-error.tsx index 9bda5fee..32800924 100644 --- a/apps/web/app/global-error.tsx +++ b/apps/web/app/global-error.tsx @@ -6,7 +6,9 @@ import { useEffect } from "react"; export default function GlobalError({ error }: { error: Error & { digest?: string } }) { useEffect(() => { - Sentry.captureException(error); + if (process.env.NODE_ENV !== 'development') { + Sentry.captureException(error); + } }, [error]); return ( diff --git a/apps/web/components/header.tsx b/apps/web/components/header.tsx index e38134a7..dd24a43d 100644 --- a/apps/web/components/header.tsx +++ b/apps/web/components/header.tsx @@ -38,8 +38,7 @@ export function AppHeader() { <>
diff --git a/apps/web/components/views/chat/chat-messages.tsx b/apps/web/components/views/chat/chat-messages.tsx index a20856bd..4e32d075 100644 --- a/apps/web/components/views/chat/chat-messages.tsx +++ b/apps/web/components/views/chat/chat-messages.tsx @@ -3,14 +3,13 @@ import { useChat, useCompletion } from "@ai-sdk/react"; import { cn } from "@lib/utils"; import { Button } from "@ui/components/button"; -import { Input } from "@ui/components/input"; import { DefaultChatTransport } from "ai"; import { - ArrowUp, Check, ChevronDown, ChevronRight, Copy, + Plus, RotateCcw, UserIcon, X, @@ -218,8 +217,10 @@ export function ChatMessages() { getCurrentChat, } = usePersistentChat(); + const [input, setInput] = useState(""); const activeChatIdRef = useRef(null); const shouldGenerateTitleRef = useRef(false); + const hasRunInitialMessageRef = useRef(false); const { setDocumentIds } = useGraphHighlights(); @@ -254,6 +255,16 @@ export function ChatMessages() { activeChatIdRef.current = currentChatId ?? id ?? null; }, [currentChatId, id]); + useEffect(() => { + if (currentChatId && !hasRunInitialMessageRef.current) { + const msgs = getCurrentConversation(); + if (msgs && msgs.length === 1) { + sendMessage({ text: msgs[0].content }); + hasRunInitialMessageRef.current = true; + } + } + }, []); + useEffect(() => { if (id && id !== currentChatId) { setCurrentChatId(id); @@ -262,7 +273,11 @@ export function ChatMessages() { useEffect(() => { const msgs = getCurrentConversation(); - setMessages(msgs ?? []); + if (msgs && msgs.length > 0) { + setMessages(msgs); + } else if (!currentChatId) { + setMessages([]); + } setInput(""); }, [currentChatId]); @@ -273,7 +288,6 @@ export function ChatMessages() { } }, [messages, currentChatId, id, setConversation]); - const [input, setInput] = useState(""); const { complete } = useCompletion({ api: `${process.env.NEXT_PUBLIC_BACKEND_URL}/chat/title`, credentials: "include", @@ -336,7 +350,13 @@ export function ChatMessages() { ref={scrollContainerRef} > {messages.map((message) => ( -
+
{message.role === "user" && ( )} @@ -517,40 +537,92 @@ export function ChatMessages() {
-
{ - e.preventDefault(); - if (status === "submitted") return; - if (status === "streaming") { - stop(); - return; - } - if (input.trim()) { - enableAutoScroll(); - scrollToBottom("auto"); - sendMessage({ text: input }); - setInput(""); - } - }} - > - setInput(e.target.value)} - placeholder="Say something..." - value={input} - /> - -
+
+
+
+
+ Suggest me best hotels in Liechtenstein +
+
+ Prepare a full itinerary to Liechtenstein +
+
+
{ + e.preventDefault(); + if (status === "submitted") return; + if (status === "streaming") { + stop(); + return; + } + if (input.trim()) { + enableAutoScroll(); + scrollToBottom("auto"); + sendMessage({ text: input }); + setInput(""); + } + }} + > +