From f19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 6 Aug 2023 09:28:22 -0700 Subject: feat: :construction: Router and new history page --- extension/react-app/src/pages/gui.tsx | 14 ++++++-- extension/react-app/src/pages/history.tsx | 55 +++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 extension/react-app/src/pages/history.tsx (limited to 'extension/react-app/src/pages') diff --git a/extension/react-app/src/pages/gui.tsx b/extension/react-app/src/pages/gui.tsx index d69da57e..247789d6 100644 --- a/extension/react-app/src/pages/gui.tsx +++ b/extension/react-app/src/pages/gui.tsx @@ -16,11 +16,12 @@ import { BookOpenIcon, ChatBubbleOvalLeftEllipsisIcon, TrashIcon, + PlusCircleIcon, + FolderIcon, } from "@heroicons/react/24/outline"; import ComboBox from "../components/ComboBox"; import TextDialog from "../components/TextDialog"; import HeaderButtonWithText from "../components/HeaderButtonWithText"; -import ReactSwitch from "react-switch"; import { usePostHog } from "posthog-js/react"; import { useDispatch, useSelector } from "react-redux"; import { RootStore } from "../redux/store"; @@ -589,7 +590,16 @@ If you already have an LLM deployed on your own infrastructure, or would like to }} text="Clear" > - + + + { + // Go to /history page + document.location.href = "/history"; + }} + text="History" + > + ([]); + const client = useContext(GUIClientContext); + const apiUrl = useSelector((state: RootStore) => state.config.apiUrl); + + useEffect(() => { + const fetchSessions = async () => { + console.log("fetching sessions"); + if (!apiUrl) { + return; + } + const response = await fetch(`${apiUrl}/sessions/list`); + const json = await response.json(); + console.log(json); + setSessions(json); + }; + fetchSessions(); + }, [client]); + + return ( +
+ + + {sessions.map((session, index) => ( + + + + ))} + +
+
{ + // client?.loadSession(session.id); + // document.location.href = "/gui"; + }} + > +
{session.title}
+
+ {session.date_created} +
+
+
+
+ ); +} + +export default History; -- cgit v1.2.3-70-g09d2