Skip to content

Fix/image optimizations#7762

Merged
carlagn merged 6 commits intomainfrom
fix/image-optimizations
Apr 2, 2026
Merged

Fix/image optimizations#7762
carlagn merged 6 commits intomainfrom
fix/image-optimizations

Conversation

@carlagn
Copy link
Copy Markdown
Contributor

@carlagn carlagn commented Apr 2, 2026

Summary by CodeRabbit

  • New Features

    • Fine-grained image loading: key visuals load with priority while others use lazy loading to improve perceived performance.
    • Avatars now support configurable loading modes (lazy/eager).
  • Chores

    • Enabled image optimization across the site and migrated many images to the optimized renderer for better delivery and consistency.
    • Minor layout adjustment to footer column sizing.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Apr 2, 2026 4:28pm
docs Ready Ready Preview, Comment Apr 2, 2026 4:28pm
eclipse Ready Ready Preview, Comment Apr 2, 2026 4:28pm
site Ready Ready Preview, Comment Apr 2, 2026 4:28pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bd47c947-247e-4c0a-970f-4ffd1f91483c

📥 Commits

Reviewing files that changed from the base of the PR and between 069593a and 4f02e5c.

📒 Files selected for processing (2)
  • apps/site/src/app/about/page.tsx
  • packages/ui/src/components/footer.tsx

Walkthrough

Replaced many HTML img elements with Next.js Image components across the site, added loading/priority attributes and explicit dimensions or fill usage, adjusted wrappers for fill, extended AvatarProps with loading, and set images.unoptimized to false in next.config.mjs.

Changes

Cohort / File(s) Summary
Config
apps/site/next.config.mjs
Set config.images.unoptimized from truefalse. Minor formatting/whitespace edits and a non-functional argument-list tweak in the production validation error message.
App Pages
apps/site/src/app/about/page.tsx, apps/site/src/app/careers/page.tsx, apps/site/src/app/client/page.tsx, apps/site/src/app/orm/page.tsx
Replaced <img> with Image; moved some images to fill (requires positioned parent), added width/height or fill, and added loading/priority attributes. Minor class adjustments to support fill.
Homepage Components
apps/site/src/components/homepage/bento.tsx, apps/site/src/components/homepage/card-section/card-section.tsx, apps/site/src/components/homepage/testimonials/testimonial-item.tsx
Migrated visual, card, and avatar images to Image; added explicit dimensions, conditional priority/loading, and updated wrappers (e.g., relative) to support fill.
Utility & Feature Components
apps/site/src/components/logo-parade.tsx, apps/site/src/components/postgres.tsx, apps/site/src/components/prisma-with/community-section.tsx, apps/site/src/components/prisma-with/hero.tsx
Replaced logos, themed assets, and hero visuals with Image; introduced width/height or fill, preserved dark/light and responsive visibility, and adjusted container classes for positioning and object-fit.
Shared UI Package
packages/eclipse/src/components/avatar.tsx
Extended exported AvatarProps with `loading?: "lazy"
Layout Styling
packages/ui/src/components/footer.tsx
Adjusted Tailwind sizing class from lg:h-72lg:h-[217px] for the logo/social column.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fix: final tweaks #7749 — Modifies apps/site/src/components/logo-parade.tsx (related changes to logo rendering that may overlap with this PR).
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/image optimizations' accurately reflects the main objective of the changeset: systematically converting img elements to Next.js Image components across multiple files and enabling lazy loading throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/site/next.config.mjs (1)

258-266: ⚠️ Potential issue | 🟡 Minor

Add avatar.vercel.sh to remotePatterns for optimized avatar rendering

With image optimization now enabled (unoptimized: false), the Avatar component in testimonial-item.tsx dynamically generates avatars from https://avatar.vercel.sh/ when no custom image is provided. Since this domain isn't in remotePatterns, Next.js will skip optimization for these generated avatars, missing an opportunity to serve them more efficiently.

Add this pattern to enable optimization:

Proposed fix
   images: {
     unoptimized: false,
     remotePatterns: [
       {
         protocol: "https",
         hostname: "cdn.sanity.io",
       },
+      {
+        protocol: "https",
+        hostname: "avatar.vercel.sh",
+      },
     ],
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/next.config.mjs` around lines 258 - 266, Update the Next.js images
remotePatterns so avatar.vercel.sh is allowed for optimized images: in the
images.remotePatterns array (the block that currently lists protocol "https" and
hostname "cdn.sanity.io") add an entry with protocol "https" and hostname
"avatar.vercel.sh" so the Avatar component in testimonial-item.tsx (which
generates https://avatar.vercel.sh/ URLs) can be processed by Next's image
optimizer when unoptimized is false.
🧹 Nitpick comments (4)
apps/site/src/components/homepage/bento.tsx (1)

197-208: Homepage bento cards may benefit from loading="eager"

The bento section appears prominently on the homepage. Using loading="lazy" here might cause a visible delay as users wait for images to load after the initial render.

For above-fold or near-above-fold content, loading="eager" (or omitting the prop entirely, which defaults to eager in Next.js Image) ensures images load with the page.

♻️ Suggested change
 <Image
   src={
     mounted && resolvedTheme === "light"
       ? `${card.image}_light.svg`
       : `${card.image}.svg`
   }
   alt={card.title}
   width={1200}
   height={800}
-  loading="lazy"
+  loading="eager"
   className="px-4 z-2 pt-0 pb-0 min-w-full min-h-[60%] object-fill object-[top_left] [mask-image:linear-gradient(to_bottom,rgba(0,0,0,1)_60%,transparent_90%)] [-webkit-mask-image:linear-gradient(to_bottom,rgba(0,0,0,1)_60%,transparent_90%)]"
 />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/components/homepage/bento.tsx` around lines 197 - 208, The
Image in the bento card rendering currently sets loading="lazy" which can delay
above‑the‑fold artwork; update the Image usage in the bento component (the
<Image ... /> instance that uses mounted, resolvedTheme and
card.image/card.title) to use loading="eager" or remove the loading prop so it
defaults to eager in Next.js, ensuring the prominent homepage card images load
immediately.
apps/site/src/app/client/page.tsx (1)

239-245: Consider loading="eager" for above-fold icons

These database and framework icons appear in a prominent section that may be visible on initial page load (after the hero). Browser lazy loading typically kicks in for content more than ~3 viewport heights below the fold.

If users see a flash of empty space before icons load, consider using loading="eager" for these. Otherwise, if the section is consistently below the fold, lazy is fine.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/app/client/page.tsx` around lines 239 - 245, The Image
components rendering db icons (the <Image ... src={db.icon} alt={db.name}
width={48} height={48} loading="lazy" /> instances) are likely above-the-fold;
change their loading prop from "lazy" to "eager" so the icons load immediately
(or add a simple heuristic/prop to switch to "eager" when the icons are in the
hero/above-fold section). Update the Image JSX to use loading="eager" (or
conditionalize that prop) for the above-fold database/framework icon renderings.
apps/site/src/components/postgres.tsx (1)

67-116: Consider more accurate dimensions for SVG images

The width={1200} and height={800} dimensions are quite large for images constrained by md:max-h-83 (~332px). While this works because SVGs scale, Next.js uses these values to calculate aspect ratio and reserve layout space.

For more predictable layout behavior, you have two options:

  1. Use dimensions closer to actual display size (if you know the SVG's natural aspect ratio)
  2. Use fill with a sized container for responsive images

This is a minor point since SVGs handle scaling gracefully, but worth noting for consistency.

♻️ Alternative using fill prop
-<Image
-  src={`${body.image}.svg`}
-  alt={body.title}
-  width={1200}
-  height={800}
-  loading="lazy"
-  className="hidden lg:dark:block md:max-h-83"
-/>
+<div className="relative hidden lg:dark:block md:max-h-83 w-full aspect-[3/2]">
+  <Image
+    src={`${body.image}.svg`}
+    alt={body.title}
+    fill
+    loading="lazy"
+    className="object-contain"
+  />
+</div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/components/postgres.tsx` around lines 67 - 116, The Image
elements rendering `${body.image}` variants use width={1200} height={800}, which
overestimates the rendered size (constrained by md:max-h-83); update the six
<Image ... /> usages in this component to either (A) use realistic dimensions
matching the displayed aspect ratio and max height (for 3:2 SVGs set width={498}
height={332} or equivalent) or (B) switch to next/image's fill mode and wrap
each Image in a positioned container (give the parent a relative position and
explicit height) so the images are responsive and layout reservations match the
visible size; adjust classNames as needed to keep md:max-h-83 behavior.
apps/site/src/components/homepage/card-section/card-section.tsx (1)

186-188: Minor: loading prop is redundant when priority={true}.

When priority is set to true, Next.js automatically disables lazy loading and preloads the image. The explicit loading={index === 0 ? "eager" : "lazy"} is effectively ignored for the first image where priority={true}.

You could simplify by removing the loading prop entirely and relying solely on priority:

♻️ Suggested simplification
 <Image
   key={`desktop-img-${index}`}
   className={cn(
     "hidden sm:block w-full h-auto",
     !item.noShadow &&
       "shadow-[0_10px_25px_-5px_rgba(0,0,0,0.1)]",
   )}
   src={
     mounted && resolvedTheme === "light"
       ? `${item.imageUrl}_light.svg`
       : `${item.imageUrl}.svg`
   }
   alt={item.imageAlt || ""}
   width={1200}
   height={800}
   priority={index === 0}
-  loading={index === 0 ? "eager" : "lazy"}
 />

Same applies to the mobile <Image> at lines 205-207.

Also applies to: 205-207

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/components/homepage/card-section/card-section.tsx` around lines
186 - 188, The Image components in card-section.tsx are passing both
priority={index === 0} and loading={index === 0 ? "eager" : "lazy"}; remove the
redundant loading prop and keep priority={index === 0} (Next.js will disable
lazy-loading automatically for priority images). Apply the same removal for the
mobile Image instance (the other <Image> with the same index check) so only
priority is used for the first image and others rely on default lazy behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/site/src/app/about/page.tsx`:
- Around line 342-355: The hero background Image components (both instances
rendering "/illustrations/about/hero_bg.svg" and
"/illustrations/about/hero_bg_light.svg") should be loaded with high priority so
they render above-the-fold without a flash; replace loading="lazy" with priority
or priority={true} (and remove the lazy attribute) on both Image components to
match the careers page pattern and ensure immediate rendering of the hero
backgrounds.

---

Outside diff comments:
In `@apps/site/next.config.mjs`:
- Around line 258-266: Update the Next.js images remotePatterns so
avatar.vercel.sh is allowed for optimized images: in the images.remotePatterns
array (the block that currently lists protocol "https" and hostname
"cdn.sanity.io") add an entry with protocol "https" and hostname
"avatar.vercel.sh" so the Avatar component in testimonial-item.tsx (which
generates https://avatar.vercel.sh/ URLs) can be processed by Next's image
optimizer when unoptimized is false.

---

Nitpick comments:
In `@apps/site/src/app/client/page.tsx`:
- Around line 239-245: The Image components rendering db icons (the <Image ...
src={db.icon} alt={db.name} width={48} height={48} loading="lazy" /> instances)
are likely above-the-fold; change their loading prop from "lazy" to "eager" so
the icons load immediately (or add a simple heuristic/prop to switch to "eager"
when the icons are in the hero/above-fold section). Update the Image JSX to use
loading="eager" (or conditionalize that prop) for the above-fold
database/framework icon renderings.

In `@apps/site/src/components/homepage/bento.tsx`:
- Around line 197-208: The Image in the bento card rendering currently sets
loading="lazy" which can delay above‑the‑fold artwork; update the Image usage in
the bento component (the <Image ... /> instance that uses mounted, resolvedTheme
and card.image/card.title) to use loading="eager" or remove the loading prop so
it defaults to eager in Next.js, ensuring the prominent homepage card images
load immediately.

In `@apps/site/src/components/homepage/card-section/card-section.tsx`:
- Around line 186-188: The Image components in card-section.tsx are passing both
priority={index === 0} and loading={index === 0 ? "eager" : "lazy"}; remove the
redundant loading prop and keep priority={index === 0} (Next.js will disable
lazy-loading automatically for priority images). Apply the same removal for the
mobile Image instance (the other <Image> with the same index check) so only
priority is used for the first image and others rely on default lazy behavior.

In `@apps/site/src/components/postgres.tsx`:
- Around line 67-116: The Image elements rendering `${body.image}` variants use
width={1200} height={800}, which overestimates the rendered size (constrained by
md:max-h-83); update the six <Image ... /> usages in this component to either
(A) use realistic dimensions matching the displayed aspect ratio and max height
(for 3:2 SVGs set width={498} height={332} or equivalent) or (B) switch to
next/image's fill mode and wrap each Image in a positioned container (give the
parent a relative position and explicit height) so the images are responsive and
layout reservations match the visible size; adjust classNames as needed to keep
md:max-h-83 behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5c1faf72-c7cd-44d2-b5c6-fdddb345f90f

📥 Commits

Reviewing files that changed from the base of the PR and between 032322c and ede9763.

📒 Files selected for processing (13)
  • apps/site/next.config.mjs
  • apps/site/src/app/about/page.tsx
  • apps/site/src/app/careers/page.tsx
  • apps/site/src/app/client/page.tsx
  • apps/site/src/app/orm/page.tsx
  • apps/site/src/components/homepage/bento.tsx
  • apps/site/src/components/homepage/card-section/card-section.tsx
  • apps/site/src/components/homepage/testimonials/testimonial-item.tsx
  • apps/site/src/components/logo-parade.tsx
  • apps/site/src/components/postgres.tsx
  • apps/site/src/components/prisma-with/community-section.tsx
  • apps/site/src/components/prisma-with/hero.tsx
  • packages/eclipse/src/components/avatar.tsx

mhartington
mhartington previously approved these changes Apr 2, 2026
@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Apr 2, 2026, 4:35 PM

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.

2 participants