Skip to content

[codex] Optimize archive thumbnails with CF loader - #61

Merged
posaune0423 merged 2 commits into
mainfrom
codex/archive-unoptimized-temp
Apr 8, 2026
Merged

[codex] Optimize archive thumbnails with CF loader#61
posaune0423 merged 2 commits into
mainfrom
codex/archive-unoptimized-temp

Conversation

@posaune0423

@posaune0423 posaune0423 commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace the archive thumbnail workaround with a Cloudflare custom image loader so archive cards stay on the next/image path while emitting /cdn-cgi/image/... requests
  • add fixed primary/fallback Arweave gateway handling, including a public fallback allowlist env and normalized gateway parsing
  • extend regression coverage for archive image sources, next config image settings, and the custom loader behavior
  • keep the repo housekeeping change that ignores local ArDrive wallet and dist artifacts

Validation

  • 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.ts
  • bun run lint
  • bun run format
  • bun run typecheck
  • bun run build

Notes

  • bun run build:cf still fails locally under Node 25 because @opennextjs/cloudflare currently errors on globSync; the regular Next build passes.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 040fa9e5-6c37-45a5-a769-ec674ea5bfdc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/archive-unoptimized-temp

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.

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

📦 esbuild Bundle Analysis for doom-index

This analysis was generated by esbuild-bundle-analyzer. 🤖

Meta File Out File Size (raw) Note
.open-next/server-functions/default/handler.mjs.meta.json .open-next/server-functions/default/handler.mjs 10.62 MB ✅ -47.22 KB (-0.4%)
Largest paths These 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

Path Size
.open-next/server-functions/default ${{\color{Goldenrod}{ █████████████████████████ }}}$ 100.0%, 10.62 MB
.open-next/cloudflare-templates/shims ${{\color{Goldenrod}{ }}}$ 0.0%, 368 B
optional-deps-missing-dependency:/critters ${{\color{Goldenrod}{ }}}$ 0.0%, 141 B
Details

Next to the size is how much the size has increased or decreased compared with the base branch of this PR.

  • ‼️: Size increased by 20% or more. Special attention should be given to this.
  • ⚠️: Size increased in acceptable range (lower than 20%).
  • ✅: No change or even downsized.
  • 🗑️: The out file is deleted: not found in base branch.
  • 🆕: The out file is newly found: will be added to base branch.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

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
doom-index 98c190c Commit Preview URL

Branch Preview URL
Apr 08 2026, 04:46 AM

@posaune0423 posaune0423 self-assigned this Apr 8, 2026
@posaune0423 posaune0423 added the type:bug 🐛 Bug fix label Apr 8, 2026
@posaune0423
posaune0423 marked this pull request as ready for review April 8, 2026 04:51

@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.

🧹 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:// and https://. If imageSources contains //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

📥 Commits

Reviewing files that changed from the base of the PR and between 34b2a91 and 98c190c.

📒 Files selected for processing (4)
  • .gitignore
  • src/components/archive/painting-item.tsx
  • src/components/ui/progressive-image.tsx
  • tests/unit/components/archive/archive-grid.test.tsx

@posaune0423
posaune0423 merged commit 96bb33d into main Apr 8, 2026
7 checks passed
@posaune0423 posaune0423 changed the title [codex] Temporarily bypass archive thumbnail optimizer [codex] Optimize archive thumbnails with CF loader Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant