[codex] Optimize archive thumbnails with CF loader - #61
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
📦 esbuild Bundle Analysis for doom-indexThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: .open-next/server-functions/default/handler.mjs.meta.json, Out file: .open-next/server-functions/default/handler.mjs
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
doom-index | 98c190c | Commit Preview URL Branch Preview URL |
Apr 08 2026, 04:46 AM |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/archive/painting-item.tsx (1)
30-32: Include protocol-relative URLs in optimizer-bypass detection.The current predicate only catches
http://andhttps://. IfimageSourcescontains//gateway/..., it won’t bypass optimizer even though it is still external.Suggested patch
const shouldBypassImageOptimizer = imageSources.some( - (imageSource) => imageSource.startsWith("http://") || imageSource.startsWith("https://"), + (imageSource) => + imageSource.startsWith("http://") || + imageSource.startsWith("https://") || + imageSource.startsWith("//"), );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/archive/painting-item.tsx` around lines 30 - 32, The predicate that computes shouldBypassImageOptimizer currently only checks imageSources for "http://" and "https://", so protocol-relative URLs like "//gateway/..." aren't detected; update the check in the shouldBypassImageOptimizer computation to also treat strings starting with "//" (or otherwise matching a protocol-relative/external URL pattern) as external so the optimizer is bypassed for those imageSources.tests/unit/components/archive/archive-grid.test.tsx (1)
82-92: Consider adding a complementary “does not bypass” case.This test locks the positive path well. Adding one local/relative-image case asserting
data-unoptimized="false"would prevent accidental blanket bypass regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/components/archive/archive-grid.test.tsx` around lines 82 - 92, Add a complementary negative test that ensures local/relative images are not bypassed by the next/image optimizer: create a new test (e.g., "does not bypass the next/image optimizer for local thumbnails") that imports ArchiveGrid, renders it with an item whose image URL is a local/relative path (use the existing createPainting helper or construct an item with a relative src), then query images via getAllByRole("img") and assert the rendered image has data-unoptimized === "false" (or not present). Place the test alongside the existing "bypasses the next/image optimizer..." test and reference ArchiveGrid and createPainting to locate the code under test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/archive/painting-item.tsx`:
- Around line 30-32: The predicate that computes shouldBypassImageOptimizer
currently only checks imageSources for "http://" and "https://", so
protocol-relative URLs like "//gateway/..." aren't detected; update the check in
the shouldBypassImageOptimizer computation to also treat strings starting with
"//" (or otherwise matching a protocol-relative/external URL pattern) as
external so the optimizer is bypassed for those imageSources.
In `@tests/unit/components/archive/archive-grid.test.tsx`:
- Around line 82-92: Add a complementary negative test that ensures
local/relative images are not bypassed by the next/image optimizer: create a new
test (e.g., "does not bypass the next/image optimizer for local thumbnails")
that imports ArchiveGrid, renders it with an item whose image URL is a
local/relative path (use the existing createPainting helper or construct an item
with a relative src), then query images via getAllByRole("img") and assert the
rendered image has data-unoptimized === "false" (or not present). Place the test
alongside the existing "bypasses the next/image optimizer..." test and reference
ArchiveGrid and createPainting to locate the code under test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a842133b-c9bc-4f30-aac3-c8b7b5110bfc
📒 Files selected for processing (4)
.gitignoresrc/components/archive/painting-item.tsxsrc/components/ui/progressive-image.tsxtests/unit/components/archive/archive-grid.test.tsx
Summary
next/imagepath while emitting/cdn-cgi/image/...requestsValidation
bun test --env-file=.example.vars tests/unit/lib/pure/arweave-gateway.test.ts tests/unit/lib/archive-image-sources.test.ts tests/unit/image-loader.test.ts tests/unit/components/archive/archive-grid.test.tsx tests/unit/next-config.test.tsbun run lintbun run formatbun run typecheckbun run buildNotes
bun run build:cfstill fails locally under Node 25 because@opennextjs/cloudflarecurrently errors onglobSync; the regular Next build passes.