Skip to content

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

Open

Description

@LoikStyle

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)

Activity

  1. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed write-up!

    On the crypto.subtle part: in current v2 the draft blob ID code (packages/app/src/runtime/persistence/drafts.ts, which replaced draft-store.ts) already falls back to crypto.getRandomValues when crypto.subtle is unavailable, so attachments shouldn't fail that way on insecure origins anymore. If you still see the digest TypeError on a recent v2 release, please reply with your opencode --version and the browser you used.

    The rest is a feature request: the web app should downscale and re-encode large image attachments on the client (for example, cap at 1920px and convert HEIC/WebP/JPEG to JPEG), and should accept HEIC/HEIF in the picker. Today the app sends images as they are and doesn't support HEIC. Maintainers will consider it.

    Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions