Skip to content

feat: a shared scene's link shows a frame of the scene and its title (D565) - #118

Open
lnorton89 wants to merge 2 commits into
masterfrom
feat/share-card
Open

lnorton89 wants to merge 2 commits into
masterfrom
feat/share-card

Conversation

@lnorton89

Copy link
Copy Markdown
Owner

Pasted into a chat or a post, every /s/<id> link showed the sandbox's own card. Now it shows the scene.

  • Share sends a frame. cardFromCanvas (site/src/lib/play/card.ts) copies the canvas, crops the largest centred 1200x630 part, and encodes a JPEG under 160 KB, sent as card beside the scene.
  • The Worker keeps it beside the scene as cards/<id>.jpg (site/worker/share-card.ts). It is outside the content hash, so ids and old links are unchanged, and a scene keeps the first card it gets. Anything that is not a JPEG of the right size is dropped and the scene is still shared.
  • /s/<id> rewrites the page's social tags: the scene's title, its link, and /api/card/<id>.jpg when it has a card. A scene without one keeps the generic picture with its own title.

Decision D565; roadmap and site README updated (the README says how to delete a card with its scene).

Checked: site unit tests (340, including share-worker.test.ts, which drives the Worker's routes end to end against a fake bucket), tsc, eslint, and the conventions tests.

Not checked: the capture in a real browser, the full site build and Playwright smoke test, the deployed Worker, and a real link preview. Not deployed.

…(D565)

Share sends a 1200x630 JPEG of the canvas beside the scene. The Worker keeps it as cards/<id>.jpg, outside the content hash, first card kept, and /s/<id> rewrites the /play page's og and twitter tags with the scene's title, its link and, when it has one, /api/card/<id>.jpg.
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @lnorton89's task in 19s —— View job


Review of #118

The change is correct and well-tested for what it covers. I found no rule violations: there is no unsafe and no unwrap, and the decision (D565) and roadmap entries are present. I read the code only and did not run the tests. I found two things worth a look.

1. First-card-wins can be squatted (site/worker/share-card.ts, storeCard; site/worker/index.ts, share)

  • Scene ids are content hashes, so anyone who knows a scene's content can compute its id.
  • Someone can POST that scene first with a misleading JPEG. The real owner's later card is then silently ignored, because storeCard returns false once a card exists.
  • This probably fits D565's threat model, since the scene text is public anyway. Say so in D565 explicitly if it is accepted. The alternative is to let a card replace the previous one only when none exists, which is the current behaviour.

2. The "right size" check is only a magic-byte check (readCard)

  • The PR description says anything that is not a JPEG "of the right size" is dropped.
  • The code checks the FF D8 FF header, the FF D9 trailer and the base64 length. It never checks the 1200x630 dimensions.
  • A client can store any JPEG up to 160 KB, for example a tiny or enormous-dimension image.
  • Parsing the SOF marker for width and height would enforce it cheaply. Otherwise, reword the description and the card.ts comments.

Minor

  • setMeta only matches <meta property|name=… content=…> in that attribute order. The comment says a changed page degrades gracefully, which is true, but the share-card test would silently stop covering it if Astro reorders the attributes. Check that the built /play/ HTML still matches. Your "not checked" list already includes the full build.

Summary: the change is sound, with the two points above. I left no inline comments.
· branch feat/share-card

Its Linux CUDA binary began answering 404 and failed npm ci. The site runs CLIP in the browser (D560) and never uses it; the CPU binaries are kept.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant