Repository navigation
Description
Out of scope
No remote conversion service, uploaded-code execution, new public rendering/plugin interface, original-file replacement, OCR or unrelated format expansion. Existing PNG/JPEG/WebP/GIF and document/track handling, ownership, cleanup and admission quotas stay intact. No automatic replay of an uncertain send or edits to earlier provider messages.
Context
Part of #3150. The maintainer selected #3155 I1 B (2026-11-11): SVG and BMP originals should produce bounded, supported image previews for the model. Original bytes still remain filesystem-backed and available through authorized references.
At inspected main 3c44ac6fc56d27675dadaf38a16254db53c39f69, detectKind (packages/ui-server/src/attachments/detect.ts:69) recognizes neither format as a frame-capable image. isFramedImage (packages/ui-react/src/lib/image-frames.ts:34) consequently skips them; ensureFrame (same file:92) and fileToAttachment (packages/ui-react/src/lib/image-attachments.ts:97) prepare other eligible images. Names/MIME hints must not become content evidence.
Scope
Add content-verified SVG/BMP detection and bounded local conversion to a model-supported raster frame, connected to the shared original/frame pipeline for picker, paste, drop and restored-original paths. Preserve original bytes and stable fileId, and charge the original/frame pair under the existing accounting rules. The conversion runs only in an execution context that cannot execute uploaded SVG scripts or resolve external/local resources.
Use the existing output envelope: four images per message, 4,000,000 frame bytes each, 8,000,000 frame bytes combined and maximum raster edge 1568 (MAX_IMAGES_PER_MESSAGE, MAX_IMAGE_BYTES, MAX_TOTAL_IMAGE_BYTES, DOWNSCALE_MAX_EDGE, packages/ui-sdk/src/protocol.ts:818). Before allocating/decoding, impose explicit bounded input, dimensions/pixels, conversion memory/time and concurrency limits, justified against existing upload/resource limits. Reuse qualified concrete facilities; verify any dependency/API/license and apply the release procedure before adding a package. No new resource entitlement is selected by this feature.
Acceptance criteria
- A valid SVG and BMP selected through generic Files retain byte-identical originals and generate a supported raster frame with the matching original fileId. Real offline browser/runtime proof shows the model-facing message includes that frame and reference exactly once.
- Misleading extensions/MIME and malformed content cannot claim a successfully converted image. SVG scripts/event handlers, external URL/file references, entities and resource-expansion cases execute nothing and make zero network/file-resource reads. Prove the actual decoder/rendering boundary, rather than a filename predicate.
- Oversize dimensions/pixel counts, oversized input/output, deep/pathological SVG and conversion cancellation/deadline cases stop within the recorded limits, release decoder/object URLs and keep unrelated attachments usable. Existing aggregate admission/image-frame caps are enforced on both relevant sides.
- Deterministically unconvertible images keep their original and an explicit preview limitation under the approved sendable-content policy. No missing preview is represented as successful visual/model access; real storage/admission failure retains its blocking behavior.
- Original/frame identity, stable order, draft/snapshot ownership, restart/restoration and cleanup protections remain intact. No conversion rewrites persisted original bytes or a provider prefix.
- Named failing-first and restored mutation receipts cover successful inclusion, dangerous SVG refusal/no resource access and output/resource guards. Existing image and generic attachment paths stay green.
Verification
Extend offline attachment-detect.test.ts, attachment-routes.test.ts, the actual image/frame tests and real browser composer-image-originals.offline.tsx coverage. Exercise source bytes and the actual conversion/runtime, with repository network guards and no provider calls. Record quantitative bounds and expected-assertion mutations in the PR; run required affected checks and provider-history proof.
Contract impact
Preserve existing attachment reference and image-frame shapes. Update documented supported-format/reader behavior and the relevant integration-contract component if its semantics change; use a CONTRACT commit for a machine-contract change. No new schema field or service is preselected by this brief.
Activity