Skip to content

fix(channels): restore multi-room listening for Matrix allowed_rooms#4700

Closed
rareba wants to merge 1 commit intozeroclaw-labs:masterfrom
rareba:fix/4658-matrix-multi-room-listen
Closed

fix(channels): restore multi-room listening for Matrix allowed_rooms#4700
rareba wants to merge 1 commit intozeroclaw-labs:masterfrom
rareba:fix/4658-matrix-multi-room-listen

Conversation

@rareba
Copy link
Copy Markdown
Contributor

@rareba rareba commented Mar 25, 2026

Summary

  • When allowed_rooms is configured, the Matrix bot now listens and responds in all listed rooms, not just the single room_id
  • When allowed_rooms is empty, behavior is unchanged (single room_id only)
  • Reply routing was already correct — replies use the originating room's ID

Root cause

The event handler had two sequential checks: first room_matches_target (rejecting anything not from room_id), then is_room_allowed_static. Since the first check already rejected messages from other rooms, the second was dead code for multi-room scenarios. Commit 0051a0c2 re-introduced this regression.

Fix

Replaced the two sequential checks with a single combined check:

let room_accepted = if allowed_rooms.is_empty() {
    // Backward compatible: single room_id
    MatrixChannel::room_matches_target(target_room, incoming)
} else {
    // Multi-room: any room in allowed_rooms
    MatrixChannel::is_room_allowed_static(&allowed_rooms, incoming)
};

Files changed

  • src/channels/matrix.rs — combined room filter logic + improved startup log

Test plan

  • allowed_rooms = [] + room_id set: bot listens in single room only (unchanged)
  • allowed_rooms = ["!room1:srv", "!room2:srv"]: bot responds in both rooms
  • Messages from unlisted rooms are still rejected
  • Replies route to the correct originating room

Closes #4658

Closes zeroclaw-labs#4658

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added channel Auto scope: src/channels/** changed. channel:matrix Auto module: channel/matrix changed. labels Mar 25, 2026
@singlerider singlerider mentioned this pull request Mar 25, 2026
20 tasks
@singlerider
Copy link
Copy Markdown
Collaborator

This looks to be in competition with a PR I previously opened (#4674).

@rareba
Copy link
Copy Markdown
Contributor Author

rareba commented Mar 26, 2026

Understood — happy to defer to #4674 if it covers the same multi-room listening fix. Thanks for flagging the overlap!

@theonlyhennygod
Copy link
Copy Markdown
Collaborator

Hey — this PR currently has failing CI checks. Could you rebase against current master and fix the failing checks so we can review and merge? Run cargo fmt --all -- --check && cargo clippy --all-targets -- -D warnings && cargo test locally before pushing. Thanks!

@singlerider
Copy link
Copy Markdown
Collaborator

Hi — I've been tracking the issues in the Matrix friction tracker (#4657) and am waiting on these fixes to land. If this PR isn't actively being maintained toward merge (responding to review feedback, rebasing, etc.), I'll submit a competing PR to make sure the fix gets in. Happy to collaborate if you're still working on it!

@rareba
Copy link
Copy Markdown
Contributor Author

rareba commented Mar 28, 2026

Hi @singlerider — this PR is being deferred in favor of #4674 which covers the same multi-room listening fix. Feel free to go ahead with your competing PR if #4674 needs further work. I won't be maintaining this one. Recommending closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel:matrix Auto module: channel/matrix changed. channel Auto scope: src/channels/** changed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Matrix multi-room listening scoped to single room_id despite allowed_rooms config

3 participants