diff --git a/docs/components/floating-ai-search.tsx b/docs/components/floating-ai-search.tsx index 0666fd37..2f1e5284 100644 --- a/docs/components/floating-ai-search.tsx +++ b/docs/components/floating-ai-search.tsx @@ -11,7 +11,7 @@ import { useRef, useState, } from "react"; -import { Loader2, SearchIcon, Send, X } from "lucide-react"; +import { Loader2, SearchIcon, Send, Trash2, X } from "lucide-react"; import { cn } from "@/lib/utils"; import { buttonVariants } from "fumadocs-ui/components/ui/button"; import Link from "fumadocs-core/link"; @@ -33,30 +33,30 @@ function useChatContext() { return use(Context)!.chat; } -function SearchAIActions() { - const { messages, status, setMessages, stop } = useChatContext(); - const isGenerating = status === "streaming" || status === "submitted"; +// function SearchAIActions() { +// const { messages, status, setMessages, stop } = useChatContext(); +// const isGenerating = status === "streaming" || status === "submitted"; - if (messages.length === 0) return null; +// if (messages.length === 0) return null; - return ( - <> - - - ); -} +// return ( +// <> +// +// +// ); +// } const suggestions = [ "How to configure Sqlite database?", @@ -66,7 +66,7 @@ const suggestions = [ ]; function SearchAIInput(props: ComponentProps<"form">) { - const { status, sendMessage, stop, messages } = useChatContext(); + const { status, sendMessage, stop, messages, setMessages } = useChatContext(); const [input, setInput] = useState(""); const isLoading = status === "streaming" || status === "submitted"; const showSuggestions = messages.length === 0 && !isLoading; @@ -81,12 +81,22 @@ function SearchAIInput(props: ComponentProps<"form">) { void sendMessage({ text: suggestion }); }; + const handleClear = () => { + setMessages([]); + setInput(""); + }; + useEffect(() => { if (isLoading) document.getElementById("nd-ai-input")?.focus(); }, [isLoading]); return ( -
+
) { > { setInput(e.target.value); @@ -156,6 +166,38 @@ function SearchAIInput(props: ComponentProps<"form">) {
)} + {showSuggestions && ( +
+ Powered by{" "} + + Inkeep. + + AI can be inaccurate, please verify the information. +
+ )} + {!showSuggestions && ( +
+
{ + if (!isLoading) { + handleClear(); + } + }} + > + +

Clear

+
+
+ )} ); } @@ -463,28 +505,8 @@ export function AISearchTrigger() { } }} > -

- Powered by{" "} - - - -

-
-

- Powered by{" "} - - - -

+