From eaa39ca49ebc8f09a822bb1bee0fc60fe2869a25 Mon Sep 17 00:00:00 2001 From: spencrmartin Date: Fri, 21 Nov 2025 15:03:43 -0500 Subject: [PATCH] Fix Matrix message deduplication - only mark as processed after successful display - Moved processedMessages.current.add() to AFTER onMessageSync call - Prevents messages from being marked as processed when they fail to display - Fixes issue where messages were skipped due to premature deduplication --- ui/desktop/src/hooks/useSessionSharing.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/desktop/src/hooks/useSessionSharing.ts b/ui/desktop/src/hooks/useSessionSharing.ts index fd0d60e247..4f9bc1ab1b 100644 --- a/ui/desktop/src/hooks/useSessionSharing.ts +++ b/ui/desktop/src/hooks/useSessionSharing.ts @@ -558,8 +558,7 @@ export const useSessionSharing = ({ return; } - // Mark this message as processed - processedMessages.current.add(messageKey); + // DON'T mark as processed yet - wait until we successfully call onMessageSync // ULTRA-STRICT SESSION MESSAGE FILTERING: Only process if ALL room IDs match exactly const isMatrixRoom = sessionId && sessionId.startsWith('!'); @@ -678,6 +677,10 @@ export const useSessionSharing = ({ if (onMessageSync && hasExplicitMatrixRoomId) { console.log('✅ CALLING onMessageSync FROM GOOSE SESSION SYNC - Matrix room explicitly configured'); onMessageSync(message); + + // Mark as processed ONLY after successfully calling onMessageSync + processedMessages.current.add(messageKey); + console.log('✅ Marked message as processed:', messageKey); } else { console.log('🚫 BLOCKING onMessageSync FROM GOOSE SESSION SYNC - No explicit Matrix room configuration', { hasOnMessageSync: !!onMessageSync,