desktop: pasted image breaks and send fails with "Failed to fetch" after the clipboard temp file is deleted

Open Beginner friendly
#62,052 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
desktop-dev, typescript
Domain
desktop

Research direction

Start by reading packages/app/src/runtime/persistence/drafts.ts, especially putBlob and createBlobReference, then trace how pasted image bytes are stored and how the preview and blobDataUrl use the original File. Reproduce by pasting two images from a clipboard source that deletes the previous temp file; done means the first thumbnail remains visible and sending succeeds after that file is deleted.

Written by the indexing model from the issue text.

Description

reproduced
Description

Pasting an image that the clipboard hands over as a temp file (on Windows, WeType / 微信输入法 keeps clipboard images in %LOCALAPPDATA%Low\Tencent\WeType\ClipboardTmp and deletes the previous one on every new copy) works at first. Once that temp file is gone, the thumbnail turns into a broken image and sending fails with "Failed to fetch". Pasting two images in a row is enough: the first one always breaks.

The bytes are already saved to the draft store on paste, but the preview and blobDataUrl still read the original File. Chromium reads a disk-backed File lazily, so the send goes back to the deleted file. I checked this in plain Chromium: once the file is deleted, fetch(URL.createObjectURL(file)) throws TypeError: Failed to fetch and an <img> with that URL fails to load. An in-memory copy of the same bytes keeps working.

Plugins

none relevant

OpenCode version

Desktop 1.19.5. The same code path is on dev (packages/app/src/runtime/persistence/drafts.ts, putBlob / createBlobReference)

Steps to reproduce
  1. On Windows with WeType's clipboard enabled, copy image A and paste it into the prompt.
  2. Copy image B. WeType deletes A's temp file. Paste B.
  3. A's thumbnail is now broken. Press send and you get "发送提示失败 / Failed to fetch".
Screenshot

No response

Operating System

Windows 10 Pro 22H2

Terminal

n/a (desktop app)

Dominant language
TypeScript
Stars
224k
Forks
30k
Avg merge
6h 16m
Merged PRs (30d)
507

Getting set up

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.

More from anomalyco/opencode

All issues in anomalyco/opencode

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.