Repository navigation
fix(www): leave out small sponsors whose avatars don't load - #7826
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Avatar fetching and validation www/src/og/avatar.ts, www/src/og/avatar.test.ts, www/src/og/fake-avatars.ts |
Adds an avatar service that sizes GitHub avatar URLs, validates image responses and SVG dimensions, retries selected failures, and fetches distinct images with up to eight concurrent requests. Tests cover response errors, retries, timeouts, and deduplication. |
Sponsor and backer selection www/src/sponsors.ts, www/src/sponsors.test.ts, www/src/og/card.ts, www/src/og/card.test.ts, www/src/components/sponsors/sponsor-cloud.tsx |
Excludes imageless sponsors from drawn sponsor lists and selects backers based on partner status and loaded avatars. Sponsor cards use backerSlots and sponsorCount to render selected backers and calculate the remaining count. |
Sponsor sync and README output www/build/sponsors-sync.ts, www/build/sponsors-sync.test.ts, www/build/sponsors-readme.ts, www/build/sponsors-readme.test.ts |
Sponsor sync marks small sponsors whose avatars fail to load and includes imageless status in lineup comparisons. README generation omits imageless sponsors. |
Social-card live data and rendering www/src/og/live.ts, www/src/og/live.test.ts, www/src/og/render.test.ts |
The live-data flow fetches stats and card avatars concurrently through Effect. Tests cover loaded and unavailable avatars in post and sponsor cards. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant fetchLive
participant live
participant fetchAvatars
participant Avatars
participant FetchHttpClient
par Fetch home-card stats
live->>live: fetch stats when card is a home card
and Fetch card avatars
live->>fetchAvatars: pass card image URLs
fetchAvatars->>Avatars: fetch distinct image URLs
Avatars->>FetchHttpClient: request avatar images
FetchHttpClient-->>Avatars: return image responses
Avatars-->>fetchAvatars: return successful data URIs
end
fetchLive->>live: run card live-data effect
live-->>fetchLive: return live data
Possibly related PRs
- trpc/trpc#7821: Adds the sponsor social card and data flow that this change updates.
- trpc/trpc#7799: Changes the shared social-card renderer and avatar-fetching path that this change extends.
- trpc/trpc#7820: Adds the light social-card renderer and SVG avatar handling used by this change.
Suggested reviewers: juliusmarminge
Merge Risk: 
Minimal · up to 815bd
-
The sync no longer writes an all-imageless sponsor list when every small-sponsor avatar fails to load. No identified issue remains that should block merging.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 15 files.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
|
@coderabbitai review |
f534cc1 to
e9f4e4b
Compare
|
@coderabbitai review |
Action performed
|
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
trpc-bot
left a comment
There was a problem hiding this comment.
All 48 checks pass at 74039f7. CodeRabbit's two findings, the sync writing every small sponsor imageless when the network is down and the card fetching avatars in batches of eight, are fixed, tested and resolved. CodeRabbit posted nothing on the new head. Approving.
The sponsor sync now tries each small sponsor's avatar and marks the ones that don't load imageless in sponsors.json. The sponsor cloud, the README tables and the home page's fallback skip them. The /sponsor card draws the first twelve backers whose avatars load, and counts the rest in its +N. Avatar fetching moves to src/og/avatar.ts and is written in Effect: typed errors, a timeout per try, retries for failures that may pass, eight at a time. Co-authored-by: alexander <[email protected]>
… and fetch a card's avatars at once If every small sponsor's avatar fails, the network is more likely at fault than the sponsors, so the sync writes nothing rather than hide them all. A card is drawn while a crawler waits, so it fetches all its avatars at once: a slow host costs one avatar's wait rather than one per batch of eight. Co-authored-by: alexander <[email protected]>
74039f7 to
815bd82
Compare
…c#7827) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> It uses [trpc#7826](trpc#7826 avatar fetching, now on `main`. ## Why - tRPC's partners get logos on the home page and the README, but nothing on the social cards, which are what most people see of a shared link. - A small "Supported by" strip thanks them on every card without crowding the title. ## What - **A strip along the foot of every card** (`www/src/og/card.ts`): home, docs, API reference, blog posts and the other pages. A thin rule, "SUPPORTED BY", then each partner's avatar and name. - **Not on `/sponsor`'s card**, which already shows the partners larger, with their tier. - **The partners** come from `sponsors.json`: the Gold and Silver sponsors by rank, at most four (`cardFooterPartners` in `www/src/sponsors.ts`). Today that is CodeRabbit, Greptile and SerpApi. It's the same list `/sponsor`'s card draws. - **Avatars** use trpc#7826's `Avatars` service (`www/src/og/avatar.ts`), with its timeouts and retries. They're fetched along with the card's other avatars, all at once. - **A partner whose avatar doesn't load is left out** of the strip. No initials. With none loaded, there's no strip, and the card is the same as before, byte for byte. - **Caching:** a card missing a partner's avatar is cached for 10 minutes, like one missing an author's, so the next request tries again. - `live`, `cacheControl`, `cardElement` and `renderOgImage` take the partners as an optional last argument. It defaults to `sponsors.json`'s, so `routes/og.$.ts` doesn't change, and tests can use a local server instead of GitHub. ### Renders Before is `main` with trpc#7826. After is this PR, with live avatars. Home:   A docs page:   A long docs title:   The API reference, with its long URL:   A blog post with author avatars:   A blog post with a long title:   The blog index:   `/sponsor` doesn't change:  When Greptile's avatar fails, the strip leaves Greptile out:  When no partner's avatar loads, there's no strip:  ## Links - Home: [card](https://www-git-cursor-og-partner-strip-trpc.vercel.app/og/index.png) - Docs: [Quickstart card](https://www-git-cursor-og-partner-strip-trpc.vercel.app/og/docs/quickstart.png) - API reference: [TRPCProcedureBuilder card](https://www-git-cursor-og-partner-strip-trpc.vercel.app/og/docs/typedoc/server/index/interfaces/TRPCProcedureBuilder.png) - Blog: [Introducing the new TanStack React Query integration card](https://www-git-cursor-og-partner-strip-trpc.vercel.app/og/blog/introducing-tanstack-react-query-client.png) - Sponsor: [card](https://www-git-cursor-og-partner-strip-trpc.vercel.app/og/sponsor.png), unchanged. ## Alternatives considered - **Partner logos instead of avatars:** the site draws partners' wordmarks as React components. Each would need porting to Satori, and a new partner would have none until someone drew it. Avatars come with every sponsor. - **Initials for a partner whose avatar fails:** a letter in a brand's place looks broken. Leaving them out reads better, and the next request tries again. - **The strip in the header, beside the section pill:** it crowds the logo and pulls the eye away from the title. - **Storing the partners on each card:** every docs and API reference card would carry the same list in the server bundle. The renderer reads it once from `sponsors.json` instead. ## Testing - `www` tests pass (278). New tests cover: - `cardFooterPartners`: `sponsors.json`'s partners by rank, the same as `/sponsor`'s card draws. - Fetching the partners' avatars for a docs card from a local server, and the 10-minute cache when one fails. - A partner whose SVG can't be sized is left out of the strip, with no initials. With none loaded there is no strip. `/sponsor`'s card has none. - The home and doc cards name the partners along their foot when their avatars load. - Passing the partners changes the rendered PNG. - Every card type renders at 1200×630 with and without the partners' avatars. - `pnpm lint`, typecheck and `oxfmt --check` pass in `www`. - `pnpm build` passes ("All 698 of trpc.io's URLs work"). - `/sponsor`'s card renders the same as before, byte for byte. A card with no partner avatars renders the same as before, byte for byte. ## AI model Claude Opus 5.5 <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-f3e3c393-74f1-51c3-9e62-ee29635fa923?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-f3e3c393-74f1-51c3-9e62-ee29635fa923&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> <!-- codesmith:footer --> --- <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1796228972&installation_model_id=443568&pr_number=7827&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F7827&signature=0f09ba86627da26485214848ebcc7485610cd13c24a1ea607be50348a7dce124"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a> <sup><a href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/7827?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Social preview cards for the home page, posts, and documentation can display a footer with up to four partner avatars and names. * The footer appears below the card content when partner avatars load, and is omitted when none are available. Sponsor cards continue to display without this footer. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Cursor Agent <[email protected]>
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Why
/sponsorsocial card, and a broken image in the sponsor cloud and the README.try/catchthat swallowed every failure the same way: no retries, and no reason given.This PR builds on #7821, which adds the
/sponsorcard and its backer row, so it is based on that branch. Once #7821 merges, it retargets tomain.What
isSmallSponsorinsrc/sponsors.ts).build/sponsors-sync.ts) tries each small sponsor's avatar. It marks the ones that don't loadimageless: trueinsponsors.jsonand logs who they are. A change in that mark counts as a change, so the sync rewrites the file. If no small sponsor's avatar loads, the network is more likely at fault, so the sync fails and writes nothing./sponsor(drawnSponsors);sponsorsMarkdown);topSponsors);/sponsorsocial card. It now holds twice as many backers as fit and draws the first twelve whose avatars load when the card is drawn (drawnBackers), so a dead avatar drops out at once, before the next sync.Avatars.fetch) as small sponsors, so they get the same timeouts and retries. Only the drawing differs: a partner whose avatar fails still gets initials, and the sync never marks a partner. Post authors on blog cards keep their initials too.src/og/avatar.ts(new) does the fetching in Effect:AvatarRequestError,AvatarTimeoutError,AvatarStatusError,AvatarTypeErrorandAvatarSizeError.Avatarsis a service, so the tests and the sync can provide their own.og/live.tsuses it.fetchLive(card)keeps its signature, soroutes/og.$.tsdoesn't change.Renders
The
/sponsorcard is the only one that changes. Blog post cards with author avatars, the home card and the docs cards draw the same.With every avatar loading, before and after are the same, byte for byte:
With three small sponsors' avatars failing (Ryan Magoon, BestKru, fanvue). Before, the row draws "RM", "B" and "F":
After, they are left out, and the next three sponsors fill the row:
Links
drawnSponsors. Today no sponsor is imageless, so it looks the same.Alternatives considered
<img>in the browser withonError: this fixes the cloud but not the README or the social card, and the circle would still take up space in the packed layout. The sync's mark covers all three. A browser that can't load an avatar the sync could load still shows a broken image; this PR doesn't change that.sponsors.json.Testing
src/og/avatar.test.ts(new) runs a local HTTP server for each test (await using server = await serveAvatars(...)). It covers:text/htmlor on an SVG without a size;AvatarRequestErrorwhen nothing listens;fetchAvatarsfetching each URL once, leaving out failures and keeping at most eight requests in flight.card.test.ts:drawnBackerskeeps a partner without an avatar, leaves out a small sponsor without one, and lets the next ones fill the slots.render.test.ts: on a sponsor card where every SVG is unsized, the partners draw initials and the small sponsors are left out. Authors still draw initials.sponsors.test.ts:isSmallSponsor,drawnSponsors, and asponsorCardOffixture with an imageless sponsor.build/sponsors-sync.test.ts: a small sponsor whose avatar fails is marked imageless and left out of the README, but a partner whose avatar fails is not. When the avatar loads again, the sync rewrites the file. When no small sponsor's avatar loads, the sync writes nothing.live.test.ts: a card fetches all of its avatars at once.build/sponsors-readme.test.ts: an imageless sponsor is left out.usingandawait usingwithmakeResourceandmakeAsyncResource, with nobeforeEachorafterEach.pnpm lint,pnpm typecheckandpnpm vitest run(270 passed) inwwwat the final head.pnpm buildpassed before the CodeRabbit fixes, and CI builds the final head..vercel/outputOG chunk in Node and calledfetchLive: a real GitHub avatar loaded and a missing user's was left out.Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit