Add real-time activity tracking for active game sessions#3272
Draft
gantoine wants to merge 1 commit into
Draft
Conversation
Add live tracking of which users are actively playing which games, covering
both browser-based EmulatorJS sessions and external devices via a heartbeat
endpoint. Surfaces activity on a dedicated /activity page and as an indicator
on individual game detail pages.
Backend
- New handler/activity_handler.py stores ephemeral "now playing" state in
Redis with a 90s TTL keyed by (user_id, device_id), plus a per-ROM reverse
index for fast lookup.
- New endpoints/activity.py exposes GET /api/activity, GET /api/activity/rom/{id},
and POST /api/activity/heartbeat (for external devices).
- New endpoints/sockets/activity.py handles browser activity:start /
activity:heartbeat / activity:stop events, broadcasts activity:update /
activity:clear to all connected clients, and cleans up on socket disconnect.
Frontend
- Pinia activity store syncs via Socket.IO and provides per-ROM getters.
- ActivePlayers component on GameDetails shows who is currently playing a
title, with avatar tooltips.
- New Activity view lists every live session with game cover, user, platform,
and elapsed time.
- ActivityBtn in MainAppBar with a live-count badge routes to the page.
- EmulatorJS Player emits start/heartbeat/stop events and tears down the
heartbeat interval on exit.
No DB migration required; all state is Redis-resident.
https://claude.ai/code/session_01WzWu5XEEYcAc3EJcfteiFd
Contributor
Contributor
Contributor
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds comprehensive real-time activity tracking to display which users are currently playing games across the platform. The feature includes:
Backend Changes:
ActivityHandlerclass that stores ephemeral play session state in Redis with automatic TTL expiration (90 seconds, refreshed by heartbeats)activity:start,activity:heartbeat,activity:stop, anddisconnectto manage browser-based activity/activity/heartbeatand clear activity viaDELETE /activity/heartbeatFrontend Changes:
Activity.vueview displaying all currently active play sessions in a card grid with user avatars, ROM covers, platform info, and elapsed timeActivePlayers.vuecomponent showing live players on individual ROM detail pagesActivityBtn.vuenavigation button with badge showing active session countactivity.ts) managing real-time state via Socket.IO events (activity:update,activity:clear)Key Features:
The implementation uses Redis for ephemeral storage with automatic cleanup, ensuring no manual session management is required.
https://claude.ai/code/session_01WzWu5XEEYcAc3EJcfteiFd