Commit Graph
787 Commits
Author SHA1 Message Date
ukimsanov badfdb3675 fix(studio): keep the playhead in place across preview reloads
Dropping a file (or any edit) reloads the preview iframe, sometimes more
than once (refreshPreviewDocumentVersion staggers extra bumps at 80/300ms).
The saved playhead lived in a consume-once slot: initializeAdapter read
pendingSeekRef and nulled it, so any reload after the first found the slot
empty and seeked to 0 — the "dropped at the playhead, then the playhead
jumped to 0" bug — and a mid-load save could overwrite it with a stale
value ("moves randomly" on asset drops).

Extract resolveReloadSeekTime: pending seek → deep-link seek request →
the store's last known playhead. The last fallback makes the playhead
reload-invariant (an edit never moves it); fresh project loads still start
at 0 because the store resets currentTime on project switch, and content
shrinking past the playhead clamps it (the one sanctioned move).
2026-07-10 10:23:53 -07:00
ukimsanov 4a678349d0 test(studio): pin WeakRef in offCanvas indicator test (happy-dom GC bug)
happy-dom 20.9.0 stores each MutationObserver delivery callback only as a
WeakRef (MutationObserverListener.js:29) with no strong referent, so any
GC pass between observe() and a mutation silently kills the observer.
startOffCanvasIndicatorRefresh is dirty-flag driven off that observer, so
under full-suite memory pressure the off->on indicator removal flaked
(passed in isolation, failed ~2/3 full runs; reproduced deterministically
with a forced gc()).

Swap globalThis.WeakRef for a strong-holding StrongRef for this file only
— the real MutationObserver path stays fully exercised, just immune to GC.
Verified: 3 consecutive full-suite runs at exactly the 18 pre-existing env
failures with this file green.
2026-07-10 10:23:53 -07:00
ukimsanov c49f5e0beb fix(studio): update duration readout live on timeline edits
The player's total-time readout binds to store.duration, but edits only
patched store.elements — so after a move/resize/delete the number stayed
frozen at the old length until a manual page refresh (user-confirmed,
worst on shrink since nothing ever lowered it).

Optimistically push the content-driven length into the store at each edit
site: move/resize read the furthest clip end from the just-patched preview
DOM (raw data-duration, immune to runtime-truncated live values), delete
and the batched move path reuse the content end already computed for the
source patch. The subsequent preview reload then confirms the same value.

The persist test stubs the player store so the optimistic setDuration
can't leak state into other suite files.
2026-07-10 10:23:52 -07:00
ukimsanov 9f81a79875 fix(studio): derive content duration from raw source, not truncated store
The runtime clamps a clip's live duration to the composition length when it
builds the timeline/manifest, so the Studio's stored element durations are
truncated (an 8s clip whose start sits near the comp end reads as ~3.8s). The
content-driven duration sync measured the furthest clip end from those store
durations, so every move/resize/delete fed the truncated value back in and the
composition length could only ratchet DOWN — never grow to fit a clip longer
than the current length. Moving a clip past the end just re-truncated it.

Fix: measure the furthest clip end from the PATCHED SOURCE HTML (raw
data-duration) via furthestClipEndFromSource, for all four duration-sync sites
(single move, batched move, resize, delete). Since the source carries the
authored, untruncated durations, the composition grows to fit and the runtime
clamp becomes a no-op. Extracted furthestClipEndFromDocument from
readTimelineDurationFromDocument (excluding the root) and reused it.

Replaces the store-based resolveMovedContentEnd (removed). Tests updated:
furthestClipEndFromSource units + a persist-level test proving the saved source
grows to the raw 8s end (fails if the sync is removed). Runtime-side clamp
(clipTree/timeline) left for a separate framework-level decision.
2026-07-10 10:23:52 -07:00
ukimsanov 0df673e2c8 fix(studio): sync content duration on batched timeline moves
The batched persist path (persistTimelineElementsMove, used for lane-change
and insert moves) patched only data-start/data-track-index and never synced
the root data-duration. So after moving a clip past the old content end, the
player showed the right length (effectiveDuration = live max over clips) but
the saved FILE kept a stale data-duration — and a render off that file would
truncate at the stale value. This is the "moved audio to ~11.5s, it ends at
19.53s, but the file still says data-duration=15.18" case (HANDOFF-3 §6.1).

Mirror the single-clip move path: after patching, recompute the furthest clip
end for the file (resolveMovedContentEnd, using each edit's new start) and
setCompositionDurationToContent (grow OR shrink). Extracted the content-end
calc as a pure exported helper and covered it + the persist write with tests,
including a persist-level test asserting the saved source string (the G2
persist-source boundary the prior overlap bug hid behind).
2026-07-10 10:23:52 -07:00
ukimsanov 37e214d4fa fix(studio): auto-lay time-overlapping clips onto separate lanes (never show overlap)
The timeline showed clips overlapping when they shared a track and
overlapped in time (e.g. a file left in that state) — the previous
normalizeToZones grouped purely by track index, so same-track clips
stacked on one lane. Now it interval-packs each track's clips: sequential
clips share a lane, time-overlapping ones spill onto separate lanes
(standard NLE behavior). Visual lanes on top, audio below; idempotent.
So the timeline never displays a same-track overlap, regardless of the
file's state — not just after a drag.
2026-07-10 10:23:52 -07:00
ukimsanov 34ec0a3e84 fix(studio): persist normalized track indices on lane change (no more overlap)
Root cause of clips overlapping on one track: the editor placed clips in
NORMALIZED display-track space but persisted only the dragged clip's
index, so other clips' unchanged raw source indices collided on reload
(raw-vs-normalized). Fix (persist-on-edit): on a lane change / insert,
apply the move, re-normalizeToZones the whole set, and persist EVERY clip
atomically so the source matches the display. Inserts now use a fractional
track + normalize (replaces buildTrackInsert, now unused). Pure time-moves
still persist just the dragged clip.
2026-07-10 10:23:52 -07:00
ukimsanov 41b7c9053b fix(studio): allow dragging a clip past the current content end
The drag clamped a clip's start to (duration - clipDuration), so you
couldn't move it past the current content. Relax the clamp (both
resolveTimelineMove and the snap clamp) to the rendered timeline extent
(scrollWidth, kept >= viewport by the fill) — you can now drag into the
empty space past the content, and content-driven duration grows to fit
on commit.
2026-07-10 10:23:51 -07:00
ukimsanov 1f7c6a44d1 refactor(studio): extract resolveZoneDropPlacement — the whole drop decision, unit-tested
The drop-placement logic (no same-track overlap, zone clamp, relocate to
nearest free track, else create) was inline in the drag hook and untested.
Extract it into one pure function and cover every case with unit tests
(relocate up/down, all-occupied→create, sequential-share, zone-clamp both
ways, boundary insert + wrong-zone rejection, audio-track creation). The
hook now calls it, so the verified logic is the live logic. 39 collision
tests pass.
2026-07-10 10:23:51 -07:00
ukimsanov 39adf8efd8 feat(studio): no time-overlap per track — relocate to nearest free track, else create one
Per user intent: a clip can't be dropped ON TOP OF another on the same
track. Restore the collision-push (resolvePlacement) I'd removed, now
zone-aware:
- desired lane if free at the drop time → land there (sequential clips
  still share a track);
