fix(matrix): remove member-count fallback from DM detection#30842
fix(matrix): remove member-count fallback from DM detection#30842arkyu2077 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
The DM heuristic treated any 2-person room as a direct message based solely on member count. This conflicts with the Matrix spec which uses explicit m.direct account data and is_direct member state to designate DMs. When a user has multiple 2-person rooms with the same participants, all were incorrectly classified as DMs, causing duplicate or out-of-context message routing. Remove the memberCount === 2 fallback and rely only on m.direct and is_direct member state for DM detection. Closes openclaw#30645
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d029220ce7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const memberCount = await resolveMemberCount(roomId); | ||
| log(`matrix: dm check room=${roomId} result=group members=${memberCount ?? "unknown"}`); | ||
| return false; |
There was a problem hiding this comment.
Keep 2-member rooms classified as DM fallback
This change makes isDirectMessage return false for any room where both client.dms.isDm() and is_direct state checks fail, even when the room has exactly two joined members. That creates a regression for valid 1:1 rooms when m.direct is absent or stale (a case already expected elsewhere: extensions/matrix/src/matrix/send/targets.ts explicitly treats missing m.direct as common and falls back to 2-member room discovery), so inbound DMs in those rooms can now be treated as group traffic and blocked by default group policy.
Useful? React with 👍 / 👎.
Greptile SummaryRemoves the non-spec-compliant Key changes:
Impact:
Confidence Score: 5/5
Last reviewed commit: d029220 |
Problem
createDirectRoomTrackerfalls back to treating any 2-person room as a DM based solely onmemberCount === 2. This conflicts with the Matrix spec, which designates DMs via explicitm.directaccount data andis_directmember state.When a user has multiple 2-person rooms with the same participants (e.g., a bot room and a topic-specific room), both are incorrectly classified as DMs, causing duplicate or out-of-context message routing.
Fix
Remove the
memberCount === 2fallback fromisDirectMessage(). DM detection now relies only on:client.dms.isDm()— checksm.directaccount datahasDirectFlag()— checksis_directonm.room.memberstate eventsThis aligns with the Matrix spec and prevents false-positive DM classification of regular 2-person rooms.
Closes #30645