Repository navigation
Add user presence tracking and online status visibility - #884
aXenDeveloper wants to merge 3 commits into
Conversation
…e anonymously
- `core_users.lastSeenAt` and `core_users.hideOnlineStatus` with a migration
- `UserPresenceModel`: per-session leases in a Redis sorted set (one per
member, each session expiring on its own), bulk reads in one query and
one pipeline, throttled forward-only `lastSeenAt` writes; without Redis
presence falls back to `lastSeenAt` within the lease window
- `CacheModel` lease-set primitives: `renewLease`, `releaseLeases`,
`countLeases`, `isConfigured`
- API: `POST /users/presence/heartbeat`, `GET /users/{id}/presence`,
`POST /users/presence/batch`, `PUT /users/me/privacy` and
`GET /admin/users/{id}/presence`, all `private, no-store`
- `users:can_view_hidden_presence` for admins and moderators; one privacy
resolver for every read
- sign-out and device revocation end only that session's lease
- client: visibility-aware heartbeat shared across tabs, profile indicator,
"Browse anonymously" setting, AdminCP presence card and a reusable
`UserPresenceStatus` component
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0198jw2ioVCHrx7GaSPcZND3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0198jw2ioVCHrx7GaSPcZND3
…eartbeat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0198jw2ioVCHrx7GaSPcZND3
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found 1 new issue in 1 file · 1 warning · score 90 / 100 (Great) · 0 fixed · vs 1 warning
Reviewed by React Doctor for commit |
| onCheckedChange={async checked => { | ||
| setIsSaving(true); | ||
| const result = await onUpdate({ hideOnlineStatus: checked }); | ||
| setIsSaving(false); |
There was a problem hiding this comment.
React Doctor · react-doctor/no-loading-flag-reset-outside-finally (warning)
This resets a loading/busy flag only on the success path: if the awaited call rejects the reset never runs and the flag stays stuck truthy (a spinner that never stops, a button disabled forever). Move the reset into a finally block, or mirror it on every catch, so it clears on rejection too.
Fix → A trailing setLoading(false) after an await never runs if the awaited call rejects, so the flag stays stuck truthy; reset it in a finally block (or mirror the reset on every catch) so it clears on both paths.
Description
What?
This PR implements a comprehensive user presence system that tracks when users are online and last seen, with privacy controls to hide online status if desired.
Key features:
lastSeenAttimestamp andhideOnlineStatusprivacy flag on userscan_view_presencepermission can see hidden statusesNew API endpoints:
POST /api/users/presence/heartbeat- Update user presencePOST /api/users/presence/batch- Fetch presence for multiple usersPATCH /api/users/privacy- Update privacy settingsGET /api/admin/users/:id/presence- Admin endpoint for user presenceNew UI components:
UserPresenceStatus- Displays online/offline status with last seen timeWhy?
User presence is a fundamental feature for community platforms, allowing members to see who's online and when others were last active. This implementation provides:
The heartbeat approach keeps presence fresh without requiring persistent connections, and the batch endpoint prevents N+1 queries when displaying presence for multiple users.
https://claude.ai/code/session_0198jw2ioVCHrx7GaSPcZND3