feat(tui): add compact image paste placeholders - #418
Conversation
tt-a1i
left a comment
There was a problem hiding this comment.
Reviewed the current head 9c7f9ba. The compact placeholders and atomic deletion address a useful TUI problem, but attachment ownership still breaks across submission paths. Please address the two inline findings before merging.
Validation: the 11 image-paste/editor-layer tests pass locally, and all three required CI jobs are green. Additional minimal reproductions using Pi 0.85.1's actual InteractiveMode.flushCompactionQueue and ExtensionRunner.emitInput methods reproduce both findings. These are programmatic lifecycle reproductions, not visual TUI acceptance or live provider calls.
tt-a1i
left a comment
There was a problem hiding this comment.
Reviewed at head bc2739f.
Standards
[P1] Image ownership is inferred only from the OS temp directory, a pi-clipboard filename pattern, and statSync(). statSync follows symlinks, and the later read/delete has a check-to-use race. The extension can therefore claim and remove a matching file without runtime-proven ownership. Please use a Pi-provided attachment handle, or copy into an OpenPI-owned directory and validate identity with no-follow, bounded I/O.
[P1] The 481-line editor layer depends on several private lifecycle details at once: onSubmit wrapping, raw Alt+Enter handling, setText cleanup timing, input ordering, and compaction retry behavior. Pi 0.85.1 still exposes no stable attachment/submission seam, so upgrades can silently break ownership. This should be reduced around an explicit Pi-native attachment/submission boundary rather than duplicating InteractiveMode lifecycle assumptions.
[P2] The input handler performs unbounded synchronous readFileSync plus base64 conversion. A large clipboard file can block the TUI and amplify memory use. Add a size limit and bounded asynchronous reading after identity validation.
Spec
[P1] Successful compaction with multiple queued submissions is still unsafe. Every submission enters pending, but after normal compaction only the first queued message goes through prompt/input; later messages use steer/followUp and bypass the input transform. Their images are neither sent nor promptly cleaned, and a later identical text can consume an old FIFO submission. The existing test covers only one willRetry=true submission, not successful compaction with multiple queued submissions or repeated identical text.
The Alt+Enter cleanup race from the previous review is fixed, but attachment ownership across compaction remains incomplete. Please add the missing lifecycle evidence and resolve the current main conflict before requesting re-review.
…ge-paste # Conflicts: # README.md
问题
关联 #413。
在 TUI 中粘贴图片时,输入框会显示冗长的临时文件路径,影响提示词的阅读和编辑,多图场景下尤其明显。
价值
[Image #N]展示粘贴的图片。实现方案
[Image #N],并在当前草稿中维护占位符与图片文件的对应关系。[Image #N],同时释放关联的临时图片。input事件中读取图片并生成ImageContent,与已有图片载荷合并后交给模型。[Image #N],确保用户侧消息与输入时的内容一致。验证
[Image #1],模型能够正常读取图片。影响
改动仅影响 TUI 交互式图片粘贴。
已知限制:Pi 在会话压缩期间排队的消息可能绕过原生

input事件,仅保留文本。该问题需要进一步讨论,因此暂不关闭 #413。