Spaces:
Running
Running
Pulastya B
commited on
Commit
·
fbe4715
1
Parent(s):
ecb7263
Fix loading indicator: set isTyping before API call, not after
Browse files
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -142,7 +142,9 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 142 |
const newMessages = [...activeSession.messages, userMessage];
|
| 143 |
updateSession(activeSessionId, newMessages);
|
| 144 |
setInput('');
|
| 145 |
-
|
|
|
|
|
|
|
| 146 |
|
| 147 |
try {
|
| 148 |
|
|
@@ -209,7 +211,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 209 |
|
| 210 |
const data = await response.json();
|
| 211 |
|
| 212 |
-
//
|
| 213 |
if (data.session_id && data.session_id !== activeSessionId) {
|
| 214 |
console.log(`🔑 Session UUID from backend: ${data.session_id}`);
|
| 215 |
|
|
@@ -224,13 +226,10 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 224 |
setSessions(prev => [...prev.filter(s => s.id !== activeSessionId), migratedSession]);
|
| 225 |
}
|
| 226 |
|
| 227 |
-
// Switch to the backend UUID session
|
| 228 |
setActiveSessionId(data.session_id);
|
| 229 |
}
|
| 230 |
|
| 231 |
-
// NOW start SSE - after we have the UUID
|
| 232 |
-
setIsTyping(true);
|
| 233 |
-
|
| 234 |
let assistantContent = '';
|
| 235 |
let reports: Array<{name: string, path: string}> = [];
|
| 236 |
let plots: Array<{title: string, url: string, type?: 'image' | 'html'}> = [];
|
|
|
|
| 142 |
const newMessages = [...activeSession.messages, userMessage];
|
| 143 |
updateSession(activeSessionId, newMessages);
|
| 144 |
setInput('');
|
| 145 |
+
|
| 146 |
+
// Show loading indicator immediately (for UI feedback)
|
| 147 |
+
setIsTyping(true);
|
| 148 |
|
| 149 |
try {
|
| 150 |
|
|
|
|
| 211 |
|
| 212 |
const data = await response.json();
|
| 213 |
|
| 214 |
+
// Store UUID from backend to trigger SSE connection
|
| 215 |
if (data.session_id && data.session_id !== activeSessionId) {
|
| 216 |
console.log(`🔑 Session UUID from backend: ${data.session_id}`);
|
| 217 |
|
|
|
|
| 226 |
setSessions(prev => [...prev.filter(s => s.id !== activeSessionId), migratedSession]);
|
| 227 |
}
|
| 228 |
|
| 229 |
+
// Switch to the backend UUID session - this triggers SSE connection
|
| 230 |
setActiveSessionId(data.session_id);
|
| 231 |
}
|
| 232 |
|
|
|
|
|
|
|
|
|
|
| 233 |
let assistantContent = '';
|
| 234 |
let reports: Array<{name: string, path: string}> = [];
|
| 235 |
let plots: Array<{title: string, url: string, type?: 'image' | 'html'}> = [];
|