From d633cdcd1fcbb60e9a0a30bb9ddf7abd121d6f10 Mon Sep 17 00:00:00 2001 From: spencrmartin Date: Mon, 17 Nov 2025 16:17:24 -0500 Subject: [PATCH] fix: improve Matrix session detection to prevent API calls in DMs - Fixed hasMatrixMapping logic to properly detect Matrix-backed sessions - Matrix room IDs check for direct mappings - Regular session IDs check if they're mapped FROM Matrix rooms - This prevents DM sessions from making OpenAI API calls - Only @goose mentions should trigger AI responses in DMs --- ui/desktop/src/hooks/useChatEngine.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/desktop/src/hooks/useChatEngine.ts b/ui/desktop/src/hooks/useChatEngine.ts index fcd516e124..b42624ea55 100644 --- a/ui/desktop/src/hooks/useChatEngine.ts +++ b/ui/desktop/src/hooks/useChatEngine.ts @@ -88,7 +88,11 @@ export const useChatEngine = ({ const matrixRoomId = sessionMappingService.getMatrixRoomId(chat.sessionId); // Check if this session has a Matrix mapping (indicating it's a Matrix-backed session) - const hasMatrixMapping = sessionMappingService.getMapping(chat.sessionId) !== null; + // For Matrix room IDs, check if a mapping exists + // For regular session IDs, check if they're mapped FROM a Matrix room + const hasMatrixMapping = isMatrixRoom + ? sessionMappingService.getMapping(chat.sessionId) !== null + : matrixRoomId !== null; // A session is collaborative if: // 1. It's a Matrix room ID (starts with !)