Skip to content

Conversation

@guitavano
Copy link
Contributor

@guitavano guitavano commented Dec 10, 2025

Summary by CodeRabbit

Refactor

  • Restructured image optimization logic to better handle and prioritize requests across multiple integration points.
  • Streamlined the optimization workflow to ensure more consistent and reliable image delivery throughout the platform.
  • Enhanced overall image processing efficiency and performance.

Bug Fixes

  • Removed unnecessary warning messages about image optimization settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.133.20 update
  • 🎉 for Minor 0.134.0 update
  • 🚀 for Major 1.0.0 update

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

Restructured image URL optimization logic in website/components/Image.tsx, introducing an internal optimizeWake() helper and reordering the getOptimizedMediaUrl() function to prioritize Wake/VNDA/Shopify/VTEX optimization paths with early special-case handling. Removed warning functionality and simplified the control flow.

Changes

Cohort / File(s) Change Summary
Image optimization logic restructuring
website/components/Image.tsx
Introduced optimizeWake() helper for appending width/height query parameters; restructured getOptimizedMediaUrl() with reordered optimization paths (Wake special-case first, then VNDA/Shopify/VTEX), moved VTEX evaluation before global enabled check, removed canShowWarning() function and optimization warning log

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Logic path precedence: Verify the reordering of VNDA, Shopify, and VTEX optimization checks produces correct results and no regressions
  • Edge case handling: Confirm data URLs and disabled optimization states are properly handled in the new flow
  • Wake CDN integration: Review the new optimizeWake() helper and its early special-case path for correctness

Possibly related PRs

  • improve image #1452: Modifies getOptimizedMediaUrl() in the same file, restructuring URL-building and optimization branches.
  • add data.decoassets.com #1496: Also modifies website/components/Image.tsx and getOptimizedMediaUrl(), handling asset base URL stripping and optimization path changes.

Suggested reviewers

  • vibe-dex
  • aka-sacci-ccr

Poem

🐰 Hop, hop! URLs now optimized bright,
Wake paths leap forward, VNDA takes flight,
Reordered branches, cleaner control flow,
Image queries shine—watch optimization grow! 🖼️✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely missing. The required template includes sections for 'What is this Contribution About?', 'Issue Link', 'Loom Video', and 'Demonstration Link', none of which have been completed. Add a complete pull request description following the template, including the contribution summary, issue link, and preferably a Loom video and demonstration link.
Title check ❓ Inconclusive The title is vague and uses non-descriptive phrasing. 'Tavano' appears to be a branch reference, and 'use platforms optimization' is generic without clarifying which specific optimization changes are being made to which components. Revise the title to be more specific and descriptive, such as 'Refactor image optimization to prioritize platform-specific handlers' or 'Add Wake platform image URL optimization'.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tavano/use-platforms-optimization

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.

Copy link
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b0d583 and 57c97c8.

📒 Files selected for processing (1)
  • website/components/Image.tsx (1 hunks)
🔇 Additional comments (3)
website/components/Image.tsx (3)

104-112: LGTM! Clean implementation of Wake optimization.

The function correctly follows the same pattern as other platform optimizers, appending width and height query parameters to optimize Wake/VNDA platform images.


141-143: LGTM! Appropriate fallback for generic optimization.

The global optimization check is now correctly positioned to only affect non-platform-specific URLs, allowing the generic Deco optimization service to be toggled independently of platform-native optimizations.


125-139: Verify that platform-specific optimizations intentionally bypass the global image optimization flag.

The code confirms that VNDA, Shopify, VTEX, and Wake optimizations (lines 121-139) execute before the isImageOptmizationEnabled() check (line 141), meaning they will always apply regardless of the enableImageOptimization feature flag. This is a significant behavior change.

Please confirm this is intentional—that native platform optimizations should always be used independent of the global optimization flag. If confirmed, consider adding an explicit comment in the code to document why platform-specific optimizations bypass the feature flag, and update any documentation describing the optimization behavior.

Comment on lines +121 to +123
if (originalSrc.includes("fbitsstatic.net/img/")) {
return optimizeWake(opts);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n website/components/Image.tsx | head -150

Repository: deco-cx/apps

Length of output: 5058


🏁 Script executed:

rg -i "fbitsstatic" --type ts --type tsx --type js -B 2 -A 2

Repository: deco-cx/apps

Length of output: 83


🏁 Script executed:

rg -i "fbitsstatic" -A 2 -B 2

Repository: deco-cx/apps

Length of output: 294


🏁 Script executed:

rg -i "wake|optimizeWake" -B 2 -A 2

Repository: deco-cx/apps

Length of output: 23296


🏁 Script executed:

fd -e "test" -o -e "spec" | head -20

Repository: deco-cx/apps

Length of output: 172


🏁 Script executed:

rg "getOptimizedMediaUrl|Image\.tsx" -l --type-list

Repository: deco-cx/apps

Length of output: 445


🏁 Script executed:

rg "getOptimizedMediaUrl" -B 3 -A 3

Repository: deco-cx/apps

Length of output: 2156


🏁 Script executed:

rg "test|spec" website/components/ -i

Repository: deco-cx/apps

Length of output: 43173


Strengthen the Wake URL pattern check for consistency and correctness.

The check at line 121 uses .includes("fbitsstatic.net/img/"), which differs from the more precise pattern checks for other platforms (VNDA and Shopify use .startsWith() with full protocol; VTEX uses regex domain matching). The .includes() approach could match this string anywhere in the URL, including in query parameters or as part of a different domain (e.g., https://evil.com?redirect=fbitsstatic.net/img/x), potentially causing Wake optimization to be incorrectly applied to non-Wake images.

Align with other platform checks by using a precise pattern:

-  if (originalSrc.includes("fbitsstatic.net/img/")) {
+  if (originalSrc.startsWith("https://fbitsstatic.net/img/") || 
+      originalSrc.startsWith("http://fbitsstatic.net/img/")) {
     return optimizeWake(opts);
   }

Or with regex to support subdomains if needed:

-  if (originalSrc.includes("fbitsstatic.net/img/")) {
+  if (/^https?:\/\/[^\/]*fbitsstatic\.net\/img\//.test(originalSrc)) {
     return optimizeWake(opts);
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (originalSrc.includes("fbitsstatic.net/img/")) {
return optimizeWake(opts);
}
if (originalSrc.startsWith("https://fbitsstatic.net/img/") ||
originalSrc.startsWith("http://fbitsstatic.net/img/")) {
return optimizeWake(opts);
}
Suggested change
if (originalSrc.includes("fbitsstatic.net/img/")) {
return optimizeWake(opts);
}
if (/^https?:\/\/[^\/]*fbitsstatic\.net\/img\//.test(originalSrc)) {
return optimizeWake(opts);
}

@guitavano guitavano closed this Dec 10, 2025
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