Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#57,698 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
cli, frontend

Hướng nghiên cứu

Bắt đầu tại packages/tui/src/component/prompt/index.tsx, nơi pasteInputText() kiểm tra các đường dẫn được dán và pasteAttachment() gắn nhãn cho tệp đính kèm. Theo dõi cách xử lý các tệp đính kèm nhị phân và kiểm tra các bài kiểm thử prompt hiện có về hành vi dán. Công việc hoàn tất khi việc dán đường dẫn PDF không còn khiến yêu cầu gửi đến mô hình chỉ xử lý văn bản bị lỗi, đồng thời đáp ứng hành vi mà issue mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
215k
Fork
28.9k
Merge trung bình
8 giờ 11 phút
Pull request đã merge (30 ngày)
365

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.