Skip to content

fix(image): the Image atom hides every image until hydration - #148

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/fix-145-image-ssr-visible
Oct 1, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/fix-145-image-ssr-visible

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Every server-rendered <Image> and <Avatar> shipped its <img> at opacity-0, so images were invisible with JavaScript off and no <Image> could be a page's LCP element.
  • The loading state is now client-only: it starts cleared, and only an in-place src change enters it. The server renders an opaque <img> and no placeholder.
  • New <Image priority> renders loading="eager" + fetchPriority="high" and gets a hoisted <link rel="preload" as="image">.
  • Avatar now sets loading="lazy", so avatars stop taking the preload slots a priority hero needs.

Changes

  • components/atoms/Image/Image.tsx — isLoading starts false; the mount effect only clears it; priority prop.
  • components/atoms/Avatar/Avatar.tsx — the opacity gate and its state are gone; the initials it already renders are its placeholder. Adds loading="lazy".
  • DESIGN_SYSTEM.md — hero-image guidance, and the rule this bug broke.

Preview

All four verified 200 on the branch aliases.

Test results

  • Lean gate: ✓ lint (0 errors, no new warnings), tsc --noEmit, test:run — 79 files / 794 tests
  • Re-run green after the review round (c8b50af), which changed only a JSDoc paragraph and DESIGN_SYSTEM.md
  • Targeted specs: 28 passed in Image.test.tsx + Avatar.test.tsx, 8 of them new
  • Each new regression spec was watched failing against the unfixed code before being kept
  • Build: N/A locally — but the Cloudflare Worker and Pages previews both built and deployed from this branch
  • Verified on the deployed preview: no <img> on the home page carries opacity-0, and every <Image> renders opacity-100

Manual verification

  1. Open the home-page preview with JavaScript disabled in DevTools. Every image is visible, including the feature-block ones that use forceAspectRatio={false}.
  2. Grep the preview HTML for opacity-0, with the pattern scoped to the img tag — expect 0. The ticket wrote this criterion as a bare grep for opacity-0, which cannot reach 0: the home page has 13 hits, all from one unrelated carousel affordance (<div class="shrink-0 transition-opacity duration-200 opacity-0 pointer-events-none">).
  3. Lighthouse mobile on a page whose hero is an <Image priority> — needs a hero marked by hand first; see the first note below.

Notes for reviewer

Detail

Open question: is the Placeholder positioned at all? Settled. It emits class="relative overflow-hidden … absolute inset-0", and Tailwind v4.3.3 emits the position utilities alphabetically — .absolute, .fixed, .relative, .static, .sticky — so .relative is generated last and wins. Compiled the real stylesheet to check rather than reasoning from class order.

So the ticket's claim 2 was wrong. It predicted the placeholder "covers the image forever with JS off" in the forceAspectRatio={false} layout. It does not: being relative and in flow with height: 100% against an auto-height parent, it collapses to zero height there. The image was hidden by opacity-0 alone. Either way the question is now moot — the server renders no placeholder when there is a src.

Open question: fill layout (acceptance criterion 6). Out of scope, recorded here as the criterion allows. The container's class list is owned by the atom and className reaches the <img>, so a fill mode means a third layout mode beside forceAspectRatio — a real API cost with no caller in this ticket needing it.

Why not re-enter the loading state on mount. My first version did, to keep the placeholder on client-side navigation. It is wrong: the browser is already painting the server's <img> progressively, so entering the loading state on mount fades a partly-visible image out and back in. An unloaded <img> paints nothing anyway, so the placeholder buys nothing that reserved width and height do not. This is the option #145 preferred, and the fade on a cold load is the stated cost.

Avatar lost its fade entirely, because once isLoading cannot become true the state, the onLoad and the transition are dead. Confirmed against origin/main that the avatar preload link pre-exists, so loading="lazy" removes a cost rather than one this PR added.

The priority JSDoc's sizes claim was wrong, and is fixed in c8b50af. It said a missing sizes falls back to full-viewport-width. It falls back to DEFAULT_SIZES (Image.tsx:16) — 100vw only under 640px, then 50vw, then 800px — and only when a srcSet exists (Image.tsx:362), so a non-Cloudflare src gets no sizes at all. The note now names the over-fetch case and defers the mechanics to the responsive prop's docs, which already carry them.

Rejected review findings

  • Drop the priority prop, since {...props} already emits identical markup. True, and fix(image): the Image atom hides every image until hydration #145 asked for it anyway: Phase 2 specifies the prop and acceptance criterion 3 requires its markup. Dropping it fails that criterion, so it is the reviewer's call.
  • Switch to fix(image): the Image atom hides every image until hydration #145's second option to keep the cold-load skeleton. A product trade, not a defect. Left open for the reviewer — see the Image note above.
  • Delete isLoading from Image outright. It still serves the AudioPlayer thumbnail's in-place src swap, which is deliberate, documented behaviour. Removing it is a UX decision beyond this ticket.
  • Move the fade out of React into a CSS animation plus key={imageSrc}. Genuinely better altitude, but a redesign of the atom's load lifecycle. Worth its own ticket.
  • Gate transition-opacity duration-300 on the fade. It would break the fade: a transition animates only when the class is on the element in the end state too.
  • Make priority authoritative over {...props}. Acceptance criterion 5 requires the spread to keep winning.
  • The natural-flow opacity spec cannot fail independently today. Kept: it pins acceptance criterion 2 and guards a future change that makes the opacity classes conditional on boxed.
  • Conditional onLoad to skip the listener. Micro, and handleLoad must still forward the caller's onLoad.
  • showLoading is now a no-op on every first render. It is not — !hasSrc still reaches it, which is the blank-src placeholder, and that path is specced.
  • Add a priority story. A priority image looks identical in Ladle; the prop's effect is a <link> in the head. A story would document nothing.

Fixture pre-mortem. The specs use no fixture. They render the real component through renderToStaticMarkup, as docs/rules/testing.md prescribes, and assert on React's own output. Two spellings were verified against that output rather than assumed: React emits fetchPriority camelCase, and with a srcSet the hoisted link carries imageSrcSet/imageSizes and no href — so the assertions match rel and as only, and will survive #141.

Review passes. /simplify (4 agents) then /code-review high; the pr-review-toolkit plugin is not installed in a routine. comment-lint clean. /security-review skipped — no path matches securityReview.triggerPattern. The adversarial review's four findings were addressed in c8b50af and its thread replies.

Closes #145

🤖 Generated with Claude Code

https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU

claude and others added 5 commits October 1, 2026 17:08
`isLoading` started `true`, so every server-rendered `<Image>` and
`<Avatar>` shipped its `<img>` at `opacity-0` and, for `<Image>`, behind
an opaque placeholder. The image was invisible with JavaScript disabled,
and Chromium does not treat a zero-opacity element as an LCP candidate,
so no `<Image>` could be a page's LCP element.

`isLoading` now starts `false`. The mount effect still only ever clears
it: entering the loading state on mount would fade out an image the
browser is already painting progressively from the server's markup. An
in-place src change — the AudioPlayer thumbnail on a track switch — is
what the placeholder was written for, and it still enters the state.
The cost is the fade on a cold load, where the browser paints nothing
for an unloaded `<img>` anyway.

`Avatar` could then never enter the loading state at all, so its
`isLoading`, its `onLoad` and its opacity transition are gone. The
initials it already renders underneath are its placeholder.

The placeholder's stacking question is moot — the server renders no
placeholder when there is a src to show. For the record, `Placeholder`
resolves to `position: relative`, not `absolute`: Tailwind v4.3.3 emits
the position utilities alphabetically, so `.relative` wins.

Co-authored-by: sydevs-bot <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU
`<Image priority>` renders `loading="eager"` and `fetchPriority="high"`,
and React's Fizz renderer hoists a `<link rel="preload" as="image">` for
it. Both attributes sit before `{...props}`, so a caller passing
`loading` or `fetchPriority` directly still wins.

The preload comes from dropping `loading="lazy"`, not from
`fetchPriority`: Fizz hoists a preload for any `<img>` that is not lazy,
and `fetchPriority="high"` only promotes that link into the
high-priority set, capped at 10 per render. So `priority` has to flip
`loading`, and the default has to stay lazy — marking every image on a
page preloads every one of them and ranks none.

None of the thirteen callers passes it, so nothing changes for them.

Co-authored-by: sydevs-bot <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU
React hoists a `<link rel="preload" as="image">` for any `<img>` that is
not `loading="lazy"`, and `Avatar` set no `loading` at all. So every
avatar on a page was preloaded, and with no `fetchPriority` they filled
the high-priority preload set first-come — the slots an `<Image
priority>` hero is meant to win. An avatar is never the hero.

Confirmed against `origin/main`: the preload link is in the markup there
too, so this removes a pre-existing cost rather than one just added.

Co-authored-by: sydevs-bot <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU
From the `/simplify` pass.

The mount run of the `complete`/`naturalWidth` effect became a provable
no-op once `isLoading` starts `false`, so it now returns early unless the
state is actually set. That makes the effect's one live job — clearing
the state after an in-place src change whose new src was already cached —
what the code says, and drops a dead `imageSrcSet` dependency.

The Fizz-preload explanation existed in three copies. The prop's JSDoc
keeps it, and gains the hazard it creates: `priority` without an explicit
`sizes` promotes the full-viewport-width fallback into a high-priority
over-fetch. `DESIGN_SYSTEM.md` keeps the guidance and adds the rule the
class of bug needs — a first render must produce visible markup.

Specs: dropped a duplicate blank-src placeholder case and an assertion
implied by the one beside it, and strengthened the existing blank-src
spec to assert the gradient rather than a class the <img> also carries.

Co-authored-by: sydevs-bot <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU
From the `/code-review high` pass.

The story section titled "With Loading State" rendered three identical
loaded images, so it demonstrated nothing once the loading gate left the
first render. It now shows the three states that remain: loaded, absent
src with the placeholder holding the box, and `showLoading={false}`.

