An external file drop fires two preview reloads back-to-back (the upload's
refresh + the insert's reload). The second refreshPlayer called
saveSeekPosition while the first reload's iframe was mid-teardown —
getAdapter() still returned that dying document's adapter, whose getTime()
reads 0 — overwriting the correctly saved pending seek with an explicit 0,
which initializeAdapter then honored. Result: drop a file from Finder and
the playhead jumps to 00:00 (reproduced live with a currentTime
write-trace; the store held the right time, the poisoned pendingSeek won).
saveSeekPosition now refuses to re-read position while a refresh is
already in flight and a save exists — the first save wins until it is
consumed. Verified live end-to-end: seek 11s → Finder-style file drop →
clip inserted, playhead stays at 11s (was: 0). Sidebar asset drops were
already correct (single reload) and stay so.
Pressing Escape mid-gesture (clip move, trim, or pending blocked-drag)
cancels it: no commit, no undo entry. Previews live only in the drag/
resize state — the store mutates only in the pointerup commit path — so
clearing the state restores the pre-drag timeline; the auto-scroll RAF is
stopped and the click from the eventual pointerup is suppressed once so it
can't reselect. Decision extracted as pure resolveTimelineDragEscape
(unit-tested: cancels for each gesture kind, click suppressed only past
the drag threshold, other keys ignored).
Arrow keys move the selected canvas element(s) by 1 composition px, Shift
by 10 — the top-ranked gap vs CapCut-class editors. The nudge reuses the
manual-offset drag machinery end to end: the same drag-member snapshot,
the same GSAP/CSS preview channel per keypress, and the same path-offset
commit a drag drop uses, so persistence and undo behave identically to a
tiny drag. A key-repeat burst commits once (400ms debounce after the last
arrow, flushed on selection change / pointerdown / unmount) = one undo
entry per burst.
Guards: no text-input/contentEditable focus, no pointer gesture in flight,
every target must support manual offset, plain/Shift arrows only. Caption
editing is safe by construction (CaptionOverlay and DomEditOverlay mount
mutually exclusively). While a nudgeable selection exists, ArrowLeft/Right
frame-stepping yields via a claim gate (both listen on window capture with
mount-order-dependent priority, so defaultPrevented can't arbitrate) —
deliberate behavior change: arrows nudge when an element is selected,
frame-step otherwise.
Three UI polish changes (CapCut as the visual reference):
- Timeline ruler is position:sticky (top of the vertical scroll container,
opaque gutter corner, z above track rows / below the playhead) so the
timestamps never scroll out of view. Scrub math verified: seek hit-testing
is x-only, and sticky keeps its layout slot so the RULER_H-based drop
y-math is unchanged.
- Timeline toolbar slimmed ~36% (44px -> 28px content box: py-2 -> py-0.5,
h-7 -> h-6 buttons, icons 18 -> 16).
- The four main regions (left sidebar, preview, right panel, timeline) read
as distinct panels: darker #050506 shell canvas, rounded borders per
panel, gaps via the existing 8px structural seams. Panel resize verified:
side resize is delta-based; timeline height uses inner padding so the
divider's absolute math is untouched. Preview drops its chrome in
fullscreen.
Product decision (user, 2026-07-09): every add — OS file drop, asset-panel
drop, block drop — lands at the current playhead time, not at the drop x;
only the track comes from the drop position. Reverts the drop-x landing
from c568f748c while keeping its zone- and overlap-aware track resolution,
so external and internal drops still behave identically.
New media dropped on the timeline now lands where you release it (drop-x
for start, drop-y for track) instead of at the playhead — the industry
drag semantic; playhead placement stays for the add-at-playhead
button/shortcut path. Drops past the content end are allowed into the
rendered empty space (the comp grows on commit), matching the clip-drag
bound.
The insert path then runs the new clip through resolveZoneDropPlacement —
the same pure, tested decision a clip DRAG uses (visual lanes top / audio
lanes bottom, no same-track time overlap: relocate to the nearest free
lane in the kind zone, else a fresh track). Because OS file drops, asset-
panel drops, and playhead adds all funnel through handleTimelineAssetDrop,
adding an asset now behaves exactly like moving one, from any source.
Two edge-of-timeline fixes:
1. Drag-to-extend: while a clip is dragged, the rendered timeline keeps a
160px margin past the ghost's end, so holding the pointer in the right
edge auto-scroll zone keeps stepping and the timeline extends at
auto-scroll pace — you can now place a clip farther than the timeline
currently shows. Growth is bounded per frame by AUTO_SCROLL_MAX_SPEED,
stops when the pointer leaves the edge zone, and the extra width
collapses when the drag ends (the comp only grows on commit).
2. Trim limit = available source media only, not the composition length.
Duration is content-driven, so capping a trim at the current comp end
both blocked extending the last clip rightward and collapsed a clip to
the sliver between its start and the comp end after a far move (the
8s → 0.95s audio incident). Images/text extend freely; audio/video stay
capped by remaining source.
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).
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.
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.
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.
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).
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.
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.
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.
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.
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).
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.
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).
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).
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.
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).
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.
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.
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).
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.
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.
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.
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.