- GET /games/me/active and /games/me (Bearer token), /games/popular (live games, or the most spectated finished ones), and /game/:id now also returns saved records of finished games - Lists are cached in Valkey for 10 seconds, cleared when a game is saved, and empty instead of failing while the database is down - Live game previews over WebSocket: subscribers get the top 5 on subscribe and on change, at most once per second, without counting as spectators; ids are public ids - RTMT supports several connection listeners
2.0 KiB
2.0 KiB
Game history and live games: tasks
Work through the tasks in order; each ends with its tests passing and a commit. Tick a task when it is committed.
- 1. Infrastructure:
postgresservice with init script for thekeycloakandmancaladatabases (replacingkeycloak-db),valkeyservice, backendDATABASE_URL/VALKEY_URL,.envvariables, README. - 2. Core types and history helpers:
PlayerSummary,MoveRecord, summaries,GameRecord,TURN_TIMEOUT_MS, new channels,offlineSince;getInitialBoard,getBoardAfterMove,describeMove,createGameAtMovewith unit tests; localized strings. - 3. Backend fixes: remove spectators on disconnect, remove finished games from memory, send the connection info once at game start.
- 4. Postgres repository: pool, migration runner,
gamesandgame_players,PostgresGameHistoryRepository(save, get, recent for user, popular), integration tests. - 5. Valkey store: live game snapshots and restore, pending saves, cache; integration tests.
- 6. Game lifecycle: start and move times, spectator counters, outcomes (completed, left, timeout, inactive),
timeout watcher,
offlineSince, rejecting a new game while playing, saving with retry, restore on startup; unit tests. - 7. API: public ids, Bearer auth middleware,
/games/me/active,/games/me,/games/popular,/game/:idfor finished games, live games channel with throttled push; tests. - 8. Board size:
--board-unitinBoardView,PitView,StoreView,StoneView;widthprop. - 9. Home page:
ActiveGameBanner,LiveGamesSectionwith live updates,RecentGamesSection; lobby rejection message. - 10. Live game history:
MoveList, review mode withReviewBannerand keyboard, timeout countdown. - 11. Replay:
ReplayViewwith controls, speed, timeline,?move=, own-side orientation, duration. - 12. End to end and docs: Chrome tests from
design.md, README andTODO.mdupdates.