- else nearest free lane in the SAME kind-zone (prefer up);
- else auto-create a new track right below the aimed lane.
Deliberate boundary-insert still works (kind-gated). Cross-track overlap
stays allowed (that's layering).
2026-07-10 10:23:51 -07:00
ukimsanov 9455a719cc feat(studio): kind-zone-aware drag placement + insert
Verifying the drop cases surfaced a gap: the drag preview didn't respect
the visual/audio kind-zones, so a clip could appear to land in the wrong
zone mid-drag and snap back on re-zone, and audio-zone insert suppression
was too blunt (blocked creating new audio tracks).

- clampTrackToZone: a landing clip stays in its own zone (visual above the
  audio lanes, audio at/below) — no wrong-zone flash.
- isInsertAllowedForZone: new-track insert only in the clip's own zone, so
  audio clips CAN create audio tracks and visual inserts stay out of audio.
Both pure + unit-tested; wired into the drag preview.
2026-07-10 10:23:51 -07:00
ukimsanov d6d95656bc fix(studio): correctness sweep — live duration state, audio-row suppression, blocked-edit ref
From a fresh-eyes review of the DnD interaction paths:
- content-driven duration now reads live store elements (getState) instead
  of a closed-over snapshot, so fast sequential moves compute the right
  furthest-end (was a stale-closure hazard).
- audio-zone insert suppression compares in row-index space (position in
  trackOrder) instead of raw track values, which can shift.
- onBlockedEditAttempt routed through a ref (was a stale closure captured
  once at mount).
2026-07-10 10:23:51 -07:00
ukimsanov 553aa9f6ee feat(studio): content-driven duration on trim + move too
Extend the delete-shrink duration sync to the resize (trim) and move
fallback paths: after a trim/move, set data-duration to the furthest
clip end in the file (grows if extended past the end, shrinks if the
furthest clip is trimmed or moved left). Completes content-driven
duration for the live edit paths (SDK-cutover path is a follow-up).
2026-07-10 10:23:51 -07:00
ukimsanov ed6d92ce64 feat(studio): content-driven duration — shrink to content on delete
Composition length was grow-only (extendCompositionDurationIfNeeded
ratcheted data-duration up on drop/stretch but nothing shrank it), so
deleting the last/longest clip left trailing empty space. Add
setCompositionDurationToContent (grow OR shrink) and sync data-duration
to the furthest remaining clip end on delete. Empty timeline keeps its
declared length (no collapse to 0). Trim/move shrink are follow-ups.
2026-07-10 10:23:50 -07:00
ukimsanov 3e9672b0e0 feat(studio): kind-based zones, audio styling, visual-only track insert
Completes the free-form timeline model:
- normalizeToZones is now kind-based (visual lanes on top, audio at the
  bottom); deleted resolveMainOriginTrack + its main-track concept.
- Audio clips get a distinct violet tint (is-audio) vs teal-accented
  visual clips, so the audio zone reads as separate at a glance.
- New-track insertion line is suppressed at/below the first audio lane
  (inserting a visual track only makes sense in the visual zone).
2026-07-10 10:23:50 -07:00
ukimsanov a95ac9dda5 feat(studio): free-form placement — drop the main-track magnet
Field-testing showed the auto-magnetic main track fights how HyperFrames
projects are actually authored (scenes on separate lanes, sequenced by
time; 20+ real comps are ~80% temporal sequence + audio + z-index layers;
track index is sparse logical grouping the renderer ignores).

- Drag preview lands on the hovered lane at the snapped time; overlaps
  allowed. Removes collision-push (fixes 'cannot put two clips on one
  track') and the main-track no-overlap magnet.
- commitDraggedClipMove: drop the main-track ripple branch; plain moves
  are single SDK-aware persists. Track-insert still batches atomically.
- Delete now-dead reflowMainTrack + tests. Keep the atomic batched persist.
Design + prior plan docs included.
2026-07-10 10:23:50 -07:00
ukimsanov 827725ebb9 feat(studio): thread onMoveElements batched callback to the drag commit
Wires the atomic multi-clip handler end-to-end: useTimelineEditing →
EditorShell → useTimelineEditCallbacks → TimelineEditContext →
TimelinePane (per-edit expanded-clip rebase) → Timeline → resolver →
useTimelineClipDrag → commitDraggedClipMove. Enables the main-track
ripple + batched track-insert to actually fire.
2026-07-10 10:23:50 -07:00
ukimsanov 03eecb3b3c feat(studio): main-track ripple + batched insert in drag commit
Main-lane drops now reflow the whole lane end-to-end (gap-close +
insert-ripple) and persist atomically via onMoveElements; track inserts
batch the dragged clip + shifts into one call (retiring F2's N racing
persists). Plain overlay/audio moves keep the single SDK-aware path.
2026-07-10 10:23:50 -07:00
ukimsanov 004240572d feat(studio): handleTimelineElementsMove — atomic multi-clip persist
One read / patch-all / save-once / one batched GSAP shift / one reload /
single undo, grouped per source file. Fixes the per-clip persist race
(HANDOFF §7.1) where concurrent GSAP round-trips corrupted the file.
Single-clip moves keep the SDK-cutover-aware handler; this serves the
new multi-clip ripple/insert paths (extracted to a module to keep
useTimelineEditing under the filesize gate).
2026-07-10 10:23:50 -07:00
ukimsanov c0ed66c6f4 feat(studio): shiftGsapPositionsBatch client helper 2026-07-10 10:23:50 -07:00
ukimsanov 1a308c4229 feat(studio): reflowMainTrack — contiguous re-lay for main-track ripple 2026-07-10 10:23:49 -07:00
ukimsanov a04cbc7a3c fix(studio): drop crop-mode props from shell (align to main always-on crop)
Rebase reconciliation: main #2090 made crop always-on and removed
cropMode/onCropModeChange from DomEditOverlay. The R4 shell refactor
predated that and still threaded those props through EditorShell ->
PreviewOverlays. Drop the dead chain; crop is always-on now.
2026-07-10 10:23:49 -07:00
ukimsanov 1d86c23a64 fix(studio): keep clip selection outline + solid bg while dragging
The .is-dragging drop-shadow overrode the selected-clip white outline;
re-state both together. Add a solid background so audio clips (waveform
on a separate layer) aren't see-through while being dragged.
2026-07-10 10:23:49 -07:00
ukimsanov 02e5192b70 feat(studio): timeline fills viewport width when zoomed out
When content is shorter than the visible area, the ruler + empty track
lanes continue into the space instead of leaving dead black on the
right (CapCut-style). Only the rendered extent grows; clip positions
and durations are untouched.
2026-07-10 10:23:49 -07:00
ukimsanov f16940121f fix(studio): stable zone tie-break + valid top-insert track
resolveMainOriginTrack tie-broke on the mutated track index, so two
equal-duration videos on distinct tracks oscillated lanes on every
re-zone. Tie-break on the stable clip id instead (invariant across
normalizeToZones passes).

buildTrackInsert row 0 returned track -1 (negative index corrupts the
persisted source). Insert above the top by shifting every other clip
down one; the dragged clip takes the old top index.
2026-07-10 10:23:49 -07:00
ukimsanov 9f4d16f4f6 refactor(studio): extract drag-commit module; defer main-track ripple (per-clip persist races) 2026-07-10 10:23:48 -07:00
ukimsanov cb5afc5ee2 feat(studio): main-track no-overlap magnet (snap flush, no stacking) 2026-07-10 10:23:48 -07:00
ukimsanov c2ffc24821 fix(studio): stable main-track resolution (role/longest-video) — idempotent zoning 2026-07-10 10:23:48 -07:00
ukimsanov b7ac593df6 feat(studio): enforced CapCut track zones (overlay/main/audio normalization) 2026-07-10 10:23:48 -07:00
ukimsanov ed212ba8ee feat(studio): denser ruler minor ticks + frame-mode label sync 2026-07-10 10:23:48 -07:00
ukimsanov b811de1560 feat(studio): mid-lane track insert with insertion-line indicator 2026-07-10 10:23:48 -07:00
ukimsanov 705c7371aa feat(studio): collision-push drag to nearest free lane (prefer up) 2026-07-10 10:23:47 -07:00
ukimsanov b0d3a6cab4 feat(studio): clip-sized drop placeholder at the landing spot 2026-07-10 10:23:47 -07:00
ukimsanov 5077efe036 feat(studio): ghost follows cursor with target-lane highlight (CapCut feel) 2026-07-10 10:23:47 -07:00
ukimsanov bf62b33b88 feat(studio): magnetic vertical drag ghost (snaps to track lanes) 2026-07-10 10:23:47 -07:00
ukimsanov 2a5a350c23 feat(studio): full-width timeline layout; sidebars and preview above it 2026-07-10 10:23:46 -07:00
ukimsanov e5dd19a1d0 refactor(studio): extract PreviewOverlays and useTimelineEditCallbacks 2026-07-10 10:23:46 -07:00
ukimsanov 1b1a2ba009 refactor(studio): extract TimelinePane from NLELayout 2026-07-10 10:23:46 -07:00
ukimsanov bdc1583231 refactor(studio): extract PreviewPane from NLELayout 2026-07-10 10:23:46 -07:00
ukimsanov b9ed297164 refactor(studio): lift player and composition-stack state into NLEProvider 2026-07-10 10:23:46 -07:00
ukimsanov 2c0858934f feat(studio): timeline zoom slider (log-scaled) replacing +/- buttons 2026-07-10 10:23:45 -07:00
ukimsanov 471c773ed5 feat(studio): timeline always visible (remove hide/show toggle + shortcut) 2026-07-10 10:23:45 -07:00
ukimsanov 131d6d9921 fix(studio): stamp id + data-hf-id on inserted blocks (fixes duplicate timeline clips) 2026-07-10 10:23:45 -07:00
ukimsanov 9bb7e05139 feat(studio): regular cursor over timeline clips; taller default timeline (smaller preview) 2026-07-10 10:23:45 -07:00
ukimsanov d3378b6f91 feat(studio): drops place at the playhead, CapCut-style (remove drag ghost overlay) 2026-07-10 10:23:44 -07:00
ukimsanov 0c2d0c9bd5 fix(studio): drops stay on the target track (no overlap-bump to a new track) 2026-07-10 10:23:44 -07:00
ukimsanov 83f1d5da5a fix(studio): honor authored track index; drop lands on hovered track; smooth edge auto-scroll 2026-07-10 10:23:44 -07:00
ukimsanov 75240a5c86 fix(studio): extend root duration when a dropped clip overflows the composition 2026-07-10 10:23:44 -07:00
ukimsanov 42278797ed fix(studio): kind-aware drop targeting, assets uploads dir, block-install guard, rAF drag-over 2026-07-10 10:23:44 -07:00
ukimsanov b9faea06cd fix(studio): clear drop ghost on drag cancel; type=button on add-at-playhead item 2026-07-10 10:23:43 -07:00