Skip to content

Fix presence indicators not showing without cache #32880

Merged
t3chguy merged 2 commits intoelement-hq:developfrom
DLCSharp:fix/presence-indicator-initial-sync
Mar 23, 2026
Merged

Fix presence indicators not showing without cache #32880
t3chguy merged 2 commits intoelement-hq:developfrom
DLCSharp:fix/presence-indicator-initial-sync

Conversation

@DLCSharp
Copy link
Copy Markdown
Contributor

@DLCSharp DLCSharp commented Mar 20, 2026

Tested on Element Web v1.12.12, local dev server.
This issue does not happen on v1.12.2. There were changes to how the room list is rendered, which I believe to be impacting load timing.

Summary

Presence indicators in the DM room list do not appear on initial login (when the room is not in the sync cache).
When a room gets put in cache - for example by sending a message in the room -, the presence indicator for this room will appear on next refresh and update correctly from this point on.

Root cause

During initial sync, RoomMember.user is not yet linked to the User object when the room list renders. The usePresence hook reads presence from member.user, which is null at that point.
The user object exists in client store (client.getUser()), but the hook doesn't fall back to it.

From my understanding, the room list renders before the SDK can link RoomMember.user which causes this issue. On subsequent loads, the user objects are available early enough for the linking to succeed thanks to the cache.

So, we end up with at least some rooms not having their presence rendered :

prepatch_presence

Fixes

  • In getPresence, we fall back to client.getUser(member.userId) when member.user is not linked.
  • We also listen to the client-level UserEvent.Presence to catch presence update events when member.user is null since the event listener cannot subscribe to it.

With these fixes, we end up with all 1:1 DM rooms having their presence rendered :

image

Notes

I believe the same linking issue also affects DM avatars on the first page load since they only render after a subsequent reload in Web.
If I am correct, the proper long-term fix should probably be in the SDK itself.

@DLCSharp DLCSharp requested a review from a team as a code owner March 20, 2026 23:18
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane, thanks

@t3chguy t3chguy added this pull request to the merge queue Mar 23, 2026
Merged via the queue into element-hq:develop with commit 54d3ab9 Mar 23, 2026
45 of 47 checks passed
@DLCSharp
Copy link
Copy Markdown
Contributor Author

No problem, happy to be of help

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

Labels

T-Defect Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants