Repository navigation
fix(studio): a first animation in a sub-composition file runs from inside its template - #4806
Merged
Merged
Conversation
Edit accuracy: 841 passing here, 841 on the base branchThe gate passes. Quarantined, measured but not gated (7)
|
miguel-heygen
force-pushed
the
fix/studio-first-animation-in-template
branch
9 times, most recently
from
October 1, 2026 18:25
ead4de8 to
bf2692e
Compare
miguel-heygen
marked this pull request as ready for review
October 1, 2026 19:09
…side its template
miguel-heygen
force-pushed
the
fix/studio-first-animation-in-template
branch
from
October 1, 2026 19:16
bf2692e to
cd7ac03
Compare
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.
What changes
The first GSAP edit on a GSAP-free sub-composition file now puts the GSAP script and timeline inside the file's
<template>, where the composition loader runs them. Before, a file with no<body>(every sub-composition file is only its<template>) got the script appended after</template>. The loader never runs it, so that first edit was saved but never showed, in the preview or in a render.Moves and nudges of GSAP-free elements stop writing GSAP at all in #4799. This covers the remaining ways in, such as the first animation added to a GSAP-free sub-composition.
How
prepareGsapMutationScript(studio-serverroutes/files.ts) still inserts before</body>when the file has one. Otherwise it inserts before the file's own outer</template>, through core'sinsertBeforeCloseTag(which now also takes"template"). Core walks the markup, skipping comments and script text, and counts template depth, so a template nested inside the sub-composition's template keeps its own close tag. Only when a file has neither does it fall back to appending at the end. A file with a<body>keeps the</body>placement even when its content sits in a<template>(<body><template>…</template></body>): a root composition can hold a<template>(slot or clone markup) whose scripts never run, so moving the script into it would break the root case. Studio writes sub-compositions as template-only files, and every registry file with the body-wrapped shape already has GSAP, so this first-animation path does not reach them. It is a string insertion, so no<head>or<body>is added to the file.Test
htmlDocument.test.ts: "puts markup before the outer , past a nested one and a commented one". It fails with first-match lookup.files.test.ts: "a first animation in a sub-composition file lands inside its template". Without the fix it fails, because the script sits after</template>. "a first animation in a file lands before , outside its template" pins the body-wrapped choice above.Before
Main: a fixture project whose root includes a template-only sub-composition holding
#card. Its first animation (x0 to 800 over 2 s) is added through the same GSAP mutation route the test uses, and Studio is seeked to 2.0 s. The script was saved after</template>, so the card has not moved.After
This PR, same fixture, same mutation, same seek. The script was saved inside the template, so the card is 800 px to the right at 2.0 s.
Merged below the usual size floor: this PR was opened and reviewed before PRs started being batched per lane, and PRs already in review finish as they are.