fix(studio): keep preview state synchronized - #3450
Conversation
miga-heygen
left a comment
There was a problem hiding this comment.
Review
Approve. Independent read at exact head.
Two structural improvements and several bug fixes:
HMR-stable contexts: createStableContext keys contexts on globalThis by name, so a Vite HMR re-evaluation reuses the original object. Collision detection warns loudly when two modules share a name. This fixes the "useX must be used within XProvider" crashes that fired on edits to files nowhere near the context — anything that propagated an HMR boundary was enough.
Timeline sync hydration extraction: useTimelineSyncCallbacks.ts was 642 lines; the pure functions (clipTreeParentMap, collectSubCompositionDomChildren, buildTimelineElementsFromClips, withImplicitDomLayers, seekAdapterToRestorePoint, hydrateTimelineFromPreview) now live in timelineSyncHydration.ts, each callable and testable on its own.
Bug fixes: sub-comp DOM children now carry audio-group state via readChildAudioGroupState; useEffectiveTimelineDuration delegates to the guarded shared function (fixes NaN propagation); sub-comp child track fractions confined to 0.5 * (k+1) / (n+1) (strictly under 0.5, avoiding the group anchor collision at exactly 0.5 for two-child hosts); handleGroupSelection refuses audio clips in layout groups.
Import cycle break (useLivePlayheadTime → playerStore directly) and group-levels message removal are clean.
No issues. Ship it.
— Miga
1c7fe30 to
b354780
Compare
3b765b8 to
1641aad
Compare
b354780 to
dd0fdae
Compare
49f05da to
3dd9a73
Compare
dd0fdae to
5347a43
Compare
3dd9a73 to
f731659
Compare
5347a43 to
06fa518
Compare
The base branch was changed.
Part 7 of 12 replacing #3439. Base:
wa-26f-studio-group-editing.Why
Preview hydration and DOM edit sessions must agree on project/session identity, expanded children, and message ordering before the timeline UI consumes them.
What
Verification
fallow audit --base main --fail-on-issuesThe final stack tip preserves the verified #3439 replacement and includes the review fixes landed across the stack.
Stack: #3449 ← #3450 → #3451