Spaces:
Running
Running
Pulastya B
commited on
Commit
Β·
94aef75
1
Parent(s):
565097f
Fix frontend refresh bug: map session ID in-place instead of filter/recreate
Browse files
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -104,9 +104,9 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 104 |
console.log('β
Analysis completed', data.result);
|
| 105 |
setIsTyping(false);
|
| 106 |
|
| 107 |
-
// Process the final result
|
| 108 |
if (data.result) {
|
| 109 |
-
processAnalysisResult(data.result);
|
| 110 |
}
|
| 111 |
}
|
| 112 |
} catch (err) {
|
|
@@ -133,7 +133,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 133 |
};
|
| 134 |
}, [activeSessionId]);
|
| 135 |
|
| 136 |
-
const processAnalysisResult = (result: any) => {
|
| 137 |
// Extract and display the analysis result from SSE
|
| 138 |
let assistantContent = 'β
Analysis Complete!\n\n';
|
| 139 |
let reports: Array<{name: string, path: string}> = [];
|
|
@@ -198,7 +198,13 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 198 |
plots
|
| 199 |
};
|
| 200 |
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
};
|
| 203 |
|
| 204 |
const handleSend = async () => {
|
|
@@ -285,19 +291,14 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 285 |
const data = await response.json();
|
| 286 |
|
| 287 |
// Store UUID from backend to trigger SSE connection
|
| 288 |
-
if (data.session_id
|
| 289 |
console.log(`π Session UUID from backend: ${data.session_id}`);
|
| 290 |
|
| 291 |
-
//
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
...currentSession,
|
| 297 |
-
id: data.session_id,
|
| 298 |
-
};
|
| 299 |
-
setSessions(prev => [...prev.filter(s => s.id !== activeSessionId), migratedSession]);
|
| 300 |
-
}
|
| 301 |
|
| 302 |
// Switch to the backend UUID session - this triggers SSE connection
|
| 303 |
setActiveSessionId(data.session_id);
|
|
|
|
| 104 |
console.log('β
Analysis completed', data.result);
|
| 105 |
setIsTyping(false);
|
| 106 |
|
| 107 |
+
// Process the final result with the current session ID
|
| 108 |
if (data.result) {
|
| 109 |
+
processAnalysisResult(data.result, activeSessionId);
|
| 110 |
}
|
| 111 |
}
|
| 112 |
} catch (err) {
|
|
|
|
| 133 |
};
|
| 134 |
}, [activeSessionId]);
|
| 135 |
|
| 136 |
+
const processAnalysisResult = (result: any, sessionId: string) => {
|
| 137 |
// Extract and display the analysis result from SSE
|
| 138 |
let assistantContent = 'β
Analysis Complete!\n\n';
|
| 139 |
let reports: Array<{name: string, path: string}> = [];
|
|
|
|
| 198 |
plots
|
| 199 |
};
|
| 200 |
|
| 201 |
+
// Get current session and add message
|
| 202 |
+
setSessions(prev => prev.map(s => {
|
| 203 |
+
if (s.id === sessionId) {
|
| 204 |
+
return { ...s, messages: [...s.messages, assistantMessage], updatedAt: new Date() };
|
| 205 |
+
}
|
| 206 |
+
return s;
|
| 207 |
+
}));
|
| 208 |
};
|
| 209 |
|
| 210 |
const handleSend = async () => {
|
|
|
|
| 291 |
const data = await response.json();
|
| 292 |
|
| 293 |
// Store UUID from backend to trigger SSE connection
|
| 294 |
+
if (data.session_id) {
|
| 295 |
console.log(`π Session UUID from backend: ${data.session_id}`);
|
| 296 |
|
| 297 |
+
// Simply update the session ID - no migration needed
|
| 298 |
+
// The session already exists with id='1', just change its id to the UUID
|
| 299 |
+
setSessions(prev => prev.map(s =>
|
| 300 |
+
s.id === activeSessionId ? { ...s, id: data.session_id } : s
|
| 301 |
+
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
// Switch to the backend UUID session - this triggers SSE connection
|
| 304 |
setActiveSessionId(data.session_id);
|