anomalyco / anomalyco/opencode

Pasting an image file loses the original path — model only gets an inline data: URL

Open
#48,190 1 comment 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Sep 9, 2026.

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

Description

Description

When an image file is pasted into the TUI composer (pasted path text, or a Finder file copy), the attachment is always submitted as an inline data: URL. The original path only survives in the part's source.path metadata, which the model never sees. After materialization the model effectively has an image and a temp path, so it cannot reference the source file it was given.

The server already does the right thing for file: URL attachments: in packages/opencode/src/session/prompt.ts it emits a synthetic text part with {"filePath": ...} alongside the image. The TUI paste flow just never produces file: URLs, so that path is unreachable.

Secondary symptom on macOS: pasting with the internal paste command (prompt.paste) with a Finder file copy on the clipboard attaches the file's generic icon bitmap, because clipboard.read() requests the clipboard as "PNGf" and the icon flavors win over the file URL/text flavors.

Steps to reproduce
  1. Copy an image file in Finder
  2. Paste it into the TUI composer (it is auto-attached as [Image 1])
  3. Submit and ask the model for the path of the attached image
  4. The model has no path: the part is a data: URL, materialized to a temp file
OpenCode version

v0.0.0-beta-19381 (also present on dev)

Operating System

macOS

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.