Repository navigation
Description
Problem
Relates to #413.
Pasting clipboard images in the TUI editor inserts a long temporary file path that occupies most of the line width, makes the prompt unreadable when multiple images are attached, and requires dozens of backspace presses to remove. #413 identified this problem and proposed compact [Image #N] placeholders, which this issue carries forward with a narrower scope.
#413's acceptance criteria also include converting images to multimodal ImageContent at submission time and cleaning up temporary files. After investigating the codebase during the #418 implementation, those two items turn out to change submission semantics rather than improve display, and they conflict with Pi's existing design:
- Submission semantics. On the current
mainbranch the onlyinputhandler that producesImageContentisextensions/ai-providers/cursor/input-images.ts, gated onctx.model?.provider === "cursor". For every other provider, the model receives the raw file path and reads the image through thereadtool on demand. Making all providers receiveImageContentunconditionally changes what the model sees relative to an unmodified Pi install. - Temporary file cleanup. Pi leaves clipboard images in the temp directory so the
readtool can open them in any later turn. The Cursor input-images implementation also does not delete files after conversion. Deleting on submission would breakreadaccess during compaction, rollback, and session reload.
Both items are worth pursuing but belong in a dedicated issue where provider-aware capability gating (model.input.includes("image")), the interaction with downgradeUnsupportedImages, and file lifecycle ownership can be discussed on their own terms.
Proposed scope
This issue covers TUI display and editing only. The model receives the same bytes it would without this extension installed.
Acceptance criteria
- Pasted clipboard images display as
[Image #N]in the TUI editor. - Backspace on any position within
[Image #N]removes the entire token atomically. - Multiple images in one input are numbered sequentially (
[Image #1],[Image #2], …). - Submission expands placeholders back to real file paths so the model and
readtool receive unmodified content. - The transcript renders submitted clipboard paths as compact placeholders (not raw temp paths).
- Transcript collapsing only rewrites files Pi wrote to the temp directory; paths in other directories, Markdown link/image targets, fenced code blocks, and inline code are left verbatim.
- Alt+Enter queued messages and Up-arrow history recall display compact placeholders and expand correctly on resubmission.
- Temporary files are not deleted by this extension; Pi's existing
read-tool contract is preserved. - Existing static checks and test suite remain passing.
Non-goals (deferred)
- Converting pasted images to
ImageContentfor multimodal delivery. - Temporary file lifecycle management (cleanup on placeholder deletion, session end, etc.).
- Extending compact placeholders to non-TUI surfaces (web, RPC).
These are tracked as potential follow-ups, not as blockers for this issue.
Activity
fix(image-paste): provenance-bounded collapsing, dequeue/history reca…
feat(tui): add compact image paste placeholders (#418)