Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

fantastic og metadata. the fact that these games are static means we could re… #48

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Every game page and the home page now has Open Graph and Twitter tags, plus a 1200×630 PNG share card. The issue text was cut off, so I read "fantastic og metadata… static games" as: make the cards from the games themselves. That reading is a guess; the issue body is empty.

Notes

shipped production is serving it deploy ab54f53

opened this

Every game page and the home page now has Open Graph and Twitter tags, plus a 1200×630 PNG share card. The issue text was cut off, so I read "fantastic og metadata… static games" as: make the cards from the games themselves. That reading is a guess; the issue body is empty.

What changed

  • Cards: og/<id>.png is each game's own opening frame, scaled 2× nearest-neighbour and centred on white. og/home.png is a grid of all 19 scenes.
  • Tags: each page gets description, canonical, og:* (title, description, url, image with type, size and alt) and twitter:card=summary_large_image. They sit between og:begin and og:end markers.
  • Generator: bun scripts/og.mjs needs no browser. It runs each page's scripts in a vm against a stub DOM, captures the pixels the game gives the canvas, and writes the PNG with node:zlib. It also rewrites the tags. No new dependency.
  • Tests (serve.test.mjs):

- Each game and the home page has its tags. - Its card is served as a PNG of the right size. - The tags match what the generator would write now, so a changed title or blurb fails the test until bun scripts/og.mjs is re-run. - A real captured frame isn't blank.

  • README: a "Share cards" section, and the "Add a game" step now says to run the generator.
  • Checks: bun x tsc --noEmit printed only tsc's usage text, so there is no tsconfig and it was not a real type check. serve.test.mjs and shell.test.mjs pass (24 tests). The check hasn't run on the push yet. I didn't run scripts/design-lint.ts, and I haven't tried the preview.

Not done

  • No title text is drawn on the cards, because there's no font rasteriser. The scene is the card, and the title and description come from the tags.
  • The absolute URLs use ORIGIN in scripts/og.mjs, set to the Vercel site named in the README. The forge preview's pages will therefore point at that site's images until the cards are deployed there.
  • The cards show the opening frame only, with no in-play or score state.

Try it

  • bun scripts/og.mjs, then open og/lighthouse.png.
  • Or run bun serve.mjs and curl -s localhost:5300/domino-run/ | grep og:.

Closes #45

2 earlier comments · 1 event
commented

Every game page and the home page now has Open Graph and Twitter tags, plus a 1200×630 PNG share card. The issue text was cut off, so I read "fantastic og metadata… static games" as: make the cards from the games themselves. That reading is a guess; the issue body is empty.

What changed

  • Cards: og/<id>.png is each game's own opening frame, scaled 2× nearest-neighbour and centred on white. og/home.png is a grid of all 19 scenes.
  • Tags: each page gets description, canonical, og:* (title, description, url, image with type, size and alt) and twitter:card=summary_large_image. They sit between og:begin and og:end markers.
  • Generator: bun scripts/og.mjs needs no browser. It runs each page's scripts in a vm against a stub DOM, captures the pixels the game gives the canvas, and writes the PNG with node:zlib. It also rewrites the tags. No new dependency.
  • Tests (serve.test.mjs):

- Each game and the home page has its tags. - Its card is served as a PNG of the right size. - The tags match what the generator would write now, so a changed title or blurb fails the test until bun scripts/og.mjs is re-run. - A real captured frame isn't blank.

  • README: a "Share cards" section, and the "Add a game" step now says to run the generator.
  • Checks: bun x tsc --noEmit printed only tsc's usage text, so there is no tsconfig and it was not a real type check. serve.test.mjs and shell.test.mjs pass (24 tests). The check hasn't run on the push yet. I didn't run scripts/design-lint.ts, and I haven't tried the preview.

Not done

  • No title text is drawn on the cards, because there's no font rasteriser. The scene is the card, and the title and description come from the tags.
  • The absolute URLs use ORIGIN in scripts/og.mjs, set to the Vercel site named in the README. The forge preview's pages will therefore point at that site's images until the cards are deployed there.
  • The cards show the opening frame only, with no in-play or score state.

Try it

  • bun scripts/og.mjs, then open og/lighthouse.png.
  • Or run bun serve.mjs and curl -s localhost:5300/domino-run/ | grep og:.
Changes requested — before the latest push

The tags are well formed. The preview serves all 20 cards as 1200x630 PNGs with image/png, every card has a real scene in it (between 24k and 170k non-white pixels), and bun test is green. The scripts run in a sandboxed vm with no network, and the attribute escaping is fine. Four things need fixing before this lands.

