fix(website-gen): support video assets and YouTube/Vimeo embeds#99
Merged
Conversation
Videos attached to an AI-generated website were silently dropped before upload because every video extension had a 0-byte size cap, so they never reached the generator and never appeared on the published site. - add kWebsiteMaxVideoBytes (200MB) and whitelist browser-playable video extensions (.mp4/.webm/.mov/.m4v/.ogv) in websiteMaxFileSizeBytesForExt; non-playable containers (.mkv/.avi/.wmv/.flv) stay unsupported on purpose - raise the per-job total cap 50MB -> 220MB so one large (100MB+) clip fits. Video is uploaded unencrypted for hosting and referenced by URL only — its bytes are never sent to the AI backend - teach the system prompt to embed a video asset with an HTML5 <video> player (never an <img>), and to turn a referenced YouTube/Vimeo link into a responsive 16:9 iframe (an explicit, video-only exception to the "no external links" rule) - report the actual total cap in the skip message (native + web) instead of a hardcoded 50MB The uploaded video streams from the range-capable dweb.link gateway so the <video> element plays and seeks. Note: the unencrypted upload buffers the whole file in memory before the PUT, so very large videos remain a memory consideration on the web build (failures are surfaced, not silent). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Fixes the AI website generator silently dropping video assets, and adds YouTube/Vimeo embedding.
Root cause: every video extension had a 0-byte size cap in
websiteMaxFileSizeBytesForExt, so_uploadPhaseskipped videos as "unsupported type" before upload — they never got a CID, were filtered out of the asset payload, and never reached Claude. Separately, the system prompt gave no<video>guidance and forbade external embeds.Changes
lib/core/services/website_prompt_builder.dart,lib/core/services/website_service.dart,lib/web/services/web_website_service.dart:.mp4/.webm/.mov/.m4v/.ogv) with a newkWebsiteMaxVideoBytes(150MB); non-playable containers (.mkv/.avi/.wmv/.flv) stay unsupported by design so users don't publish a clip that won't play.<video controls>player (never<img>); embed a referenced YouTube/Vimeo link as a responsive 16:9 iframe — the single permitted external resource, with an explicit host allowlist,loading="lazy",referrerpolicy, and noautoplay.The uploaded video streams from the range-capable
dweb.linkgateway (Content-Type set from the extension on PUT), so<video>plays and seeks.Pairs with the pinning-service backend PR (
detectMedia/prompt).Review
Reviewed by GLM-5.2 (Cursor/Kimi/MiMo were unavailable this session — quota / account-gating). Applied its P1 fixes: cap headroom, de-contradicted the "no external links" wording, hardened the iframe.
dart analyzeclean.Recommended follow-ups (from the review; intentionally out of scope here)
<meta>CSP (frame-srcallowlist) into generated pages and a deterministic post-generation iframe-srcallowlist sanitizer (YouTube/Vimeo only). These harden a pre-existing gap (the generator already permits unsanitized inline JS), and a CSP risks breaking existing generated sites — so they warrant their own tested PR rather than riding along here.<source>type → silent playback failure).Verification
Import a ~110MB
.mp4into a generated website → it uploads (not skipped as unsupported/too-large), the generated HTML contains<video controls>with adweb.linksrc, and the clip plays and seeks on the published site. Paste a YouTube link in the prompt → a responsive iframe embed appears. Confirm a normal (non-generator) upload still plays (regression).🤖 Generated with Claude Code