Skip to content

refactor(image): route hand-rolled <img> elements through the Image atom - #214

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/refactor-150-image-atom
Nov 15, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/refactor-150-image-atom

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Change outline

Behaviour — what each site asks Cloudflare for now

Both sites previously reached getImageURL with no aspectRatio, so the URL passed through unresolved and getImageSrcSet returned ''.

 ContentOverlay                       components/organisms/ContentOverlay/ContentOverlay.tsx
   mobile branch (md:hidden)
-    <div className="w-full aspect-video"> ````&lt;img src={imageSrc}&gt;````   # …/<id>/public, no srcset
+    <Image aspectRatio="video" rounded="none" sizes={LEAD_IMAGE_SIZES}>
+      # the atom's container supplies `relative aspect-video overflow-hidden`,
+      # so the wrapper div goes
   desktop branch (hidden md:block)
-    ``````&lt;Image aspectRatio="video" sizes="100vw"                     # …/&lt;id&gt;``````/width=800
-      className="w-full h-full object-cover {blend}">            # the atom emits all three itself
+    ```````&lt;Image aspectRatio="video" sizes={LEAD_IMAGE_SIZES}·+      className={imageBlendClass}&gt;```````                               # the blend alone
+  LEAD_IMAGE_SIZES = '100vw'          # one constant, because the two must agree

 AtlasContent                         pages/map/_components/AtlasContent.tsx
-  <img className="mt-6 w-full max-w-full rounded">               # …/<id>/public, no srcset
+  <div className="mt-6">                                         # className reaches the <img>
+    <Image aspectRatio="video" forceAspectRatio={false} className="w-full">
+      sizes: calc(100vw - 2rem) / calc(100vw - 3rem) / 720px

Flow — why the overlay fetched twice, and what ends it

Both branches stay in the DOM at every breakpoint, and a hidden <img> is still fetched. Since #141 merged (PR #147) they resolved to different URLs.

 one overlay block, desktop visitor
   desktop <Image aspectRatio="video">
     getImageURL(src, 'width=800')          → …/<id>/width=800      ← fetched
   mobile `````&lt;img src={imageSrc}&gt;`````
-    no resolution                          → …/<id>/public         ← fetched again
+  mobile <Image aspectRatio="video" sizes={LEAD_IMAGE_SIZES}>
+    same srcSet + same sizes + same DPR    → …/<id>/width=800      ← same candidate, one fetch

Behaviour — the atlas sizes is the column, not the viewport

The ticket proposed 100vw, and asked for it to be confirmed against the rendered width. It does not hold: AtlasContent sets its own column at mx-auto max-w-3xl px-4 py-8 sm:px-6, and max-w-3xl caps the padded box.

 real rendered width                        pages/map/_components/AtlasContent.tsx:193
   viewport < 640px    100vw - 2rem         # px-4
   640px – 768px       100vw - 3rem         # sm:px-6
-  >= 768px            768px                # the cap…
+  >= 768px            720px                # …minus its own gutters

Declaring the cap costs a whole srcset tier at DPR 2 — a 412px-wide phone at DPR 2.625 would have declared 1081 and taken width=1536 for a slot needing width=1024.

Preview

Branch aliases, each confirmed to serve this branch's own markup rather than derived from the branch name:

  • Home page — carries two ContentOverlay blocks. Both branches of each now resolve …/504d3db7…/width=800; before this PR the mobile one was on /public.
  • A Belfast class page — the only atlas route in the content set with a lead image. Renders …/picture-105…/width=800 with a 4-entry srcSet.
  • Ladle: Image atom — the atom itself is unchanged; here for a side-by-side.

Both render from live SahajCloud data, so nothing needed seeding. The alias follows the head commit, and f852103 removes only duplicate class names, so both pages look the same before and after its build.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint (0 errors; the 2 warnings on changed files are both pre-existing on main), tsc --noEmit, test:run.
  • Tests: 910 passed / 89 files. Build: ✓ pnpm build. Both re-run on f852103, after origin/main was merged in — the merge was clean, and its only overlap with this branch is a comment in AtlasContent.tsx that chore(urls): record the Link relativize decision in comment and docs #210 rewrote.
  • Each new assertion was watched failing against the unconverted components before being kept, and renderToStaticMarkup was probed directly to confirm React 19 really does hoist <link rel="preload"> there — otherwise the two not.toContain('rel="preload"') assertions would assert nothing.
  • Fixture pre-mortem: the specs assume SahajCloud spells an upload …/<image_id>/public. Verified against the producer, not assumed — sydevs/SahajCloud src/plugins/storage/cloudflareImagesAdapter.ts builds `${config.deliveryUrl}/${imageId}/public`, and src/endpoints/atlas/seo/seoDocument.ts passes Payload's virtual url through untouched.
  • /security-review skipped — no changed path matches securityReview.triggerPattern. comment-lint clean.

Verified on the deployed preview, items 1–4 of the ticket's checklist:

  1. ✓ The double download is gone. Both ContentOverlay <img>s on the home page carry the same src (…/504d3db7…/width=800), the same 4-entry srcSet and sizes="100vw", so the browser picks one candidate and makes one request.
  2. ✓ No stray /public. imagedelivery\.net/[^/]*/[^/"]*/public matches 0 times on the home page. It would have matched twice before this PR — the two sites fix(image): six paths skip the variant pipeline, four over-fetch #207's body assigns to this ticket.
  3. ✓ The atlas lead image is converted. width=800 with a 640/800/1024/1536 srcSet, sizes="(max-width: 40rem) calc(100vw - 2rem), (max-width: 48rem) calc(100vw - 3rem), 720px", loading="lazy", opacity-100 (so a no-JS reader sees it), and no aspect-video box, so it is not cropped.
  4. ✓ Preload links. 0 on the class page. 1 on the home page, and it is the Splash hero's deliberate fetchPriority="high" preload, not an overlay's.

Manual verification

  1. Compare the two preview pages above against main at mobile and desktop widths. The variants change bytes, not layout, so anything that moves is a defect.
  2. The atlas lead image's corner radius moves from rounded (4px) to the atom's rounded="square" (rounded-xs, 2px), which the ticket sanctions. Worth a glance.
  3. Load the class page with JavaScript disabled and confirm the lead image is visible. The markup says it should be — opacity-100 on first render — but that has not been checked in a real browser.

Notes for reviewer

Detail

The desktop branch's three utilities are gone (f852103). <Image> emits object-cover absolute inset-0 w-full h-full itself whenever aspectRatio is boxed, so the call site restated all three and the rendered class carried them twice. imageBlendClass was the only part doing work, and it is '' for every variant but highContrast. The atlas call site keeps its w-full, which is not redundant: forceAspectRatio={false} means the atom emits no width there.

Both "until #148" comments are gone, which is criterion 7. #148 merged in f1f8aa7, and Image.tsx:204 now starts isLoading at false, so the atom's first render carries opacity-100. The retained AtlasContent.test.tsx assertion that the lead image is free of opacity-0 is what holds that, and the preview confirms it on real markup.

rounded="none" on the mobile branch matches today's square corners; the atom defaults to rounded="square" (rounded-xs). The desktop branch keeps the default, where it is invisible anyway — its container sits inside an overflow-hidden parent.

max-w-full was dropped from the atlas image. It is inert beside w-full, and Tailwind's preflight already sets img { max-width: 100% }. It was carried over from the raw <img>, and no other Image call site in the repo has it.

Why forceAspectRatio={false} and not a boxed aspect-video. Since #141 a variant is a width-only width=<n> segment, so the ratio crops nothing and only picks which width tiers the srcSet offers. Natural flow renders the photo at its own ratio, exactly as today.

The preview links are branch aliases, not the per-commit one. CI's scripts/get-cloudflare-preview-url.mjs selected 252de255-wemeditate-web… for the smoke gate, which is correct there — it must pin one SHA — but a per-commit alias in a PR body goes stale on the next push. The branch alias was confirmed by fetching the class page from it and matching this branch's own sizes string, so it is not a guess from the branch name.

Only one atlas route in the content set has a lead image. Of four class pages sampled under /map/gb, three render zero <img>. That is why the Preview section links the Belfast one specifically.

Closes #150

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjW2ei3KxPxbsi25Xd8

Both branches render, and a hidden <img> is still fetched, so since #141
a desktop visitor took the desktop branch's `width=800` variant and the
mobile branch's unresolved `/public` original — the same picture twice.

The mobile branch now uses the atom with the desktop branch's `sizes`, so
both resolve the same srcset candidate and the browser makes one request.
`rounded="none"` keeps today's square corners against the atom's
`rounded-xs` default, and the atom's container supplies the
`relative aspect-video overflow-hidden` the wrapper div was carrying.

The comment refusing the atom "until #148" is stale: #148 merged in
f1f8aa7, and the atom's first render now carries `opacity-100`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW2ei3KxPxbsi25Xd8
The lead image was a raw <img> on the unresolved `/public` URL, so it
fetched the full original and offered no srcset. It now goes through the
atom with `aspectRatio="video"` and `forceAspectRatio={false}`: since
#141 a variant is a width-only `width=<n>` segment, so the ratio picks
which widths the srcset offers and crops nothing.

`sizes` tracks the `max-w-3xl` column this content renders in, not the
viewport — the earlier `100vw` reading missed that AtlasContent sets its
own column. `className` reaches the <img> rather than the container, so
the margin moved to an element of its own.

The comment refusing the atom "until #148" is stale: #148 merged in
f1f8aa7, so the atom's first render is visible to a reader who never
hydrates — which is most of this markup's audience.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW2ei3KxPxbsi25Xd8
The atlas `sizes` declared the `max-w-3xl` cap, but that cap bounds the
padded box, so the image is 720px and never 768. Declaring the cap cost a
whole srcset tier at DPR 2 — a Pixel 7 fetched `width=1536` for a slot
needing `width=1024`. It now declares the gutters it actually renders in.

ContentOverlay's two branches must agree on `sizes` or the browser
resolves the srcset twice, which is the bug this ticket fixes. That
coupling was a comment; it is now one constant both branches read.

Also: drop `max-w-full`, inert beside `w-full` and carried over from the
raw <img>; fold four overlapping specs into two; cut comments restating
the atom's own prop docs and docs/rules/testing.md.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW2ei3KxPxbsi25Xd8
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Should #150's criteria 4 and 6 — an explicit loading on MeditationPlayer.tsx:685 — land here or in PR #207?

Two records of yours disagree. #150's body folds the line in. #152's Decisions says: "→ With #146, in PR #207. This ticket drops them and blocks on it instead (Ardnived, 2026-10-28)."

I recommend A, and read #207's LCP call as the better evidenced: the circle is 384–512px against a 128px Avatar.

Reply with a letter, or your own answer.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: f852103
Status: ✅  Deploy successful!
Preview URL: https://fa423818.wm-design.pages.dev
Branch Preview URL: https://claude-refactor-150-image-at-7l3f.wm-design.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web f852103 Commit Preview URL

Branch Preview URL
Oct 28 2026, 05:52 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 28, 2026
@sydevs-bot

sydevs-bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:45Z address-review · attempt 1 · session · done
  • 17:45Z address-review · attempt 1 · session
  • 17:37Z review-pr · attempt 1 · session · done
  • 17:37Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is the ticket and nothing more: two call sites, one constant, one wrapper div. It is smaller than #150, because criteria 4 and 6 were reassigned to #146 / PR #207, and #152's Decisions carries that in the reviewer's own words, dated 2026-10-28. The omission is sanctioned, not skipped. The question thread asking it again is right.

Every behavioural claim in the body holds on the preview, the two the ticket asked to be confirmed included: the atlas sizes is the column measured inside its gutters, and the ticket's own 100vw was wrong. No contract surface is touched — AtlasSeoImage is hand-written here and unchanged, and the diff adds no type, prop or export.

One redundancy, pre-existing but now provable from the diff. Nothing blocking.

Findings

  • consider — ContentOverlay.tsx:217: the desktop branch restates three utilities the atom already emits. The new mobile branch is the proof.

What was checked

Read whole: ContentOverlay.tsx, AtlasContent.tsx, Image.tsx, both specs, server/atlas-types.ts, blockConverters.tsx. #150 and #152, whose Decisions line matches the body verbatim. Reviewer profile read.

Re-derived, not taken from the body:

  • Home page: each overlay's two branches share one …/width=800 src, one 4-entry srcSet and sizes="100vw". …/public matches 0 times. One rel="preload" as="image", the Splash hero's.
  • Belfast class page: width=800, a 640/800/1024/1536 srcSet, the three-clause sizes, loading="lazy", opacity-100, 0 aspect-video, 0 preloads. Ladle alias returns 200.
  • The sizes arithmetic from AtlasContent.tsx:193 (mx-auto max-w-3xl px-4 py-8 sm:px-6): the 48rem cap less 3rem of gutters is 720px, and 100vw - 3rem reaches 720px at exactly 48rem.
  • AtlasContent renders one image site, so the conversion left no sibling outside it.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 28, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Oct 28, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 28, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Oct 28, 2026
The desktop branch passed `w-full h-full object-cover` to <Image>, which
already emits all three for a boxed aspect ratio — the home-page preview
rendered them twice in one class attribute. The new mobile branch proves
it: it passes no className and renders the same box.

`imageBlendClass` is the only part doing work, and it is '' for every
variant but highContrast, so the className is now that alone. Verified by
SSR render: the desktop <img> loses exactly the three duplicates and
keeps `brightness-70 contrast-70` on highContrast.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWp4SWjtxLvy4vB16y
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

One finding addressed, and main merged in. Pushed f852103.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 28, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

The session for this item did not finish after 3 attempts. I have stopped retrying. A mention (@sydevs-bot) or a push from you starts me again.

🤖 sydevs dispatcher

@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Oct 28, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 28, 2026 21:49
@sydevs-bot
sydevs-bot requested a review from Ardnived October 28, 2026 21:49
@sydevs-bot
sydevs-bot enabled auto-merge October 28, 2026 21:49
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 15, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 2922f0c Nov 15, 2026
42 of 43 checks passed
@sydevs-bot
sydevs-bot deleted the claude/refactor-150-image-atom branch November 15, 2026 18:25
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 15, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 15, 2026
#214 routed ContentOverlay and AtlasContent through the Image atom, which
is what this guard's docstring said would happen there rather than here.
The pin is a measurement, so merging main moved it.

The reason for stopping at <Image> is unchanged: four of the six remaining
raw tags still do not name getImageURL, so that arm would still need the
exemption list the guard refuses.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXyy2UmAFQvQw35rQN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

refactor(image): route hand-rolled &lt;img&gt; elements through the Image atom

3 participants