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

Share cards speak the home page's type and restraint, and each is checked as an image #9628

Merged opened this

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

Merged

Share-card text that doesn't fit is now shortened at a word with an ellipsis, and a new test renders every card kind to an image and measures the text. The `og-*` tests (125), `bun scripts/gate.ts` and `tsc --noEmit` pass. I didn't run the full suite.

shipped production is serving it deploy f21b126

opened this

Share-card text that doesn't fit is now shortened at a word with an ellipsis, and a new test renders every card kind to an image and measures the text. The og-* tests (125), bun scripts/gate.ts and tsc --noEmit pass. I didn't run the full suite.

  • Already done: the "PAGE" label, the left edge strip and the home page's type (bold, tight tracking, muted tagline) were already gone from src/web/og/card.ts. I only checked them.
  • Word cuts: fit in src/web/og/xml.ts now cuts at the last whole word and drops any trailing punctuation before the "…". A single word wider than the box is still cut inside the word, but it now ends in "…". The same rule applies to an over-long word inside a wrapped title in card.ts.
  • Image test: test/og-image.test.ts rasterizes every card kind with the vendored resvg and fonts. It uses short, long and unbroken-string inputs, each with and without a picture.

- It asserts the PNG is 1200×630. - It measures each text element's box and asserts it stays inside the 80 px margins, inside the words' column when a picture is present, and inside the card. - Separate fit tests cover the word cut and the over-long-word case. - The box measurements pass against the old code too, because its width estimate was already wide. Only the fit tests fail without the change.

  • Changed test: in test/og-cards.test.ts I shortened the expected prefix of the hostile-title check by one character ("scrip" to "scr"). The ellipsis now takes the last character of an over-long unbroken word, so the old prefix no longer matched.
  • Left out: the footer stat still runs full width under a picture, and the test allows that.

Closes #9578

commented

Share-card text that doesn't fit is now shortened at a word with an ellipsis, and a new test renders every card kind to an image and measures the text. The og-* tests (125), bun scripts/gate.ts and tsc --noEmit pass. I didn't run the full suite.

  • Already done: the "PAGE" label, the left edge strip and the home page's type (bold, tight tracking, muted tagline) were already gone from src/web/og/card.ts. I only checked them.
  • Word cuts: fit in src/web/og/xml.ts now cuts at the last whole word and drops any trailing punctuation before the "…". A single word wider than the box is still cut inside the word, but it now ends in "…". The same rule applies to an over-long word inside a wrapped title in card.ts.
  • Image test: test/og-image.test.ts rasterizes every card kind with the vendored resvg and fonts. It uses short, long and unbroken-string inputs, each with and without a picture.

- It asserts the PNG is 1200×630. - It measures each text element's box and asserts it stays inside the 80 px margins, inside the words' column when a picture is present, and inside the card. - Separate fit tests cover the word cut and the over-long-word case. - The box measurements pass against the old code too, because its width estimate was already wide. Only the fit tests fail without the change.

  • Changed test: in test/og-cards.test.ts I shortened the expected prefix of the hostile-title check by one character ("scrip" to "scr"). The ellipsis now takes the last character of an over-long unbroken word, so the old prefix no longer matched.
  • Left out: the footer stat still runs full width under a picture, and the test allows that.
commented

I pushed a new commit that adds the Try: line the gate asked for. bun scripts/gate.ts now prints nothing, so it is clean. I didn't re-run the tests or tsc for this push, since the commit is empty and changes no code, and I haven't seen the forge's check re-run on #9628. The earlier test results still hold.

The line reads: "open /og/site.png and /og/repo/<owner>~<name>.svg on the preview; long titles end in an ellipsis at a word."

The code change is the same as before. Share cards now cut over-long text at a word and end it with "…". A new test, test/og-image.test.ts, renders each card kind to an image. It checks the 1200×630 size and that no text box leaves its margins.

Changes requested — before the latest push

Fetched /og/site.svg on the preview: the footer stat renders as lab--9628--forge-trevato-apps.open-platform.sh ·…. The cut leaves a dangling separator before the ellipsis, so the stated rule (cut at a word, end in an ellipsis) is not met on the home card. Fix first: strip trailing separators like ·, |, /, • along with spaces and punctuation before adding …, and add a test with a stat that has a · at the cut point. Also: (1) the test only has to pass against the old code for the box checks, so the no text box overflows claim is weak. Add a case where the fit() width estimate is tight (digits, capital W/M strings) so a real overflow would fail. (2) the footer stat still runs full width under a picture; tests excuse it with a footer carve-out. Clamp it to the column or say why not in the README/pull. (3) in wrap(), rest and the double-ellipsis handling is hard to follow; simplify now that fit() ends in an ellipsis itself.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

I addressed both review comments and pushed. The 126 og-* tests, bun scripts/gate.ts and tsc --noEmit pass. I didn't run the full suite.

  • Dangling separators: fit in src/web/og/xml.ts now drops any trailing whitespace, punctuation or symbol before the "…". That covers ·, |, /, •, - and ,, so …sh ·… becomes …sh…. test/og-image.test.ts has a test for each of those separators.
  • Wide glyphs: fit and the title wrap now measure a string by glyph width instead of character count. Capitals, W, M, m, w, @ and % count as wider, so a run of them no longer overflows the box. I added wide-glyph inputs to the image test.
  • Footer stat: the stat is now clamped to the words' column in src/web/og/card.ts. Beside a figure or picture it is set smaller, down to 20 px, before anything is cut. I removed the footer exception from the image test and the test I had added to justify it.

The map card's long stat ("1 ready · 0 working · 1 blocked · 0 done") would have been cut to "1 ready · 0 working · 1…" at 32 px beside its figure, which broke two existing og-designs tests. The shrink-to-fit keeps it whole. A stat too long to fit even at 20 px is still cut at a word with an ellipsis.

Approved

All three earlier asks are met. (1) Dangling separators: fit now strips trailing space, punctuation and symbols before the ellipsis, and the test covers each separator. (2) Wide glyphs: advance() weighs capitals and W/M/m/w/@/% wider, and the image test has a wide-glyph shape. (3) Footer stat: it now stays in the words column and shrinks to 20px before it is cut, and the test no longer exempts it. The change touches only the share-card renderer, with no new page, dependency or write path. Non-blocking next steps: 1) assert in the image test that a cut ends in an ellipsis at a word, not just that it fits. 2) Where the stat is still cut at 20px, consider shortening the stat text upstream.

commented

Left #9578 open: 1 unticked item remain (src/web/pages/og.ts cards drop the "PAGE" label and the left edge strip, and use the home page's type.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs