fix(studio): undoing an agent's build takes its sections off the timeline too - #4757
Open
miguel-heygen wants to merge 3 commits into
Open
miguel-heygen wants to merge 3 commits into
miguel-heygen wants to merge 3 commits into
Conversation
miguel-heygen
force-pushed
the
fix/studio-undo-drops-removed-sections
branch
from
September 30, 2026 08:41
1a74885 to
46eced4
Compare
miguel-heygen
marked this pull request as ready for review
September 30, 2026 09:18
…d trims are unchanged
This branch has not been deployed
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
Undoing an agent's build of sections now takes those sections off the timeline too. Before this change, the file went back but the timeline kept showing every section the build added, until the project was reopened.
Why
When a shorter clip list arrives,
mergeTimelineElementsPreservingDowngradeskeeps each old element that has acompositionSrc. The rule exists for sub-composition children that a bare DOM re-scan drops andenrichMissingCompositionsre-adds. A section the agent built is also a sub-composition host with acompositionSrc. So after an undo, the runtime reported the reverted film's clips (3), and the merge added the removed sections back (6).To reproduce on main: have an agent add sections hosted by
data-composition-src, then press Cmd+Z. The file and the picture go back, but the timeline keeps the sections. In the run below this happened in 5 of 7 runs. The other runs got a longer list first, which the merge trusts in full.How
mergeTimelineElementsPreservingDowngradestakes aninPreviewcheck. An old element is kept only while its node is still in the preview.syncTimelineElements, the one place every discovery path writes through, passesfindTimelineElementInIframe. That is the composition-aware lookup the other timeline edits use.enrichMissingCompositionsadds (buildMissingCompositionEntry) are nowkind: "composition", asparseTimelineFromDOMnames the same node. Without it the lookup searchedindex.htmlfor a host that belongs to its own composition and never found it, so each report would drop and re-add those rows. This also lets the lookup's other callers find these rows.iframeRefpoints at the new document before its clip list is committed. Before, the commit read the old document, which still held the undone sections.Test plan
What I measured
On a Linux box:
timelineDOM.test.ts: a section whose host left the preview is dropped;timelineIframeHelpers.test.ts: an enriched host is a composition the lookup finds in its preview;useTimelinePlayer.shadowReload.test.ts: after a shadow reload, a section the new document no longer has leaves the timeline, though the old document still holds it. It fails with main's merge rule, and with the old commit order.What I did NOT exercise
data-composition-src) compositions.Before
After Cmd+Z the run card reads Undone and the file holds only Title, Subtitle and Tag, but the timeline still shows Intro Hook, Benefit Fresh and Closing Cta.
After
After the same Cmd+Z the timeline shows Title, Subtitle and Tag, like the file.