Skip to content

fix(web): show a preview-failed state when an image won't load - #674

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/web-broken-preview-error-state
Aug 14, 2026
Merged

fix(web): show a preview-failed state when an image won't load#674
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/web-broken-preview-error-state

Conversation

@zachdunn

Copy link
Copy Markdown
Member

In plain terms

A corrupt or unreachable image on the public file page used to show the browser’s broken-image icon. That looks like a dead page even when the file record is fine. The stage now swaps to a preview-failed state, and a render crash in the signed-in React islands no longer blanks the rest of the shell.

Preview failed state

What it does / what it is not

  • Does: if an image or video fails to load, hide the native chrome and show “Preview failed” with a short reason and an Open original link. Fit / Full width hide because they don’t apply.
  • Does: use the same fallback shell for known non-previewable kinds (file / unsupported / missing) on the file page, gallery item, and gallery grid.
  • Does: wrap the files table and screenshots islands so a render throw keeps the header, nav, and rail up.
  • Does: serve the branded /500 page if the Worker itself throws, instead of a Cloudflare 1101.
  • Does not: diagnose why the bytes failed (corrupt upload vs CDN vs decode). The copy stays generic on purpose.
  • Does not: change 404 / unlisted / deleted file pages. Those already had their own states.

How to try it

The 25-byte cache probe from the original report is still live:

https://uploads.sh/f/default/gh/_cachetest/probe-1783465136.png

Locally, pnpm dev:web and open the same path on http://localhost:4321 — the page talks to the production API, so the broken file is the same one.

Technical notes

  • Load failures are a client error (or complete && naturalWidth === 0) on <img> / <video>. The file record can be fine while the object 404s, fails to decode, or never arrives.
  • Shared helpers live in media-load.ts; the visible shell is MediaFallback.astro. ImagePreview and MediaStage bind directly. The gallery grid uses data-media-load + bindMediaFallbacks.
  • The two signed-in React mounts (WorkspaceFileTable, ScreenshotsByPath) wrap in IslandErrorBoundary. Other account/admin pages are vanilla JS and already have per-flow error copy.
  • Thumbnail cells use <img onError> instead of a silent empty background-image.

Test plan

  • pnpm --filter @uploads/web test (619 passing)
  • Opened the original 25-byte probe in a local browser: stage shows Preview failed, Fit/Full width gone, rail still works
  • Mobile viewport of the same page
  • Missing file (/f/default/does-not-exist.png) still shows file.not_found
  • /500 still renders the branded application-error card
  • CI lint + typecheck + test on this PR

Replace the browser broken-image icon with a designed fallback, and
keep signed-in React islands from blanking the rest of the shell.
@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ee6cdce

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

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
uploads-auth ee6cdce Commit Preview URL

Branch Preview URL
Aug 14 2026, 06:45 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

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
uploads-web ee6cdce Commit Preview URL

Branch Preview URL
Aug 14 2026, 06:46 PM

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (2)
  • coderabbit:review
  • review
🚫 Excluded labels (none allowed) (1)
  • wip

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c57f222-9c4d-4756-99ad-201e764fef0b

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:

  • 🔍 Trigger review

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.

@uploads-sh

uploads-sh Bot commented Aug 14, 2026

Copy link
Copy Markdown

file-preview-failed-desktop.webp
/f/default/gh/_cachetest/probe-1783465136.png · error

localhost-f-default-gh-_cachetest-probe-1783465136.png-error.webp
/f/default/gh/_cachetest/probe-1783465136.png · error

Maintained by uploads.sh — re-uploading a file with the same name updates it everywhere it is embedded.
Add media: uploads put <file> --pr <N> --comment (or --issue <N>) · docs

@zachdunn
Zach Dunn (zachdunn) merged commit 61aeb7b into main Aug 14, 2026
5 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the fix/web-broken-preview-error-state branch August 14, 2026 18:55
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