You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(tui): optimize image paste UX with compact placeholders and atomic deletion #413
Cursor's provider does not execute Cursor-native read-file tools, so convert an explicit leading image path into the same ImageContent shape used by CLI/RPC attachments before the agent turn starts.
它是因为 cursor 的模型无法自己调用 read 工具,才必须提前转好。反过来说,其他 provider 不需要它,恰恰是因为「发路径 + 模型自己 read」在那里是可行且被有意保留的默认行为。宿主 Pi 也是同样的设计:图片写到 tmpdir 后路径长期有效,read 工具随时能打开,因此 Pi 从不删除这个临时文件。
The display-only portion of this issue (compact placeholders, atomic deletion, transcript rendering) has been split into #527 with a narrower scope that does not change submission semantics or file lifecycle.
The investigation behind the split is documented in #527's problem section — in short, main only converts images to ImageContent for the Cursor provider, and neither Pi nor that implementation deletes temp files. Making those changes unconditional belongs in a separate discussion.
#418 now targets #527. The multimodal ImageContent conversion and temp file cleanup items from this issue's acceptance criteria remain open for a future dedicated issue.
Activity
onychen commentedon Sep 6, 2026
我来认领这个 issue,计划围绕 TUI 图片粘贴占位符、占位符原子删除、多图顺序映射和临时文件生命周期管理进行实现,并补充相关测试,确保现有静态检查与测试通过。
fix(image-paste): keep the transcript free of clipboard temp paths
onychen commentedon Sep 10, 2026
补充一条实现过程中查到的仓库现状,可能影响这个 issue 的验收口径,想先和你对一下。
源仓库当前的提交行为
我把 main 上所有注册在
input事件的处理器都过了一遍,只有一个:产出
images的位置也只有extensions/ai-providers/cursor/input-images.ts:94一处(goal里那几处是清理 completion marker,不新增图片)。而这个唯一的处理器有三道闸门,必须全部满足才会转换:
所以 provider 不是 cursor 时第二道就放行了。也就是说,在 Claude / Gemini / Antigravity 等 provider 下,粘贴图片路径提交后,模型收到的是路径纯文本,没有任何多模态转换。
这份实现的注释也说明了它为什么是特例:
它是因为 cursor 的模型无法自己调用 read 工具,才必须提前转好。反过来说,其他 provider 不需要它,恰恰是因为「发路径 + 模型自己 read」在那里是可行且被有意保留的默认行为。宿主 Pi 也是同样的设计:图片写到 tmpdir 后路径长期有效,
read工具随时能打开,因此 Pi 从不删除这个临时文件。由此想确认的两点
第一,「提交时作为多模态载荷传递」这条,如果要覆盖所有 provider,等于改变了 OpenPI 当前对非 cursor provider 的提交语义——模型收到的内容会与未安装该扩展时不同。我想确认这个范围扩张是否为本意,还是延续 cursor 那种按需补齐即可。
第二,「临时文件清理」与多模态传递之间有一个实际冲突。提交后立即删除文件,该轮之后模型和用户都无法再通过
read打开这张图,压缩、会话回滚、历史召回等场景下这条退路会消失;而 Pi 原生和 cursor 那份实现都保留了它(我 grep 过整个 cursor 目录,没有任何rmSync或unlink)。如果不删,则与这条边界的字面表述有出入。我的建议
把这个 issue 收敛到它的问题背景所描述的范围内——也就是 TUI 输入框的可读性。#413 列的三条问题(视觉割裂、删除需逐字退格、多图失去可读性)和附的截图都指向输入框显示,这部分可以在不改变提交语义的前提下完整解决:编辑器内显示
[Image #N]、支持原子删除、多图按序编号,提交时展开回真实路径,模型收到的字节与当前 main 完全一致。多模态
ImageContent我认为值得做,但它是一次提交语义的变更而非显示优化,建议拆成独立 issue 和 PR:这样可以单独讨论覆盖哪些 provider、非视觉模型如何降级(仓库里antigravity/google-conversion.ts:95的downgradeUnsupportedImages已有基于model.input.includes("image")的现成写法)、以及临时文件生命周期该归谁管。混在一个 PR 里,显示层的改进会被更大的语义变更拖住。临时文件清理这条,建议调整为只清理未提交的草稿(占位符被删除、会话结束时),已提交的沿用 Pi 与 cursor 的既有做法交给系统清理,以保留
read退路。如果你认可这个拆分,我把 #418 的范围按此调整;如果你倾向保持原验收标准,我也可以按原样实现,只是希望先把上面第二点的冲突定下来。@tt-a1i 在 #418 的 review 里也提到可以显式调整验收标准,这个结论确定后我会同步过去。
onychen commentedon Sep 10, 2026
The display-only portion of this issue (compact placeholders, atomic deletion, transcript rendering) has been split into #527 with a narrower scope that does not change submission semantics or file lifecycle.
The investigation behind the split is documented in #527's problem section — in short,
mainonly converts images toImageContentfor the Cursor provider, and neither Pi nor that implementation deletes temp files. Making those changes unconditional belongs in a separate discussion.#418 now targets #527. The multimodal
ImageContentconversion and temp file cleanup items from this issue's acceptance criteria remain open for a future dedicated issue.JS-banana commentedon Sep 14, 2026
认可拆分:显示层诉求已由 #527 + #418 完整覆盖,我已在真机完成验收(见 #418 的留言)。
多模态范围:不是要无差别改语义。按 provider 能力门控即可(
model.input.includes("image"),仓库里 antigravity 的downgradeUnsupportedImages已有先例),延续 cursor 那种按需补齐。临时文件冲突:认可「只清理未提交草稿」。另外提供一个可参考的化解形态——转存而非删除:图片字节以
ImageContent进消息作为权威副本,read工具需要时再从消息字节物化文件(oh-my-pi 的getImageAttachments就是这么做的)。这样 OS 临时文件随时可清,read退路和历史会话都不受影响,生命周期归会话管理,「提交即删 vs 保留 read 退路」的两难就化解了。feat(tui): add compact image paste placeholders (#418)