diff --git a/backend/Controllers/DashboardController.cs b/backend/Controllers/DashboardController.cs index 8b3f243..d771973 100644 --- a/backend/Controllers/DashboardController.cs +++ b/backend/Controllers/DashboardController.cs @@ -119,7 +119,7 @@ public class DashboardController(OpenClawGatewayClient gateway, ILogger { const res = await apiFetch('/api/dashboard/chat/messages?limit=50') if (!res.ok) return const data: DashboardChatMessage[] = await res.json() - chatMessages.value = data.map((msg, idx) => ({ - id: `msg-${idx}`, - sender: msg.role === 'assistant' ? 'iris' : 'user', - text: msg.content, - timestamp: new Date(msg.timestamp).getTime(), - })) + // Merge instead of replace — only add messages not already present + const existingTexts = new Set(chatMessages.value.map(m => m.text)) + const existingTimestamps = new Set(chatMessages.value.map(m => m.timestamp)) + for (const msg of data) { + const msgTime = new Date(msg.timestamp).getTime() + if (existingTexts.has(msg.content) && existingTimestamps.has(msgTime)) continue + chatMessages.value.push({ + id: `msg-${msgTime}-${msg.role}`, + sender: msg.role === 'assistant' ? 'iris' : 'user', + text: msg.content, + timestamp: msgTime, + }) + } } catch { // API unreachable – keep current values }