Skip to content

Attach images to outgoing prompts - #271

Open
dnouri wants to merge 1 commit into
fix/prompt-ownership-settlementfrom
feature/prompt-image-attachments
Open

Attach images to outgoing prompts#271
dnouri wants to merge 1 commit into
fix/prompt-ownership-settlementfrom
feature/prompt-image-attachments

Conversation

@dnouri

@dnouri dnouri commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

Add a narrow, explicit path for outgoing image prompts:

  • Press C-c C-a in the input buffer and select—or paste—the path to one PNG, JPEG, GIF, or WebP image. C-u C-c C-a clears it.
  • Emacs identifies the format from the file bytes, materializes the image immediately, and keeps its basename and size visible in the input header.
  • A nonempty ordinary prompt sends the image through Pi's documented images RPC field when the selected model advertises image input.
  • Accepted user images reuse the bounded image renderer from feat: display inline images from tool results in chat buffer #221 in live chat and history, with useful type-and-size placeholders in terminals.
  • Prompt refusal, RPC failure, model-selection failure, process replacement, and reload preserve the draft or restore queued text rather than losing it or sending it under the wrong model.
  • Process-bound model-change tokens prevent stale callbacks from changing a replacement session.
  • Extension-handled prompts retract speculative image turns only after Pi authoritatively reports idle; delayed real turns remain owned until agent_start arrives.
  • The fake Pi contract persists image blocks, providing deterministic subprocess-level coverage.

Image-bearing drafts remain deliberately outside local follow-up and steering queues. Busy, slash-command, steering, unresolved-capability, and text-only-model attempts refuse without clearing the draft.

Stack

This PR is stacked on #273, which extracts the shared text-prompt settlement and session-reset ownership fixes found during review. This branch contains the image feature plus image/model-specific integration and hardening. Once #273 merges, this PR can be retargeted to master without changing its feature diff.

Intentional limits

  • One attached image per prompt.
  • Direct idle prompts with nonempty text only.
  • Images are sent as-is under a configurable 3 MiB source limit; there is no resize or conversion step.
  • Clipboard image extraction, automatic path detection in prompt prose, multiple images, and image-bearing queue/steering turns remain separate work.
  • Emacs file handlers such as TRAMP may supply readable paths, but remote attachment reads have not been broadly exercised.
  • Pi extensions can change the active model without an authoritative RPC model-change event; a later extension replacement may require a history reload to update the live preview.

Verification

  • make check on the combined stack — 1,680 tests, one compatibility skip, no unexpected results
  • make test-integration-fake — all 15 fake contracts passed
  • Real Emacs -Q terminal and Xvfb GUI image-send/render probes passed
  • Delayed agent_start, extension-handled prompt, model/process replacement, reload, and reset race probes passed
  • Python compile, Ruff lint/format, checkdoc, package-lint, byte compilation, and git diff --check passed

Closes #261.

Let users attach one materialized raster image to an ordinary idle prompt and send it through Pi's documented image-content RPC field. Keep attachment ownership explicit across validation, model changes, failures, rendering, history, and draft replacement.

Extend the fake subprocess contract and headless coverage so persisted user content is verified end to end.
@dnouri
dnouri force-pushed the feature/prompt-image-attachments branch from 47f29ef to 1d1e81d Compare August 31, 2026 23:45
@dnouri
dnouri changed the base branch from master to fix/prompt-ownership-settlement August 31, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: image support

1 participant