Skip to content

feat(tui): compact image paste placeholders (display-only, relates to #413) #527

Closed

Description

@onychen

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 main branch the only input handler that produces ImageContent is extensions/ai-providers/cursor/input-images.ts, gated on ctx.model?.provider === "cursor". For every other provider, the model receives the raw file path and reads the image through the read tool on demand. Making all providers receive ImageContent unconditionally changes what the model sees relative to an unmodified Pi install.
  • Temporary file cleanup. Pi leaves clipboard images in the temp directory so the read tool can open them in any later turn. The Cursor input-images implementation also does not delete files after conversion. Deleting on submission would break read access 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 read tool 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 ImageContent for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions