Spaces:
Running
Running
Pulastya B
commited on
Commit
·
11c0b04
1
Parent(s):
94aef75
Fix loading indicator: remove activeSession dependency, show based on isTyping only
Browse files
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -294,14 +294,14 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 294 |
if (data.session_id) {
|
| 295 |
console.log(`🔑 Session UUID from backend: ${data.session_id}`);
|
| 296 |
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
| 299 |
setSessions(prev => prev.map(s =>
|
| 300 |
-
s.id === activeSessionId ? { ...s, id:
|
| 301 |
));
|
| 302 |
-
|
| 303 |
-
// Switch to the backend UUID session - this triggers SSE connection
|
| 304 |
-
setActiveSessionId(data.session_id);
|
| 305 |
}
|
| 306 |
|
| 307 |
// For async endpoint, result comes via SSE analysis_complete event
|
|
@@ -728,7 +728,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 728 |
</motion.div>
|
| 729 |
))
|
| 730 |
)}
|
| 731 |
-
{isTyping &&
|
| 732 |
<div className="flex gap-4">
|
| 733 |
<div className="w-8 h-8 rounded-lg flex items-center justify-center shrink-0 bg-white/5 border border-white/10">
|
| 734 |
<Bot className="w-4 h-4 text-indigo-400" />
|
|
|
|
| 294 |
if (data.session_id) {
|
| 295 |
console.log(`🔑 Session UUID from backend: ${data.session_id}`);
|
| 296 |
|
| 297 |
+
const newSessionId = data.session_id;
|
| 298 |
+
|
| 299 |
+
// CRITICAL: Update sessions first, then activeSessionId
|
| 300 |
+
// React 18 batches these updates automatically, preventing flicker
|
| 301 |
setSessions(prev => prev.map(s =>
|
| 302 |
+
s.id === activeSessionId ? { ...s, id: newSessionId } : s
|
| 303 |
));
|
| 304 |
+
setActiveSessionId(newSessionId);
|
|
|
|
|
|
|
| 305 |
}
|
| 306 |
|
| 307 |
// For async endpoint, result comes via SSE analysis_complete event
|
|
|
|
| 728 |
</motion.div>
|
| 729 |
))
|
| 730 |
)}
|
| 731 |
+
{isTyping && (
|
| 732 |
<div className="flex gap-4">
|
| 733 |
<div className="w-8 h-8 rounded-lg flex items-center justify-center shrink-0 bg-white/5 border border-white/10">
|
| 734 |
<Bot className="w-4 h-4 text-indigo-400" />
|