0029. Game thumbnails and play history
- Status: Accepted 2026-12-02 (owner decisions 2026-12-02)
- Date: 2026-12-02
- Phase: site redesign, step 2 (docs/design/site-redesign.md)
Context
Section titled “Context”The redesigned home page (featured game, “Popular now”, game cards, “Jump back in”) needs a picture for every game and to know what was played recently. Games have no pictures today, and plays are a single all-time counter.
Owner decisions (2026-12-02):
- Thumbnails are captured automatically when a game is published, and creators can upload their own cover. Games without one still appear, with a branded placeholder.
- Capture happens in the creator’s browser, not on the server: the production image has no browser, a headless one would add size and CPU on the shared VPS, and headless Chrome draws the 3D games blank.
- Play history is kept for signed-in players only (game, first and last played, count, optional progress); anonymous plays only bump counters. The privacy policy says so, and players can clear their history.
Decision
Section titled “Decision”Thumbnails
- One thumbnail per game (not per version):
game.thumbnail_key(blob key),thumbnail_source(captureorupload),thumbnail_updated_at. Blobs live underthumbnails/<gameId>/<sha256>.<ext>; the old blob is deleted when replaced. PUT /api/games/{slug}/thumbnail(owner only) takes a PNG, JPEG or WebP data URL of at most 1.5 MB. The server checks the magic bytes and reads the size from the header (320×180 to 3840×2160, landscape). Acapturenever replaces anupload(the creator’s own cover wins) unless the creator removes the upload first.DELETE /api/games/{slug}/thumbnailremoves it.GET /api/games/{slug}/thumbnailserves it from the web origin withnosniff, a fixed image content type and a long cache; game summaries carrythumbnailUrlwith the blob hash as the version (?v=), so a new picture is a new URL. Images are never SVG and are only shown in<img>.- Capture: the play bridge gains a request from platform to game,
capture, answered by the game with aframemessage (a JPEG data URL). The entry file the platform generates for every build answers it with the framework’scaptureFrame: a one-shot plugin that copies the canvas inafterFrame, straight after drawing (WebGL canvases are readable then), scaled to at most 1280×720. Games built before this change do not answer (the request times out); they get a thumbnail when rebuilt or from an upload. - Automatic captures (
capture): the editor captures the preview’s current frame when the creator publishes, and the game page captures a frame 4 s in when the owner opens a game that has no picture (this also covers games published by upload, the CLI or MCP). The creator’s own choices (upload): the editor’s “Use this frame as the picture” button, and “Upload an image” on the game’s settings page (re-encoded in the browser: cropped to 16:9, JPEG, at most 1280×720). The settings page also has “Remove”.
Play history
play_history(user_id, game_id, first_played_at, last_played_at, plays, progress), primary key (user, game), rows deleted with the user or the game. Written byPOST /api/games/{slug}/playswhen the caller is signed in.progress(≤ 80 characters, from the game) is reserved for a later step.game_play_day(game_id, day, plays)counts plays per UTC day for everyone (no user). “Popular” sorts by the last 7 days, then all-time plays.GET /api/me/historylists the signed-in player’s recent games (published and visible only);DELETE /api/me/historyclears it (button on the account page).
Consequences
Section titled “Consequences”- No server-side browser; 3D games get real thumbnails. A creator who never opens the editor or uploads a cover gets the placeholder until they do.
- Thumbnails are user content: they are covered by reports and moderation like the rest of a game, and removed with it.
- The five live demo games need a rebuild or uploaded covers after this deploys (owner’s OK for production).
- New personal data (which signed-in player played which game, when): listed in the privacy policy, deleted with the account, clearable by the player.