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

OG cards as PNG, rasterized once per input hash under FORGE_APP_DATA, behind a deploy that stays up #1962

Parked opened this
Closed without merging

GET /og/{repo,app,issue,pull,run}/:ref.png now serves the existing public card as a 1200×630 PNG. tsc, bun test test/og-png.test.ts test/og-route.test.ts test/og-card.test.ts test/check-list.test.ts test/reserved-names.test.ts and scripts/gate.ts pass. I did not run the whole suite; the forge's check does that.

Notes

stopped parked by the crew deploy 028ff5f

opened this

GET /og/{repo,app,issue,pull,run}/:ref.png now serves the existing public card as a 1200×630 PNG. tsc, bun test test/og-png.test.ts test/og-route.test.ts test/og-card.test.ts test/check-list.test.ts test/reserved-names.test.ts and scripts/gate.ts pass. I did not run the whole suite; the forge's check does that.

What changed

  • The routes use the same refs, 404s and public-only rules as the .svg routes, with an ETag per input hash.
  • A PNG is rasterized once and kept at $FORGE_APP_DATA/og-png/<sha256 of inputs>.png. The cache holds at most 512 files (OG_PNG_CAP), and the least recently used are removed first. Concurrent first requests share one render.
  • The rasterizer loads on the first PNG request, not at boot. If it fails to load or render, the route logs and answers 503 with retry-after: 30. / and the .svg routes are unaffected, and a failed load is retried after 30 seconds. The tests cover this.
  • Cold takes about 120 ms and warm is a file read. test/og-png.test.ts asserts under 300 ms cold and under 5 ms warm, and it is listed in GATE.
  • forge.json is not edited. og was already a route prefix, so no reserved name was needed.
  • The rasterizer is resvg compiled to WebAssembly (@resvg/resvg-wasm 2.6.2, MPL-2.0). It comes with four DejaVu fonts: Sans, Sans Bold, Sans Mono and Sans Mono Bold. I looked at a rendered card; the text fits.

Decision for you: the dependency is vendored under src/web/og/vendor/ (about 4.5 MB, unmodified) rather than installed. forge.json has no install step, so an installed package would not exist in the preview, which is probably what killed the earlier tries. This also keeps dependencies empty, as CLAUDE.md requires. The README's new "OG cards as PNG" section gives the why, size and licence of each file.

Not done

  • The .svg routes are unchanged, and the PNG is a render of that SVG.
  • The rasterizer runs on the main thread, about 100 ms once per distinct card.
  • Nothing yet points og:image meta tags at the PNG.

To try it Run bun run src/main.ts, then fetch /og/repo/<owner>~<name>.png for a public repo. A second fetch comes from og-png/ in the data directory.

🤖 Generated with Claude Code

Closes #1803

commented

Parked by the crew: the check failed ("no tight wall-clock bound in a test > no test file bounds a request or a spawn below the floor") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs