Skip to content

Attach images to outgoing prompts - #271

Merged
dnouri merged 1 commit into
masterfrom
feature/prompt-image-attachments
Sep 1, 2026
Merged

Attach images to outgoing prompts#271
dnouri merged 1 commit into
masterfrom
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.

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 after rebasing onto master — 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.

@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
Base automatically changed from fix/prompt-ownership-settlement to master September 1, 2026 17:16
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 1d1e81d to 159ff75 Compare September 1, 2026 17:19
@dnouri
dnouri merged commit 0a7076c into master Sep 1, 2026
11 checks passed
@dnouri
dnouri deleted the feature/prompt-image-attachments branch September 1, 2026 18:42
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