anomalyco / anomalyco/opencode

TUI converts pasted image file paths to attachments even when the active model has no image input

Open
#47,558 1 comment 0 reactions 1 assignee View on GitHub

@simonklee is already working on this.

Since Sep 6, 2026.

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

Description

Title: TUI converts pasted image file paths to attachments even when the active model has no image input — no way to disable

Environment

  • opencode 1.18.27 (TUI)
  • macOS 26.6.2
  • Model: zai-coding-plan/glm-5.3 (text-only — no attachment/image modality in config)

Summary

The TUI's paste handler intercepts pasted text and converts it into an image
attachment whenever the text is (or contains) a path to an existing image file,
regardless of whether the active model supports image input. With a
text-only model this makes the paste a guaranteed failure — and there is no
config option to disable the behavior.

Two conversion paths trigger this:

  1. Clipboard image checkpackages/tui/src/clipboard.ts runs
    osascript ... 'the clipboard as "PNGf"' on paste; if the clipboard holds
    image data, it's attached.
  2. Local path checkpackages/tui/src/component/prompt/local-attachment.ts
    maps image/PDF extensions (.png, .jpg, .gif, .webp, .avif, .pdf, ...)
    and converts a pasted path to an existing matching file into an attachment.
    The detection also fires when the path is embedded in surrounding text
    (e.g. wrapped in backticks or quotes).

Repro

  1. Configure a text-only model as the active model.
  2. Copy the full path of any .png on disk (e.g. ⌘⌥C in Finder, or drag into
    a terminal and copy the printed path).
  3. Paste into the TUI prompt — bare, quoted, or backtick-wrapped.

Actual: the text is replaced with [Image 1]; on submit the model receives
the error:

Cannot read "Screenshot ....png" (this model does not support image input).

Expected: the path is inserted as plain text (or at minimum, the conversion
is skipped when the active model can't accept image attachments).

Notes

  • Paths to non-image files and directories are unaffected — only the extensions
    in local-attachment.ts are intercepted.
  • tui.json has no option to disable image-paste conversion.
  • The client already knows whether a model accepts attachments
    (attachment: true / modalities.input in model config), so the paste handler
    could check the active model before converting.

Suggested fixes (either or both)

  1. Skip image conversion when the active model lacks image input modality.
  2. Add a tui.json option to disable paste-to-attachment conversion.

Workaround

Mention the filename in the message and let the agent read the file from disk;
/editor also bypasses the paste handler for raw-text pasting.

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.