Repository navigation
fix(studio-server): an edit aimed at a clip never lands on an audio group sharing its id - #5645
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 199 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jerrai-bot-heygen
left a comment
There was a problem hiding this comment.
At this head, exact hfId resolution remains first; id and selector fallback now reject an element carrying a different ID pinned in the authored source, while parser-minted IDs retain the legitimate fallback. The new remove/patch regression distinguishes the prior audio-group deletion, and the edit-accuracy and lint checks passed. The separate timeline viewport gate is red on a paused A-roll chroma sample; its fixture loads/plays a film without a source edit and does not establish a defect in this two-file resolver change. That CI/visual gate still needs its own landing decision. — Jerrai
What changed
An edit aimed at one element can no longer land on a different element that happens to share its
id.A person put an audio group in the film's root,
<hf-audio-group id="voice" data-fx-chain="...">, and gave the voiceover clips in a sub-compositiondata-audio-group="voice". After a later edit in Studio, the group was gone fromindex.htmlwith no error, so the voice chain stopped applying.findTargetElement(packages/studio-server/src/helpers/sourceMutation.ts) looks the target up bydata-hf-idfirst. When that finds nothing, it falls back togetElementById(target.id), then to the selector.<audio id="voice" ...>) and the request is resolved in a file where itsdata-hf-idisn't found: the clip lives in another file, or the copy it was served from is stale.data-startonto it.findTargetElement(patch, remove, split, wrap, unwrap, duplicate, freeze frame) shared this.findTargetElement. Adata-hf-idthat was already in the file is that element's identity. So when a request names adata-hf-id, a fallback hit pinned in the file to a different one is a different element, and it no longer counts as a match. The routes already answer "not matched" safely.data-hf-idwas only minted by this parse (not yet written to the file) still matches. That is the case the fallback exists for: a save carrying an id served before an outside edit changed what is minted. Its test ("hfId lookup falls through to selector...") passes unchanged.parseSourceDocumentrecords whichdata-hf-ids the raw source carried, keyed by the document it returns.findTargetElementreads that, so no call site changes.What I measured
sourceMutation.test.ts: a root<hf-audio-group id="voice" data-hf-id="hf-oova">, then remove and patch with{ id: "voice", hfId: "hf-6egx" }. The file comes back unchanged and the patch reportsmatched: false.src/helpersvitest passes 3 runs of 3 (511 tests). Full@hyperframes/studio-servervitest passes (1328, 2 skipped).tsc --noEmitpasses. oxfmt and oxlint are clean on the changed files.removeElementFromHtml/patchElementInHtmlon a two-file project (clip incompositions/vo.html) and on an inline-template one:index.html,{id, hfId}index.htmlhfIdhfIdWhat I did NOT exercise
id(nohfId), into a file where that id appears twice. It carries no identity to check, so it still resolves to the first element, as before. Studio's timeline always sends both.