From df170c83a554df526e25a825389e692669644c85 Mon Sep 17 00:00:00 2001 From: firecoperana Date: Sun, 8 Jun 2025 11:38:47 +0000 Subject: Webui improvement (#481) * update webui * add token/s in webui * add webui files * fix webui first message disappear in some browser * add missing html files --------- Co-authored-by: firecoperana --- examples/server/webui/src/components/Sidebar.tsx | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 examples/server/webui/src/components/Sidebar.tsx (limited to 'examples/server/webui/src/components/Sidebar.tsx') diff --git a/examples/server/webui/src/components/Sidebar.tsx b/examples/server/webui/src/components/Sidebar.tsx new file mode 100644 index 00000000..34727c62 --- /dev/null +++ b/examples/server/webui/src/components/Sidebar.tsx @@ -0,0 +1,96 @@ +import { useEffect, useState } from 'react'; +import { classNames } from '../utils/misc'; +import { Conversation } from '../utils/types'; +import StorageUtils from '../utils/storage'; +import { useNavigate, useParams } from 'react-router'; + +export default function Sidebar() { + const params = useParams(); + const navigate = useNavigate(); + + const [conversations, setConversations] = useState([]); + const [currConv, setCurrConv] = useState(null); + + useEffect(() => { + StorageUtils.getOneConversation(params.convId ?? '').then(setCurrConv); + }, [params.convId]); + + useEffect(() => { + const handleConversationChange = async () => { + setConversations(await StorageUtils.getAllConversations()); + }; + StorageUtils.onConversationChanged(handleConversationChange); + handleConversationChange(); + return () => { + StorageUtils.offConversationChanged(handleConversationChange); + }; + }, []); + + return ( + <> + + +
+ +
+
+

Conversations

+ + {/* close sidebar button */} + +
+ + {/* list of conversations */} +
navigate('/')} + > + + New conversation +
+ {conversations.map((conv) => ( +
navigate(`/chat/${conv.id}`)} + dir="auto" + > + {conv.name} +
+ ))} +
+ Conversations are saved to browser's IndexedDB +
+
+
+ + ); +} -- cgit v1.2.3