Skip to content

Upgrade to Spree 5.4 media system - #65

Merged
damianlegawiec merged 3 commits into
mainfrom
feature/media-system
Mar 16, 2026
Merged

Upgrade to Spree 5.4 media system#65
damianlegawiec merged 3 commits into
mainfrom
feature/media-system

Conversation

@damianlegawiec

@damianlegawiec damianlegawiec commented Mar 16, 2026

Copy link
Copy Markdown
Member

Summary

Updates the storefront to use Spree 5.4's new media system where images is renamed to media throughout the Store API.

  • Bump @spree/sdk and @spree/next to 0.11.0
  • expand: ['images']expand: ['media'] on PDP
  • Image type → Media type imports
  • product.imagesproduct.media, variant.imagesvariant.media
  • Update SEO and OpenGraph metadata to use product.media

All image URL fields (original_url, large_url, og_image_url, thumbnail_url) remain unchanged — only the container array changed from images to media.

Test plan

  • TypeScript compilation passes
  • All 81 tests pass (7 test files)
  • PDP gallery, product cards, cart, checkout, order pages unaffected (use thumbnail_url which didn't change)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Updated Spree SDK and related dependencies to a newer minor release for improved compatibility.
  • Refactor

    • Standardized product media handling across product pages, gallery, metadata, and SEO to use unified "media" data, improving consistency of how product visuals are sourced and rendered with no visible UI changes.

- Bump @spree/sdk and @spree/next to 0.11.0
- expand: ['images'] → expand: ['media'] on PDP
- Image type → Media type imports
- product.images → product.media, variant.images → variant.media
- Update SEO and metadata to use product.media

All image URL fields (original_url, large_url, og_image_url, thumbnail_url)
remain unchanged — only the container changed from images to media.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d8845086-ab68-4325-b706-983410e43afe

📥 Commits

Reviewing files that changed from the base of the PR and between bdbbcf1 and 2abbad1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/app/[country]/[locale]/(storefront)/products/[slug]/page.tsx

Walkthrough

Migrates product image handling from the legacy Image type to the new Media type and updates SDK dependency versions; switches product API expansion from "images" to "media" and updates related components, metadata, and SEO to use media fields.

Changes

Cohort / File(s) Summary
Dependency Updates
package.json
Bumped @spree/next (^0.10.5 → ^0.11.0) and @spree/sdk (^0.10.1 → ^0.11.0).
Product components & props
src/app/.../products/[slug]/ProductDetails.tsx, src/components/products/MediaGallery.tsx
Replaced Image/SpreeImage imports with Media; updated component prop and local types from SpreeImage[] to Media[]; gallery logic now prefers variant.media over product.media.
Product fetch expansion
src/app/.../products/[slug]/ProductDetailsWrapper.tsx, src/app/.../products/[slug]/page.tsx
Changed product fetch expansion/includes from "images" to "media" (variants, media, option_types).
Metadata & SEO
src/lib/metadata/product.ts, src/lib/seo.ts
Switched internal usage from product.images to product.media when building open-graph images and JSON-LD data; comments updated to reference media/expand.

Sequence Diagram(s)

(Skipped — changes are type/data-field migrations and dependency bumps; no new multi-component control flow requiring a sequence diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 From Image to Media I hop and hum,

I swap the types and watch them come,
Variants lead the gallery dance,
Metadata and SEO prance,
A little hop for every change — yum! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 directly summarizes the main change: upgrading dependencies and migrating from the legacy 'images' container to Spree 5.4's new 'media' system across the codebase.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/media-system
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/app/`[country]/[locale]/(storefront)/products/[slug]/ProductDetailsWrapper.tsx:
- Around line 31-33: The getProduct call uses different expand keys across
rendering paths causing payload drift; update the expansions to use "media"
everywhere so the server and client shapes match—specifically change the
getProduct expansion in the other fetch (the call in page.tsx that currently
uses ["images"]) to use ["media"] (and ensure any other getProduct invocations
like the one in ProductDetailsWrapper.tsx continue to include "media" alongside
"variants" and "option_types") so both fetches request the same fields.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 38c47d72-55f9-4f23-8626-449f47314f8e

📥 Commits

Reviewing files that changed from the base of the PR and between a485d18 and bdbbcf1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • package.json
  • src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx
  • src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetailsWrapper.tsx
  • src/components/products/MediaGallery.tsx
  • src/lib/metadata/product.ts
  • src/lib/seo.ts

Comment on lines 31 to 33
const data = await getProduct(slug, {
expand: ["variants", "images", "option_types"],
expand: ["variants", "media", "option_types"],
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify there are no remaining product fetches expanding "images"
rg -n -C2 --type=ts --type=tsx \
  'getCachedProduct\s*\([^)]*\["images"\]|expand:\s*\[[^]]*"images"'

Repository: spree/storefront

Length of output: 87


🏁 Script executed:

#!/bin/bash
# Search for product fetch calls with expand parameters
# Using correct rg syntax for TypeScript files
rg -n -C2 'expand:\s*\[' --type=ts src/app

# Also search for getCachedProduct or getProduct calls
rg -n 'getProduct|getCachedProduct' --type=ts src/app | head -30

Repository: spree/storefront

Length of output: 1881


Align all product fetch expansions to media instead of mixed images and media.

Product details for the same view are fetched with different expansions: src/app/[country]/[locale]/(storefront)/products/[slug]/page.tsx (line 29) uses ["images"] while src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetailsWrapper.tsx (line 32) uses ["media"]. This inconsistency can cause payload drift and create issues when the data shape differs between server and client rendering paths.

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

In
`@src/app/`[country]/[locale]/(storefront)/products/[slug]/ProductDetailsWrapper.tsx
around lines 31 - 33, The getProduct call uses different expand keys across
rendering paths causing payload drift; update the expansions to use "media"
everywhere so the server and client shapes match—specifically change the
getProduct expansion in the other fetch (the call in page.tsx that currently
uses ["images"]) to use ["media"] (and ensure any other getProduct invocations
like the one in ProductDetailsWrapper.tsx continue to include "media" alongside
"variants" and "option_types") so both fetches request the same fields.

damianlegawiec and others added 2 commits March 16, 2026 13:59
CI uses npm ci which requires package-lock.json in sync with package.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Server-side product fetch in page.tsx was still using ["images"]
while client-side ProductDetailsWrapper.tsx used ["media"].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@damianlegawiec
damianlegawiec merged commit 88d7174 into main Mar 16, 2026
4 checks passed
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.

1 participant