Skip to content

feat(presence): add presence badges to the DM list and account switcher#608

Draft
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:feat/presence-sidebar-badges
Draft

feat(presence): add presence badges to the DM list and account switcher#608
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:feat/presence-sidebar-badges

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

Related to closed PR #598 (fix/perf-rerender-reduction), which was split into smaller focused PRs.

Description

Adds visual presence indicators (online / busy / offline dot) to DM list entries in the sidebar and to the account switcher avatar.

Also fixes presence under sliding sync. Sliding sync (MSC4186) does not deliver m.presence events, so User.presence stays at the SDK default and getLastActiveTs() stays 0 for all contacts. When no cached presence is available, the hook now falls back to GET /_matrix/client/v3/presence/{userId}/status and updates the badge once the response arrives. If the server returns 404 (presence not enabled), the error is silently ignored and existing state is kept.

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

The REST presence fallback logic in useUserPresence and the badge rendering in DirectDMsList/AccountSwitcherTab were partially AI assisted. I reviewed the sliding sync limitation, verified server error handling, and confirmed the cancelled flag guards the async fetch correctly on unmount.

…resence data

- DirectDMsList: show PresenceBadge on DM avatar — actual presence for 1:1 DMs,
  green dot when any participant is online for group DMs
- AccountSwitcherTab: show PresenceBadge on own account avatar in sidebar
- Fix AvatarPresence placement: move wrapper outside SidebarAvatar (overflow:hidden
  was clipping the badge)
- useUserPresence: reset presence state when userId changes; add REST fallback for
  sliding sync (Synapse MSC4186 has no presence extension so m.presence events are
  never delivered via sync — GET /presence/:userId/status bootstraps the initial state)
- ClientNonUIFeatures: explicitly PUT /presence/:userId/status on visibility change
  so the server records online/offline state; setSyncPresence is a no-op on MSC4186
@Just-Insane Just-Insane requested review from 7w1 and hazre as code owners March 31, 2026 18:43
@Just-Insane Just-Insane marked this pull request as draft March 31, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant