anomalyco / anomalyco/opencode

Web: image attachments fail on insecure origins; no client-side optimization

Open
#46,419 1 comment 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 31, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

Attaching an image in the web app is unreliable, especially over remote/slow or insecure connections:

  • Large photos upload as full-size payloads, and HEIC/HEIF are not accepted by the picker or readable by the vision model.
  • On an insecure (http) origin, crypto.subtle is undefined, so blob ID generation throws and the attachment silently never gets added to the prompt.

Expected

Attach a JPG/PNG/HEIC and have it appear in the prompt reliably, with a reasonably-sized payload.

Actual

  • Blob reference creation fails on insecure origins (TypeError: ... digest).
  • Large images are sent un-optimized; HEIC/HEIF are unsupported.

Suggested fix

  • Downscale/re-encode images client-side (HEIC/WebP/JPEG → JPEG, PNG kept, capped at 1920px / quality 0.82) with a short timeout fallback to the original.
  • Fall back to crypto.getRandomValues when crypto.subtle is unavailable.

Related (not duplicates)

  • #46168 (crypto.randomUUID in insecure context) - same root cause class (crypto unavailable on insecure origins), but affects other call sites (session delete, drag-drop). The uuid() helper already has a random fallback; the direct crypto.randomUUID() calls are separate. My change targets crypto.subtle in draft-store.ts specifically, which is still unfixed on dev.
  • #45986 (images persisted but stripped from model request on v2 beta) - different layer (server-side stripMedia / message-v2 path), not the client attachment failure.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.