Commit Graph

1 Commits

Author SHA1 Message Date
Claude
227ae0fa41 feat: real-time user game activity monitoring
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
2026-04-16 12:18:36 +00:00