Spaces:
Sleeping
Sleeping
refresh chat session button
Browse files- src/App.js +25 -1
src/App.js
CHANGED
|
@@ -63,6 +63,9 @@ function App() {
|
|
| 63 |
const [input, setInput] = useState("");
|
| 64 |
const [strictMode, setStrictMode] = useState(true);
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
// Session-scoped KB staging uses this stable id.
|
| 67 |
const sessionId = useMemo(() => {
|
| 68 |
try {
|
|
@@ -73,7 +76,7 @@ function App() {
|
|
| 73 |
// ignore
|
| 74 |
}
|
| 75 |
return `sid-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
| 76 |
-
}, []);
|
| 77 |
const [loading, setLoading] = useState(false);
|
| 78 |
const [error, setError] = useState(null);
|
| 79 |
|
|
@@ -455,6 +458,20 @@ function App() {
|
|
| 455 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 456 |
}, [showSessionPanel, token]);
|
| 457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
// ============================================================
|
| 459 |
// SEND CHAT MESSAGE
|
| 460 |
// ============================================================
|
|
@@ -578,6 +595,13 @@ function App() {
|
|
| 578 |
<header className="header">
|
| 579 |
<h1 className="header-title">Prolog AI</h1>
|
| 580 |
<div className="header-actions">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
<button
|
| 582 |
className="strict-toggle-btn"
|
| 583 |
onClick={() => setStrictMode(!strictMode)}
|
|
|
|
| 63 |
const [input, setInput] = useState("");
|
| 64 |
const [strictMode, setStrictMode] = useState(true);
|
| 65 |
|
| 66 |
+
// Session trigger - increment to force new sessionId generation
|
| 67 |
+
const [sessionTrigger, setSessionTrigger] = useState(0);
|
| 68 |
+
|
| 69 |
// Session-scoped KB staging uses this stable id.
|
| 70 |
const sessionId = useMemo(() => {
|
| 71 |
try {
|
|
|
|
| 76 |
// ignore
|
| 77 |
}
|
| 78 |
return `sid-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
| 79 |
+
}, [sessionTrigger]);
|
| 80 |
const [loading, setLoading] = useState(false);
|
| 81 |
const [error, setError] = useState(null);
|
| 82 |
|
|
|
|
| 458 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 459 |
}, [showSessionPanel, token]);
|
| 460 |
|
| 461 |
+
// ============================================================
|
| 462 |
+
// NEW CHAT SESSION
|
| 463 |
+
// ============================================================
|
| 464 |
+
function handleNewChat() {
|
| 465 |
+
setMessages([]);
|
| 466 |
+
setInput("");
|
| 467 |
+
setError(null);
|
| 468 |
+
setSessionTrigger(prev => prev + 1);
|
| 469 |
+
// Optionally clear session panels
|
| 470 |
+
setSessionLemmas([]);
|
| 471 |
+
setSessionDocs({ papers: [], stories: [] });
|
| 472 |
+
setSessionPanelStatus(null);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
// ============================================================
|
| 476 |
// SEND CHAT MESSAGE
|
| 477 |
// ============================================================
|
|
|
|
| 595 |
<header className="header">
|
| 596 |
<h1 className="header-title">Prolog AI</h1>
|
| 597 |
<div className="header-actions">
|
| 598 |
+
<button
|
| 599 |
+
className="btn-secondary"
|
| 600 |
+
onClick={handleNewChat}
|
| 601 |
+
title="New Chat Session"
|
| 602 |
+
>
|
| 603 |
+
➕
|
| 604 |
+
</button>
|
| 605 |
<button
|
| 606 |
className="strict-toggle-btn"
|
| 607 |
onClick={() => setStrictMode(!strictMode)}
|