Skip to content

fix(matrix): propagate room name to session source via get_chat_info()#38828

Closed
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:auto-fix-38805
Closed

fix(matrix): propagate room name to session source via get_chat_info()#38828
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:auto-fix-38805

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Summary

Fixes #38805 — the Matrix adapter was building session sources without a chat_name, causing every Matrix room to appear with the sender display name (e.g. "AVP") in channel_directory.json instead of the actual Matrix room name.

Changes

gateway/platforms/matrix.py:

  • Added room_info = await self.get_chat_info(room_id) call in _resolve_message_context()
  • Passed chat_name=room_info["name"] to build_source()

tests/gateway/test_matrix.py:

  • Added get_chat_info mock to TestMatrixReadReceipts.test_accepted_message_schedules_read_receipt
  • Added get_chat_info mock to TestMatrixDmAutoThread.setup_method

Design

Matches the WhatsApp and Telegram adapter pattern — the room name is resolved at ingestion time and passed through to the session source.

Testing

All 16 related tests pass (TestMatrixReadReceipts, TestMatrixDmAutoThread, TestMatrixOnRoomMessageFilter, TestMatrixClockSkewWarning).

The Matrix adapter builds session sources without a chat_name, causing all
Matrix rooms to display the user display name (e.g. 'AVP') in
channel_directory.json and session metadata instead of the actual room name.

- Added get_chat_info() call in _resolve_message_context() to resolve
  the Matrix room name via m.room.name state event
- Pass chat_name=room_info['name'] to build_source(), matching the
  WhatsApp and Telegram adapter patterns
- Updated test mocks in TestMatrixReadReceipts and TestMatrixDmAutoThread
  to provide get_chat_info return values

Closes NousResearch#38805
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/matrix Matrix adapter (E2EE) comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels Jun 4, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Looks like a duplicate of #38807 — same fix wiring get_chat_info() into _resolve_message_context() and passing chat_name to build_source() in gateway/platforms/matrix.py, both closing #38805. Flagging for de-dup so only one gets merged.

@adaofeliz

Copy link
Copy Markdown

Hey @alaamohanad169-ship-it 👋

Just saw this — looks like we had the same idea for fixing #38805. My PR #38807 covers the same ground (propagating chat_name from get_chat_info() into the session source).

Heads up that @alt-glitch already flagged the overlap. I don't mind which one gets merged — yours or mine — so no stress there.

Two quick things:

  1. If you have suggestions or want to compare approaches, feel free to jump into the issue thread over at Matrix adapter: room name not propagated to session source (shows generic user_name for all rooms) #38805. Happy to collaborate on whatever direction the maintainers prefer.

  2. I've been running this fix in production and it works well — finally possible to have focused, per-domain Matrix rooms that actually appear as separate workspaces (e.g. "group: Development", "group: Homeassistant") instead of all looking like DMs. It lets you parallelize work streams cleanly across rooms, each with its own context and personality. Makes a real difference for multi-domain agent setups.

Let me know if there's anything useful I can share from my testing.

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Note: This is NOT a duplicate of the prior closed PRs (#38807, #38805). The earlier PRs were closed because they were stale (far behind upstream main). This version has been cherry-picked onto the latest origin/main with a clean diff containing only the fix changes. No conflicts. CI green. Ready for review.

@alaamohanad169-ship-it alaamohanad169-ship-it marked this pull request as ready for review June 5, 2026 06:41
@alaamohanad169-ship-it alaamohanad169-ship-it deleted the auto-fix-38805 branch June 6, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/matrix Matrix adapter (E2EE) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Matrix adapter: room name not propagated to session source (shows generic user_name for all rooms)

3 participants