anomalyco / anomalyco/opencode
TUI converts pasted image file paths to attachments even when the active model has no image input
@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 — noattachment/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:
- Clipboard image check —
packages/tui/src/clipboard.tsruns
osascript ... 'the clipboard as "PNGf"'on paste; if the clipboard holds
image data, it's attached. - Local path check —
packages/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
- Configure a text-only model as the active model.
- Copy the full path of any
.pngon disk (e.g.⌘⌥Cin Finder, or drag into
a terminal and copy the printed path). - 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
inlocal-attachment.tsare intercepted. tui.jsonhas no option to disable image-paste conversion.- The client already knows whether a model accepts attachments
(attachment: true/modalities.inputin model config), so the paste handler
could check the active model before converting.
Suggested fixes (either or both)
- Skip image conversion when the active model lacks image input modality.
- Add a
tui.jsonoption 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.