DEBUG: Add extensive logging to diagnose Matrix message leakage

- Added detailed logging to useSessionSharing Matrix listener setup check
- Added critical debug logging to ChatInput before calling useSessionSharing
- Enhanced Matrix room detection logging with timestamps
- This will help identify why regular chats are still receiving Matrix messages

The issue appears to be that regular chat sessions might be getting
initialRoomId values when they shouldn't, causing Matrix listeners
to be set up for non-Matrix chats.
This commit is contained in:
spencrmartin
2025-11-21 09:52:46 -05:00
parent 7dca0c2494
commit 1a5530c4bd
2 changed files with 23 additions and 1 deletions
+9
View File
@@ -421,6 +421,15 @@ export default function ChatInput({
}
});
// CRITICAL DEBUG: Log what we're actually passing to useSessionSharing
console.log('🚨 ChatInput: About to call useSessionSharing with:', {
sessionId: sessionId,
initialRoomId: actualMatrixRoomId,
isMatrixRoom: isMatrixRoom,
shouldSetupMatrixListeners: !!actualMatrixRoomId,
timestamp: new Date().toISOString()
});
// Get Matrix context for current user information
const { currentUser } = useMatrix();
+14 -1
View File
@@ -138,7 +138,20 @@ export const useSessionSharing = ({
// CRITICAL FIX: Only set up Matrix listeners if this session actually has a Matrix room
// This prevents Matrix messages from leaking into regular chats
if (!stateRef.current.roomId && !initialRoomId) {
// Check both current state and initialRoomId parameter
const currentRoomId = stateRef.current.roomId;
const hasMatrixRoom = !!(currentRoomId || initialRoomId);
console.log('🔍 useSessionSharing: Matrix listener setup check:', {
sessionId,
currentRoomId,
initialRoomId,
hasMatrixRoom,
stateIsShared: stateRef.current.isShared,
willSetupListeners: hasMatrixRoom
});
if (!hasMatrixRoom) {
console.log('🚫 useSessionSharing: No Matrix room ID - skipping Matrix listener setup for regular chat session:', sessionId);
return;
}