diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index aa559e1..dee1b01 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,15 +1,17 @@ +//App.jsx import React, { useState, useEffect } from "react"; import "./App.css"; import { themes } from "./themes"; import ChatLayout from "./ChatLayout"; import { useChatStream } from "./useChatStream"; -import { getSessionId } from "./useSessionId"; +import { getSessionId, getUserId, resetSessionId } from "./useSessionId"; export default function App() { const { messages, loading, sendMessage, stopGenerating, setMessages } = useChatStream(); const [themeName, setThemeName] = useState("light"); const theme = themes[themeName]; const sessionId = getSessionId(); + const userId = getUserId(); useEffect(() => { const saved = localStorage.getItem("preferredTheme"); @@ -25,17 +27,18 @@ export default function App() { }; const reloadHistory = async () => { - const res = await fetch(`/api/history?user_id=${sessionId}`); + const res = await fetch(`/api/history?user_id=${userId}&session_id=${sessionId}`); const history = await res.json(); setMessages(history); // from useChatStream }; const freshStart = async () => { - await fetch(`/api/history?user_id=${sessionId}`, { method: "DELETE" }); + await fetch(`/api/v1/history?user_id=${userId}&session_id=${sessionId}`, { method: "DELETE" }); setMessages([]); + resetSessionId(); // or start a brand new sessionId: - localStorage.removeItem("sessionId"); - window.location.reload(); + //localStorage.removeItem("sessionId"); + //window.location.reload(); }; return ( diff --git a/frontend/src/ChatLayout.jsx b/frontend/src/ChatLayout.jsx index 18d01b6..a862217 100644 --- a/frontend/src/ChatLayout.jsx +++ b/frontend/src/ChatLayout.jsx @@ -15,7 +15,7 @@ export default function ChatLayout({ onFreshStart }) { return ( -