tui: pasting a PDF path auto-attaches it, which text-only models cannot read
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 packages/tui/src/component/prompt/index.tsx 开始,这里 pasteInputText() 会检查粘贴的路径,而 pasteAttachment() 会为附件添加标签。追踪二进制附件的处理方式,并检查现有 prompt 测试中关于粘贴行为的部分。完成标准是:粘贴 PDF 路径不再导致发给纯文本模型的请求失败,并且符合 issue 预期的行为。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 215k
- 派生
- 28.9k
- 平均合并
- 4 小时 21 分钟
- 30 天内合并 PR
- 476
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
reproduced
难度 2/5 1-3 小时 新手友好度 74/100
anomalyco/opencode#58247 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#58216 · 1 条评论 ·
维护者通常 1 天内回复
-
pending close triaging
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#58181 · 1 条评论 ·
维护者通常 1 天内回复
-
Opencde Github Actions Bot Cannot Install可能已有人在做 @zzz-creator 今天认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#57911 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#57855 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
db-ux-design-system/core-web#8613 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug:new
难度 1/5 1 小时以内 新手友好度 78/100
callstackincubator/simlock#934 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
gchq/LD-Explorer#286 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复