Skip to content

fix(studio): keep preview state synchronized - #3450

Merged
vanceingalls merged 13 commits into
mainfrom
wa-26g-studio-preview-sync
Aug 24, 2026
Merged

fix(studio): keep preview state synchronized#3450
vanceingalls merged 13 commits into
mainfrom
wa-26g-studio-preview-sync

Conversation

@vanceingalls

@vanceingalls vanceingalls commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

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

  • decompose timeline sync hydration and callback routing
  • preserve audio-group state for expanded sub-compositions
  • keep DOM edit sessions stable across HMR and provider remounts
  • route visibility, attribute, delete-member, and playback updates through one sync path
  • remove stale group-level message handling while retaining its compatibility module until PR 11

Verification

  • all relevant TypeScript projects pass cumulatively
  • fallow audit --base main --fail-on-issues

The final stack tip preserves the verified #3439 replacement and includes the review fixes landed across the stack.

Stack: #3449#3450#3451

miga-heygen
miga-heygen previously approved these changes Aug 23, 2026

@miga-heygen miga-heygen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 (useLivePlayheadTimeplayerStore directly) and group-levels message removal are clean.

No issues. Ship it.

— Miga

@vanceingalls
vanceingalls force-pushed the wa-26g-studio-preview-sync branch from 1c7fe30 to b354780 Compare August 23, 2026 22:54
@vanceingalls
vanceingalls force-pushed the wa-26f-studio-group-editing branch from 3b765b8 to 1641aad Compare August 23, 2026 22:54
@vanceingalls
vanceingalls force-pushed the wa-26g-studio-preview-sync branch from b354780 to dd0fdae Compare August 23, 2026 23:04
@vanceingalls
vanceingalls force-pushed the wa-26f-studio-group-editing branch 2 times, most recently from 49f05da to 3dd9a73 Compare August 23, 2026 23:24
@vanceingalls
vanceingalls force-pushed the wa-26g-studio-preview-sync branch from dd0fdae to 5347a43 Compare August 23, 2026 23:24
@vanceingalls
vanceingalls force-pushed the wa-26f-studio-group-editing branch from 3dd9a73 to f731659 Compare August 24, 2026 00:06
@vanceingalls
vanceingalls force-pushed the wa-26g-studio-preview-sync branch from 5347a43 to 06fa518 Compare August 24, 2026 00:06
@vanceingalls
vanceingalls changed the base branch from wa-26f-studio-group-editing to main August 24, 2026 00:58
@vanceingalls
vanceingalls dismissed miga-heygen’s stale review August 24, 2026 00:58

The base branch was changed.

@vanceingalls
vanceingalls merged commit 89069d2 into main Aug 24, 2026
113 of 127 checks passed
@vanceingalls
vanceingalls deleted the wa-26g-studio-preview-sync branch August 24, 2026 01:10
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.

2 participants