Files
hyperframes/packages/studio-server
Miguel Ángel 5f024e34e2 fix(studio): thumbnails of compositions with no code of their own load in under a second (#8316)
* fix(studio): thumbnails of compositions with no code of their own load in under a second

Both thumbnail paths (the CLI's preview server and Studio's dev server) waited up to 5 s for
a GSAP timeline before shooting a card. A composition with no script never registers one, so
each of its cards took the full 5 s, and the route shoots one card at a time, so the third
card came at about 16 s.

The wait cannot simply go: a composition may register its timeline late, in a timer or a
load handler, after the runtime is ready, and shooting it then shows the wrong moment.

So the preview route now marks the page a thumbnail loads when nothing on it can register a
timeline: no script but Studio's own (the runtime, GSAP core, an import map, the registry
line), no inline event handler, frame, template or child composition loaded at run time, and
no Studio motion. A marked page is shot once the runtime is ready. Every other page is held
for its timeline exactly as before.

The rule lives once, in studio-server, and both thumbnail paths wait on it.

fails without the fix: "is skipped for a composition with no code of its own" and "holds for
a composition whose script registers its timeline late"
(packages/studio-server/src/routes/preview.thumbnailMark.test.ts), "thumbnailSeekReadyInBrowser"
(packages/studio-server/src/helpers/screenshotClip.test.ts), "hasAuthoredCode"
(packages/studio-server/src/helpers/authoredCode.test.ts), and "holds a thumbnail's shot on
the thumbnail readiness rule" (packages/cli/src/server/studioServer.test.ts and
packages/studio/vite.browser.test.ts).

* test(studio-server): the thumbnail mark test builds its page from elements, not parsed text

The test read the served page back through DOMParser and innerHTML to hand its metas to the
readiness rule, which code scanning reports as DOM text reinterpreted as HTML. It now finds
the served page's meta tags with the compiler's own tag scanner and creates each one as an
element, so no text is parsed as markup.

Also adds a row to the code check's table: a script inside an inline SVG counts as code.

fails without the fix: "is skipped for a composition with no code of its own"
(packages/studio-server/src/routes/preview.thumbnailMark.test.ts) still fails when the route
writes no mark.
2026-11-20 21:19:26 +00:00
..
2026-11-19 22:02:17 -05:00