Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

tui: pasting a PDF path auto-attaches it, which text-only models cannot read

Open Beginner friendly
#57,698 3 comments 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
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli, frontend

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

  1. Copy the absolute path of an existing PDF (e.g. /home/user/Downloads/paper.pdf).
  2. Paste it into the prompt.
  3. The prompt inserts a [PDF 1] attachment instead of the path text.
  4. Send the message with a model that does not accept PDF input.
  5. 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() computes pastedFilepath(text), calls readLocalAttachment(filepath), and for attachment.type === "binary" calls pasteAttachment().
  • pasteAttachment() labels PDFs as [PDF n] and images as [Image n].

Possible fixes (either):

  1. 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
}
  1. 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

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.