fix(latest-events): subscribe event cache so LatestEvents subsystem runs #64

Merged
jlxq0 merged 1 commit from fix/event-cache-subscribe into main 2026-05-16 17:25:38 +00:00
jlxq0 commented 2026-05-16 17:13:39 +00:00 (Migrated from github.com)

Summary

One-line fix. matrix-sdk 0.17's /sync handler only feeds the LatestEvents subsystem when Client::event_cache().has_subscribed() returns true (see matrix-sdk-0.17/src/sync.rs:362). Without calling event_cache().subscribe() at client init the entire LatestEvents pool stays empty and Room::latest_event() returns LatestEventValue::None for every encrypted room.

This is the same subscription Element X performs via its RoomListService at startup.

User-visible effect

Before:
```json
{
"display_name": "Nathalie Shen-Picotte",
"unread_notifications": 2,
"latest_event_id": null,
"latest_sender": null,
"latest_origin_server_ts": null
}
```

After: same counts, populated event id / sender / timestamp so the MCP client can render a preview.

Test plan

  • CI green (cargo fmt, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all-features --locked, cargo audit, cargo deny, docker build)
  • Deploy v0.2.4 to `matrix-mcp.kampong.social` and call `get_unread_summary` from claude.ai – `latest_event_id` and `latest_sender` should be populated for E2EE rooms.

🤖 Generated with Claude Code

## Summary One-line fix. matrix-sdk 0.17's `/sync` handler only feeds the LatestEvents subsystem when `Client::event_cache().has_subscribed()` returns true (see `matrix-sdk-0.17/src/sync.rs:362`). Without calling `event_cache().subscribe()` at client init the entire LatestEvents pool stays empty and `Room::latest_event()` returns `LatestEventValue::None` for every encrypted room. This is the same subscription Element X performs via its `RoomListService` at startup. ## User-visible effect Before: \`\`\`json { \"display_name\": \"Nathalie Shen-Picotte\", \"unread_notifications\": 2, \"latest_event_id\": null, \"latest_sender\": null, \"latest_origin_server_ts\": null } \`\`\` After: same counts, populated event id / sender / timestamp so the MCP client can render a preview. ## Test plan - [ ] CI green (`cargo fmt`, `cargo clippy --all-targets --all-features -- -D warnings`, `cargo test --all-features --locked`, `cargo audit`, `cargo deny`, `docker build`) - [ ] Deploy v0.2.4 to \`matrix-mcp.kampong.social\` and call \`get_unread_summary\` from claude.ai – \`latest_event_id\` and \`latest_sender\` should be populated for E2EE rooms. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No description provided.