tui: pasting a PDF path auto-attaches it, which text-only models cannot read
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in packages/tui/src/component/prompt/index.tsx, where pasteInputText() checks pasted paths and pasteAttachment() labels attachments. Trace how binary attachments are handled and check the existing prompt tests for paste behavior. Done means pasting a PDF path no longer causes a text-only model request to fail, while the issue’s expected behavior is met.
Written by the indexing model from the issue text.
Description
Summary
Pasting a path to an existing PDF into the prompt auto-attaches the file as [PDF 1]. With a text-only model (no PDF input), sending the message fails, and there is no setting to disable this auto-attachment.
Environment
- opencode version: 2.0.32
- OS: Linux 7.2.9-arch1-1 (Arch Linux, x86_64)
- Terminal: xterm-256color
- Shell: /usr/bin/zsh
- Install/channel: packaged binary at
/usr/bin/opencode(latest) - Active plugins: none found in config
Reproduction
- Copy the absolute path of an existing PDF (e.g.
/home/user/Downloads/paper.pdf). - Paste it into the prompt.
- The prompt inserts a
[PDF 1]attachment instead of the path text. - Send the message with a model that does not accept PDF input.
- The request fails:
this model does not support pdf input.
Reproducible consistently.
Expected Behavior
Pasting a document path should insert the path as text so the agent can read it with tools. Auto-attachment should be limited to images, which vision-capable models can consume — or there should be a setting to disable file-path auto-attachment.
Actual Behavior
Any pasted text that resolves to an existing binary file is attached. PDFs become [PDF n], which text-only models cannot read, so the turn fails instead of passing the path to the agent.
Additional Context
Relevant code: packages/tui/src/component/prompt/index.tsx
pasteInputText()computespastedFilepath(text), callsreadLocalAttachment(filepath), and forattachment.type === "binary"callspasteAttachment().pasteAttachment()labels PDFs as[PDF n]and images as[Image n].
Possible fixes (either):
- Only auto-attach images; insert everything else as text:
if (attachment?.type === "binary") {
if (!attachment.mime.startsWith("image/")) {
input.insertText(normalizedText)
return
}
await pasteAttachment({ filename, filepath, mime: attachment.mime, content: ... })
return
}
- Add a CLI setting (e.g. in
~/.config/opencode/cli.json), such as:
{ "prompt": { "paste_attach": "images" } }
with values images | all | never.
The second keeps the current behavior available for users who do want document attachments.
- Dominant language
- TypeScript
- Stars
- 215k
- Forks
- 28.9k
- Avg merge
- 8h 11m
- Merged PRs (30d)
- 365
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from anomalyco/opencode
-
reproduced
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
anomalyco/opencode#57711 · 1 comment ·
Maintainers usually reply within 1 day
-
pending close triaging
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
anomalyco/opencode#57664 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
anomalyco/opencode#57579 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#57536 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
fs: /cd and file pickers fail on FreeBSD/ZFS — `stat` throws "dev exceeds the safe integer range" (fixed in @effect/platform-node-shared 4.0.5)Possibly taken @argszero claimed this today. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
anomalyco/opencode#57518 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xavxyz/bei-shan-lin-shui#57 ·
Maintainers usually reply within 1 day
-
[BUG] rag: sentence content can cross the reported sentence boundariesPossibly taken @LJK-ikun claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
platformatic/mcp#361 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
siyuan-note/siyuan#20799 · 7 comments ·
Maintainers usually reply within 1 day