Skip to content

feat(ai-chat): Attachment support#615

Merged
amnweb merged 2 commits intoamnweb:mainfrom
Rejdukien:feature/ai_chat_attachments
Jan 3, 2026
Merged

feat(ai-chat): Attachment support#615
amnweb merged 2 commits intoamnweb:mainfrom
Rejdukien:feature/ai_chat_attachments

Conversation

@Rejdukien
Copy link
Contributor

This PR adds support for attachments to the ai-chat widget.
Attachments can either be added via file-picker dialog or via clipboard pasting in the input field.
Supports text files (appended to the api payload as type: text) or images (included as type: image_url, base64 encoded). Binary files (that can't be utf-8 decoded) get rejected as unsupported file type.

There's two parameters to limit the max size per attachment: Text files get truncated, image files get compressed if they exceed that limit.

Supposedly OpenAIs chat completion endpoint should also allow pdf files, but in my testing I've noticed that the provider/model I use doesn't support it, so I've decided to not include untested changes.

This PR also includes a minor change to the popup / event-handling logic to properly support the file picker dialog (without the chat popup closing on me...)

image

Image shows one text file and two images attached to the first message sent to the model; two more files are staged for the next message. Staged attachments can be removed at this point via the deletion button next to each one.

Let me know if there's anything you don't like and want changed.
Happy new year!

@Rejdukien Rejdukien force-pushed the feature/ai_chat_attachments branch from 4bcd90a to 93c5ffc Compare December 30, 2025 21:04
@amnweb
Copy link
Owner

amnweb commented Dec 31, 2025

Is it possible to paste an image from the clipboard? :)

@Rejdukien
Copy link
Contributor Author

Rejdukien commented Jan 1, 2026

Is it possible to paste an image from the clipboard? :)

Yup!
image

See method _handle_paste_mime for the implementation of that.

@Rejdukien Rejdukien force-pushed the feature/ai_chat_attachments branch from 93c5ffc to a6ed89e Compare January 3, 2026 22:03
@amnweb amnweb merged commit fc31cb5 into amnweb:main Jan 3, 2026
3 checks passed
Kepners pushed a commit to Kepners/yasb that referenced this pull request Feb 4, 2026
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.

2 participants