Skip to content

Support attaching multiple images to a single chat message - #742

Open
mattlindsey wants to merge 1 commit into
mainfrom
multiple-images
Open

Support attaching multiple images to a single chat message#742
mattlindsey wants to merge 1 commit into
mainfrom
multiple-images

Conversation

@mattlindsey

Copy link
Copy Markdown
Collaborator

The message/document data layer already supported multiple documents per message (has_many :documents, all three AIBackend providers already looped over them), but the composer UI, upload controller, and message display only ever handled one.

  • Message::DocumentImage: replace .first/.last helpers with aggregate has_document_image?/has_document_pdf?/has_documents? checks; the view now reads per-document data straight off Document.
  • Composer: file picker accepts multiple files, preview box becomes a cloneable template instead of one static slot.
  • image_upload_controller.js: track an ordered list of attached files. Uses a separate, unnamed purely to trigger the OS file dialog, keeping the real Rails-nested-attributes inputs single-file always — a multiple file input left empty submits a blank value instead of being omitted, which would 422 every send.
  • Message display: loop over documents, giving each image its own modal controller/dialog instead of sharing one per message.
  • Add Gemini multi-image payload test to match existing OpenAI/ Anthropic coverage.

Closes #78

The message/document data layer already supported multiple documents
per message (has_many :documents, all three AIBackend providers
already looped over them), but the composer UI, upload controller,
and message display only ever handled one.

- Message::DocumentImage: replace .first/.last helpers with aggregate
  has_document_image?/has_document_pdf?/has_documents? checks; the
  view now reads per-document data straight off Document.
- Composer: file picker accepts multiple files, preview box becomes a
  cloneable template instead of one static slot.
- image_upload_controller.js: track an ordered list of attached
  files. Uses a separate, unnamed <input multiple> purely to trigger
  the OS file dialog, keeping the real Rails-nested-attributes inputs
  single-file always — a multiple file input left empty submits a
  blank value instead of being omitted, which would 422 every send.
- Message display: loop over documents, giving each image its own
  modal controller/dialog instead of sharing one per message.
- Add Gemini multi-image payload test to match existing OpenAI/
  Anthropic coverage.

Closes #78

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mattlindsey

Copy link
Copy Markdown
Collaborator Author

This was done entirely by Claude Code and works for OpenAI but it seems like Anthropic vision might not be working (even before this PR), so probably that should be investigated first. Also I couldn't manually verify Gemini (api key permission problems).

And I probably shouldn't be adding a new major ai feature before we do #740.

@mattlindsey

mattlindsey commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Actually this PR works for OpenAI and Anthropic (user error with key). So, for example, you can add 2 images in 1 message and ask it to compare them.

Still need to figure out key problem with Gemini. The new key process is complicated.

P.S. This works now for OpenAI, Anthropic, and Gemini. So I'm taking off of Draft.

@mattlindsey
mattlindsey marked this pull request as ready for review July 27, 2026 13:30
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.

Add support for multiple images attached to a single chat

1 participant