From 5a11c32bc4d56924e98e0df88cdab04b17f274b1 Mon Sep 17 00:00:00 2001 From: "dayuan.jiang" Date: Wed, 19 Mar 2025 07:20:22 +0000 Subject: [PATCH] feat: add WebSearchToolUI component and input UI, integrate Radix UI scroll area --- app/page.tsx | 73 ++++++--------------------- components/chatPanel.tsx | 87 ++++++++++++++++++++++++++++++++ components/ui/card.tsx | 92 ++++++++++++++++++++++++++++++++++ components/ui/input.tsx | 21 ++++++++ components/ui/scroll-area.tsx | 58 +++++++++++++++++++++ components/webSearchToolUI.tsx | 21 ++++++++ package-lock.json | 53 ++++++++++++++++++++ package.json | 1 + 8 files changed, 348 insertions(+), 58 deletions(-) create mode 100644 components/chatPanel.tsx create mode 100644 components/ui/card.tsx create mode 100644 components/ui/input.tsx create mode 100644 components/ui/scroll-area.tsx create mode 100644 components/webSearchToolUI.tsx diff --git a/app/page.tsx b/app/page.tsx index a4044ca..65cb4dc 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,43 +1,38 @@ "use client"; -import { AssistantRuntimeProvider } from "@assistant-ui/react"; -import { useChatRuntime } from "@assistant-ui/react-ai-sdk"; import { DrawIoEmbed, DrawIoEmbedRef } from "react-drawio"; -import { Thread } from "@/components/assistant-ui/thread"; import { useRef, useState } from "react"; import { Button } from "@/components/ui/button"; -import { extractDiagramXML } from "./extract_xml" -export default function Home() { - const runtime = useChatRuntime({ - api: "/api/chat", - }); +import { extractDiagramXML } from "./extract_xml"; +import ChatPanel from "@/components/chatPanel"; +export default function Home() { const drawioRef = useRef(null); - const [imgData, setImgData] = useState(null); + const [chartXML, setChartXML] = useState(""); const [diagram, setDiagram] = useState(""); // const handleExport = () => {}; const handleExport = () => { + // use this function to export the diagramxml from the drawio editor if (drawioRef.current) { drawioRef.current.exportDiagram({ format: "xmlsvg", }); } }; - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); + const loadDiagram = (chart: string) => { + // use this function to display the diagramxml in the drawio editor if (drawioRef.current) { drawioRef.current.load({ - xml: diagram, + xml: chart, }); } }; - console.log("imgData", imgData); return ( - -
+
+
setImgData(data.data)} + onExport={(data) => setChartXML(extractDiagramXML(data.data))} urlParameters={{ // ui: "kennedy", spin: true, @@ -46,48 +41,10 @@ export default function Home() { noExitBtn: true, }} /> - {/* */} -
-
-
- -