Skip to content

fix(cli): preserve clip lengths when duplicating media - #6280

Merged
jrusso1020 merged 3 commits into
heygen-com:mainfrom
AksharP5:natural-ripple
Oct 26, 2026
Merged

jrusso1020 merged 3 commits into
heygen-com:mainfrom
AksharP5:natural-ripple

Conversation

@AksharP5

@AksharP5 AksharP5 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Duplicating a video that uses its source length could put the copy underneath the next shot. The CLI knew the resolved length, but inserted zero seconds of space. A following video without an explicit duration also escaped the ripple.

The copy now gets its full slot, and later clips on the same track move by that length. The review also identified clips bounded by data-end: the copy kept the original absolute end, so a one-second clip could become three seconds long. The copy and each rippled neighbour now shift their explicit ends by the same amount as their starts. One shared timing update keeps these operations consistent.

Scenario Before After
Natural source, explicit next clip Copy and next both at 2–3s Copy 2–3s; next 3–4s
Explicit source, natural next clip Copy and next both at 2–3s Copy 2–3s; next 3–4s
Both use natural duration Copy and next both at 2–3s Copy 2–3s; next 3–4s
Both have explicit durations Correct Same output
Three-second source bounded to 1–2s with data-end Copy 2–5s; next 3–4s Copy 2–3s; next 3–4s
Following clip bounded to 2–3s Initial PR: grows to 3–6s, overlapping the third clip at 4–5s Keeps its 3–4s slot; third clip stays 4–5s

The helper uses the timeline's existing resolved duration as a fallback. Authored duration still wins. No extra media probe or persisted duration attribute is added.

Closes #6278. The Studio clipboard work in #5684 does not change this CLI duplication helper.

Validation:

  • The new helper cases and CLI regression fail on de4c0cd7447e68a6a2137fec613adad9cfb2f498 and pass with the correction. The CLI regression uses a half-second authored clip from a one-second source.
  • All 151 CLI timeline tests and 148 relevant helper tests pass, including the four existing natural/explicit controls. Both touched packages build and typecheck.
  • The reviewer's exact three-second-source example was reproduced through the real CLI. Patched source and built CLI plan/apply/reopened rows match, and planning leaves source unchanged.
  • A second CLI regression preserves a half-second neighbour and the following third clip through plan, apply and reopened rows. The reviewer’s three-second-source neighbour fixture now gives 3–4s instead of 3–6s, without changing the other track.
  • CLI documentation, lint, formatting, comment checks, normal commit hooks and local SSH signature verification pass. Actual CLI and server archives pass the unchanged size, import and export gates.

This follow-up uses existing dependencies and builds. It adds no new browser or MP4-export evidence. Mintlify validation and broken-link checks require the unavailable mint executable. Independent GPT-6.1 Sol xhigh review cleared exact signed commit 5726850d0b3cb939ab00d092bb89248fb027b037. It independently passed all 299 focused tests, 15 boundary checks and 11 built-CLI scenarios, and verified source/bundle correspondence and both actual archives without changing the checkout.

@mintlify

mintlify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 5726850.

Approve preview

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean fix in the right place. The CLI already knows each clip's resolved length, and passing it into the one helper that every timeline duplicate goes through fixes both of your cases without a second probe. I checked that the helper's new argument defaults to the old behaviour, that a clip with an authored data-duration still wins, and that the new tests fail when the two production changes are reverted (the three natural-duration cases fail, the explicit one still passes).

One related case you may want to fold in, since it ends the same way. A clip timed with data-end instead of data-duration still overlaps. With a 3 s source, <video id="clip" data-start="1" data-end="2"> and a next clip at 2-3, timeline duplicate '#clip' now correctly moves the next clip to 3-4. But the copy is written as data-start="2" data-end="2", because the clone keeps the original's absolute data-end. Its end equals its start, so it falls back to the full source and plays 2-5, over the next clip. Shifting the clone's data-end by the same amount as its start (or writing data-duration on the copy) would close it. This also happens on main, so a follow-up is fine too.

Small optional point: every e2e row uses the 1 s fixture with 1 s authored durations, so the source length and the authored length give the same numbers. A longer fixture in one row would show which one won.

Verdict: APPROVE
Reasoning: Fixes the reported overlap at its root with tests that fail without it; CI is green and the remaining data-end case is older than this change.

@AksharP5 AksharP5 changed the title fix(cli): prevent overlaps when duplicating natural-duration media fix(cli): preserve clip lengths when duplicating media Oct 25, 2026
@AksharP5

Copy link
Copy Markdown
Contributor Author

Addressed the bounded-clip case in 5726850d0.

The copy's explicit end now moves with its start. Ripple uses the same operation for following clips with absolute ends, preserving their lengths too. Your three-second-source example now gives copy 2–3s and next 3–4s. A bounded neighbour also stays 3–4s instead of growing to 3–6s and overlapping a third clip.

The CLI regression distinguishes a half-second authored trim from its one-second source. All 151 CLI and 148 helper tests pass. Independent GPT-6.1 Sol xhigh review also passed 15 boundary checks, 11 built-CLI plan/apply/reopen scenarios and both package gates.

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for folding this in. Moving the clip's start and its data-end together in one helper, and using it both for the copy and for every clip the duplicate pushes later, is the right fix: a later clip timed with data-end used to shrink, and once its end fell before its start it fell back to its full source length. My earlier example now gives copy 2-3 and next 3-4, and the same holds for plain elements timed only with data-end.

The new tests cover both parts. With the previous version of duplicateElement.ts, the three new helper tests and the two new CLI cases fail, and the older rows still pass. The half-second row also settles which length wins. The tests pass three runs in a row, the CLI typecheck is clean and CI is green.

Verdict: APPROVE
Reasoning: Copies and later clips timed with data-end now keep their length, closing the remaining overlap, with tests that fail without the change; CI is green.

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 25, 2026
Merged via the queue into heygen-com:main with commit 6a20ec9 Oct 26, 2026
70 checks passed
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.

timeline duplicate overlaps the following clip when media uses its natural duration

3 participants