The `DESIGN_SYSTEM.md` rule said to "enter a loading state on the
client", which no component here implements and which reads as a
requirement to re-enter it on mount. It now says what `Image` does: the
loaded state is the first render, and a loading state is entered only
from a later change.

Co-authored-by: sydevs-bot <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QkK2Lpc3ZbdwaHNzvrwpPU
@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: c8b50af
Status: ✅  Deploy successful!
Preview URL: https://7332573d.wm-design.pages.dev
Branch Preview URL: https://claude-fix-145-image-ssr-vis.wm-design.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 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 c8b50af Commit Preview URL

Branch Preview URL
Oct 01 2026, 07:57 PM

@sydevs-bot

sydevs-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:51Z address-review · attempt 1 · session · done
  • 19:51Z address-review · attempt 1 · session
  • 19:42Z adversarial-review · attempt 1 · session · done
  • 19:42Z adversarial-review · 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 defect fix is right and minimal. isLoading starting false makes the server <img> opaque in both layouts, and the effect's !isLoading guard keeps the src-swap path working. Filing #149 and #150 instead of widening the diff is right.

Phase 2 is the scope question. priority ships ahead of its first caller, this PR's own spec proves {...props} already emits the same markup, and one claim in its 21-line JSDoc is wrong.

Findings

  • should-fix Image.tsx:113 — priority has no caller and no capability the spread lacks.
  • should-fix Image.tsx:106 — the sizes fallback claim is wrong twice.
  • consider Image.tsx:351 — a cold load now shows an empty box, not the skeleton.
  • consider DESIGN_SYSTEM.md:288 — the new bullet narrates #145.

What was checked

Ticket #145. git diff origin/main...6bfb872 — 6 files, +165/-48. Image.tsx and Avatar.tsx read whole. All 13 <Image> and 2 <Avatar> call sites grepped: none passes showLoading, two swap src in place. No contract surface in the diff.

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


Generated by Claude Code

Comment thread components/atoms/Image/Image.tsx Resolved
Comment thread components/atoms/Image/Image.tsx Resolved
Comment thread components/atoms/Image/Image.tsx Resolved
Comment thread DESIGN_SYSTEM.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 1, 2026
claude added 2 commits October 1, 2026 19:54
The note claimed a missing `sizes` falls back to full-viewport-width.
It falls back to DEFAULT_SIZES, which is 100vw only under 640px, then
50vw, then 800px — and only when a srcSet exists, so a non-Cloudflare
src gets no `sizes` at all. Name the case that over-fetches instead,
and leave the mechanics to the `responsive` docs that already carry
them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BMdouKahebk3rN5QJAww12
Ten lines carried two rules and re-told #145. The prop's own JSDoc
already owns the preload mechanics, so the guidance points there
instead of repeating them.

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

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review in c8b50af. Two adopted, two rebutted and left open for you.

Adopted

Rebutted — your call

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


Generated by Claude Code

sydevs-bot pushed a commit that referenced this pull request Oct 1, 2026
The Image atom starts `isLoading` true and clears it from a client load
handler, so its <img> renders `opacity-0` in SSR. Routing the mobile
overlay hero through the atom therefore traded a wasted preload for an
invisible hero — the exact property this branch refuses to impose on the
atlas lead image, and the variant payoff that justified it stays inert
until #141.

`loading="lazy"` on the existing <img> closes the measured problem with
no regression. Convert after #148 makes the atom's first render visible.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0174NRurcaxgq55sz4UspoFw
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 1, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 1, 2026 20:00
@sydevs-bot
sydevs-bot requested a review from Ardnived October 1, 2026 20:00
@sydevs-bot
sydevs-bot enabled auto-merge October 1, 2026 20:00
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 1, 2026
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Oct 1, 2026
Merged via the queue into main with commit f1f8aa7 Oct 1, 2026
66 of 70 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-145-image-ssr-visible branch October 1, 2026 21:00
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Oct 1, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 1, 2026
One conflict, in the DESIGN_SYSTEM.md Performance list. Both sides added an
above-the-fold image rule to the same bullet position.

main (#148) fixed the Image atom's opacity-0-until-hydration gate and gave it
a priority prop, so this branch's bullet cited a blocker that no longer
exists. The second blocker still holds: the atom's container owns the layout
and className reaches the image, and #145 deferred a fill mode, so a hero
that must fill its parent still hand-rolls an img. The resolved bullet keeps
that reason, main's `<Image priority sizes>` guidance and its one-or-two-per-
page cap, and the never-a-CSS-background and `<picture>`-suppresses-the-
preload rules. main's separate first-render-must-be-visible bullet is kept
whole.

Splash.tsx carried the same stale opacity-0 reason in a comment. git merged
it clean because main never touched the file, so it is corrected here to the
container-layout reason it now rests on.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DzGDzXPkGrSomd1FAi7Ern
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.

fix(image): the Image atom hides every image until hydration

3 participants