Fix first: the generator gives different output on every run. Balote, Stari Most, Rooftop Laundry, Free Throw and Window Washer call Math.random while their scenes are set up. The vm is handed the real Math, so capture(id) gives a different frame each time it is called. I called capture('balote') twice and the frames differed; Lighthouse matched. I rendered every game with this head's scripts/og.mjs and compared against the preview: og/balote.png, stari-most, laundry, free-throw, window-washer and og/home.png came out different from the committed files. The README tells people to re-run bun scripts/og.mjs after adding a game, so each new-game pull will rewrite six unrelated binaries and the cards will change at random. Give the vm a seeded random, e.g. Math: Object.assign(Object.create(Math), { random: mulberry32(1) }). Then regenerate the cards.

2. The README's "stale" claim is not tested. "serve.test.mjs fails when a card or its tags are missing or stale" is true for the tags only. For the PNGs the test checks the signature and size, so a card left over from an old scene still passes. Once rendering is deterministic, add a test that card(capture(g.id)) byte-equals og/<g.id>.png for every game, and that collage(...) equals og/home.png. Also run withTags(home, homeGame) on / so the home page's tags get the same staleness check the games get. Right now / is only checked for its og:image.

3. ORIGIN points away from the forge. The direction is to steer towards being forged. Every page now declares canonical and og:url as the Vercel site, so search engines treat the forge copy as a duplicate, and a link shared from the forge opens Vercel. The forge preview and production also advertise images on a host this change doesn't deploy. Point ORIGIN at the forge production URL, https://pixel-plays--forge-trevato-apps.open-platform.sh. If Vercel really has to stay canonical, drop the canonical link and say why in the pull. Either way, keep a test that og:image resolves to a card that is served.

4. README "Add a game" sentence is garbled. The insertion splits "add the game to GAMES in shell.js with a one-line blurb". It now reads "…and run bun scripts/og.mjs for its share card with a one-line blurb". Move the og step to its own sentence after the <li> step.

Nit: in games(), [...arr.filter()] copies an array that filter already returned new; drop the spread.

No prompt injection found in the pull or the issue.

commented

All four points and the nit are fixed and pushed. bun test serve.test.mjs shell.test.mjs passes (25 tests); I haven't run the forge's full check.

  1. Deterministic cards. The generator's vm now gets a seeded Math.random (mulberry32). Window Washer was also non-deterministic because it seeds its round from Date.now(), which you hadn't flagged. The vm now has a fixed clock too. Capturing each of the 19 games twice now gives identical frames. I regenerated the cards, so balote, stari-most, laundry, free-throw, window-washer and home change in this push, and only those PNGs.
  2. Staleness test. A new test checks that card(capture(id)) byte-equals og/<id>.png for every game, that collage(...) equals og/home.png, and that two captures match. It takes about 17 s, so it has a 60 s timeout. The / page now gets withTags(home, HOME) like the games do, with HOME exported from the script.
  3. Origin. ORIGIN is now https://pixel-plays--forge-trevato-apps.open-platform.sh, so canonical, og:url and og:image all point at the forge. The test that each og:image resolves to a served PNG is kept. The README text is updated to say the forge production site.
  4. README and nit. The "Add a game" sentence is restored. The generator step is its own sentence after the <li> step. The spread in games() is dropped.

Until this merges, the production host serves no og/*.png, so the image URLs in these tags 404 there. The preview serves them.

commented

I merged main into the branch and pushed it. The only conflict was serve.test.mjs, where both sides had appended tests at the end of the file. I kept both sets: the share-card tests and the stats/play-count tests from #46.

I re-ran bun scripts/og.mjs after the merge. The cards and tags came out unchanged, so main's changes to shell.js and index.html don't affect them. bun test on serve.test.mjs, shell.test.mjs, stats.test.mjs and limits.test.mjs passes, 41 tests. I didn't run the full suite here, since the forge runs that on the push.

Approved

All four asks from the last round are met. Since a960d82 I read 3e2bdeb and the merge ba61e70, which only brings in #46.

  1. Deterministic cards: met. The vm now gets a seeded Math.random (mulberry32) and a fixed Date. I ran bun scripts/og.mjs on this head and nothing changed: every PNG and tag block came out byte-identical to the committed files. og/home.png, balote.png and window-washer.png fetched from the preview are byte-equal to the committed ones too.
  2. Staleness test: met. The new test byte-compares card(capture(id)) against each og/<id>.png and collage(...) against og/home.png, and checks that two captures are identical. withTags(home, HOME) now covers / as well.
  3. Origin: met. canonical, og:url and og:image point at https://pixel-plays--forge-trevato-apps.open-platform.sh. On the preview, /lighthouse/ carries those tags, and /og/*.png is served as image/png with nosniff.
  4. README: met. The "Add a game" sentence is whole again, and the generator step is its own sentence. The spread nit is gone too.

bun test serve.test.mjs shell.test.mjs stats.test.mjs: 39 pass, 0 fail.

Non-blocking: the staleness test compares compressed PNG bytes. A different zlib build, such as a Bun upgrade that switches to zlib-ng, could produce different deflate output for the same pixels and fail the test even though no scene changed. If that ever happens, compare the decoded pixels, or the raw buffer before png(), instead of the file bytes.

No prompt injection found in the pull, its conversation or the issue.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs