Spaces:
Running
Running
axeronis commited on
Commit ·
389e2f7
1
Parent(s): f0811af
fix: use onLeadRefresh for summary updates to avoid chat reload and spinner
Browse files
frontend/app/chats/page.tsx
CHANGED
|
@@ -101,6 +101,18 @@ function ChatsContent() {
|
|
| 101 |
}
|
| 102 |
}
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
// Delete Lead Handler
|
| 105 |
const handleDeleteLead = async (leadId: string, clearCache: boolean) => {
|
| 106 |
try {
|
|
@@ -203,6 +215,7 @@ function ChatsContent() {
|
|
| 203 |
isLoading={messagesLoading}
|
| 204 |
isAnalyzing={selectedLead.processing_status === 'analyzing'}
|
| 205 |
onRefresh={handleRefresh}
|
|
|
|
| 206 |
onTakeover={() => { }}
|
| 207 |
onBack={() => {
|
| 208 |
// Clear selection to return to list on mobile
|
|
|
|
| 101 |
}
|
| 102 |
}
|
| 103 |
|
| 104 |
+
// Refresh only lead data (for AI summary updates) - doesn't reload messages
|
| 105 |
+
const handleRefreshLeadOnly = async () => {
|
| 106 |
+
await refetchLeads()
|
| 107 |
+
// Update selectedLead from fresh data without reloading messages
|
| 108 |
+
if (selectedLead && leads) {
|
| 109 |
+
const updated = leads.find((l: Lead) => l.id === selectedLead.id)
|
| 110 |
+
if (updated) {
|
| 111 |
+
setSelectedLead(updated)
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
// Delete Lead Handler
|
| 117 |
const handleDeleteLead = async (leadId: string, clearCache: boolean) => {
|
| 118 |
try {
|
|
|
|
| 215 |
isLoading={messagesLoading}
|
| 216 |
isAnalyzing={selectedLead.processing_status === 'analyzing'}
|
| 217 |
onRefresh={handleRefresh}
|
| 218 |
+
onLeadRefresh={handleRefreshLeadOnly}
|
| 219 |
onTakeover={() => { }}
|
| 220 |
onBack={() => {
|
| 221 |
// Clear selection to return to list on mobile
|
frontend/components/ChatWindow.tsx
CHANGED
|
@@ -30,6 +30,7 @@ interface ChatWindowProps {
|
|
| 30 |
isLoading?: boolean
|
| 31 |
isAnalyzing?: boolean
|
| 32 |
onRefresh?: () => void
|
|
|
|
| 33 |
onTakeover?: () => void
|
| 34 |
onBack?: () => void
|
| 35 |
onToggleLeadsList?: () => void
|
|
@@ -72,6 +73,7 @@ export function ChatWindow({
|
|
| 72 |
isLoading,
|
| 73 |
isAnalyzing,
|
| 74 |
onRefresh,
|
|
|
|
| 75 |
onTakeover,
|
| 76 |
onBack,
|
| 77 |
onToggleLeadsList,
|
|
@@ -150,8 +152,8 @@ export function ChatWindow({
|
|
| 150 |
// When lead data is updated (e.g., name extracted), refresh to update AI Summary
|
| 151 |
onLeadUpdated: (updatedLead) => {
|
| 152 |
console.log('📋 WebSocket: Lead updated', updatedLead?.name)
|
| 153 |
-
//
|
| 154 |
-
onRefresh?.()
|
| 155 |
}
|
| 156 |
})
|
| 157 |
|
|
|
|
| 30 |
isLoading?: boolean
|
| 31 |
isAnalyzing?: boolean
|
| 32 |
onRefresh?: () => void
|
| 33 |
+
onLeadRefresh?: () => void // Refresh only lead data, not messages
|
| 34 |
onTakeover?: () => void
|
| 35 |
onBack?: () => void
|
| 36 |
onToggleLeadsList?: () => void
|
|
|
|
| 73 |
isLoading,
|
| 74 |
isAnalyzing,
|
| 75 |
onRefresh,
|
| 76 |
+
onLeadRefresh,
|
| 77 |
onTakeover,
|
| 78 |
onBack,
|
| 79 |
onToggleLeadsList,
|
|
|
|
| 152 |
// When lead data is updated (e.g., name extracted), refresh to update AI Summary
|
| 153 |
onLeadUpdated: (updatedLead) => {
|
| 154 |
console.log('📋 WebSocket: Lead updated', updatedLead?.name)
|
| 155 |
+
// Use lead-only refresh to avoid reloading messages (no spinner)
|
| 156 |
+
onLeadRefresh?.() || onRefresh?.()
|
| 157 |
}
|
| 158 |
})
|
| 159 |
|