Repository navigation
fix(web): warn before sending images a bot's model can't read - #145
Merged
Merged
Conversation
The server refuses an unreadable image before recording a turn, so the error shows once and names the bot. The composer warns as soon as such an image is attached and links to the bot's profile and the vision model setting. GET /v1/models returns images for each model. Closes #80
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a bot's model can't read images and no vision model is set, the server now refuses the message before it records a turn, and the web composer warns as soon as such an image is attached. The error shows once, names the bot, and links to the fix.
refuseUnreadableImagesinbots-submissions.tschecks the files withruntime.acceptsImages, the same check group chats use, and applies the same rule asresolveMessageFiles: only PNG, JPEG, GIF, and WebP up to 5 MB reach the model as images.assertImageSupportinruntime.tsstays as a backstop for other paths. Both useunreadableImages: "Atlas's model (flash) can't read images. Choose a model that accepts images in Atlas's profile, or set a vision model in Settings to describe images for it."GET /v1/modelsreturnsimagesfor each model (readsImages, so catalogs that list no input types count astrue).ImageWarning(apps/web/features/bot-chat/image-warning.tsx) appears above the bot chat composer through a newnoticeprop onComposer. It links to the bot's profile (/bots/$botId/edit) and the vision model setting (/settings/vision-model). It stays hidden while the model or vision settings are loading, and when either can handle the image.Uploadnow recordssize.Closes #80
Why
The owner saw the same error twice. Its button opened Provider settings, but the fix is the bot's model. The text said "agent's profile" and didn't name the bot, and the owner only found out after sending.
Evidence
bun run checkpasses on the branch: lint, format, typecheck,openapi:check, and 1316 tests, 0 failing. Theapps/docscheck passes.chat.test.ts› "a text-only model rejects image blocks…" now also checks that the snapshot has noerrorand no user message after the refusal. Without thebots-submissions.tschange it fails, becauseerrorholds the image message.image-warning.dom.test.tsx: the warning names the bot and links to/bots/b1/editand/settings/vision-model. It stays hidden when the model reads images, when a vision model is set, when no image is attached, and when the image is over 5 MB.Risk and rollback
Reversibility: Reversible.
Blast radius: Bot chat sends with image files (web, native clients, and the Discord gateway, which all go through
sendChat), theModelschema in the OpenAPI contract (adds a field), and the web bot chat composer.acceptsImagesmay refresh the provider's model catalog on a send with images. That's the same refreshsubmitalready did.