refactor(studio): single-source the timeline stacking key + guard audio reorder

The element stacking key (element.key ?? id) was recomputed in four places
(reorder-intent generation, row ordering, the commit-time sibling lookup via a
threaded keyOf param, and resolveTimelineMove). Any drift would silently break
the sibling lookup and no-op the reorder. Route all of them through the existing
getTimelineElementIdentity owner, share one toStackingOrderItem mapper between
row ordering and reorder intent, and drop the keyOf parameter.

Also enforce the audio side-effect invariant in the single mutation owner
(applyTimelineStackingReorder): dragging an audio clip has no visual layer to
restack, so it never writes z-index. Covered by a new hook test.
This commit is contained in:
Miguel Angel Simon Sierra
2026-07-08 23:46:24 -04:00
parent dd980697a2
commit 5ce362299c
6 changed files with 60 additions and 41 deletions
@@ -245,7 +245,7 @@ export function buildTimelineElementIdentity(params: {
return { id, key };
}
export function getTimelineElementIdentity(element: TimelineElement): string {
export function getTimelineElementIdentity(element: { key?: string | null; id: string }): string {
return element.key ?? element.id;
}