Skip to content

fix(website-gen): support video assets and YouTube/Vimeo embeds#99

Merged
ehsan6sha merged 1 commit into
mainfrom
fix/website-gen-video-embed
Jul 8, 2026
Merged

fix(website-gen): support video assets and YouTube/Vimeo embeds#99
ehsan6sha merged 1 commit into
mainfrom
fix/website-gen-video-embed

Conversation

@ehsan6sha

Copy link
Copy Markdown
Member

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 _uploadPhase skipped 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:

  • Whitelist browser-playable video (.mp4/.webm/.mov/.m4v/.ogv) with a new kWebsiteMaxVideoBytes (150MB); non-playable containers (.mkv/.avi/.wmv/.flv) stay unsupported by design so users don't publish a clip that won't play.
  • Raise the per-job total cap 50MB → 200MB (fits one ~110MB+ video plus ~50MB of other assets). Video is uploaded unencrypted for hosting and referenced by URL only — its bytes are never sent to the AI backend.
  • System-prompt guidance: embed a video asset with an HTML5 <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 no autoplay.
  • Skip messages now report the actual cap (native + web) instead of a hardcoded "50MB".

The uploaded video streams from the range-capable dweb.link gateway (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 analyze clean.

Recommended follow-ups (from the review; intentionally out of scope here)

  • Generator security hardening (rated P0 in the review): inject a <meta> CSP (frame-src allowlist) into generated pages and a deterministic post-generation iframe-src allowlist 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.
  • Web large-file OOM: the unencrypted upload buffers the whole file in memory before the PUT; a chunked/streaming upload is the real fix for large video on the web build. (Native is fine.)
  • Magic-byte sniff to defend against extension spoofing (renamed non-video → wrong <source> type → silent playback failure).

Verification

Import a ~110MB .mp4 into a generated website → it uploads (not skipped as unsupported/too-large), the generated HTML contains <video controls> with a dweb.link src, 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

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>
@ehsan6sha
ehsan6sha merged commit 9082a17 into main Jul 8, 2026
1 check passed
@ehsan6sha
ehsan6sha deleted the fix/website-gen-video-embed branch July 8, 2026 04:44
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.

1 participant