Commit Graph
2533 Commits
Author SHA1 Message Date
ukimsanov 4b863593db feat(studio): Escape cancels an in-progress timeline drag
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).
2026-07-10 10:23:54 -07:00
ukimsanov 14e6869c1b feat(studio): arrow-key nudge for canvas elements
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.
2026-07-10 10:23:54 -07:00
ukimsanov da5274b2ee feat(studio): sticky ruler, slimmer toolbar, distinct panel sections
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.
2026-07-10 10:23:53 -07:00
ukimsanov 66366b0d31 fix(studio): land all timeline drops at the playhead
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.
2026-07-10 10:23:53 -07:00
ukimsanov 029bfcd686 feat(studio): drops land at drop position, zone- and overlap-aware
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.
2026-07-10 10:23:53 -07:00
ukimsanov 76d8d7a244 feat(studio): drag-to-extend timeline + trim limited by source, not comp end
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.
2026-07-10 10:23:53 -07:00
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 a4df5817c9 docs(research): interaction UX spec — industry standards, inventory, gap plan 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 8b1c8ebb0a docs(research): HANDOFF-3 — free-form timeline DnD rework, full session record 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 1b07ab1d0c feat(studio-server): shift-positions-batch GSAP op (one write, N shifts) 2026-07-10 10:23:49 -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 caf5fa3868 docs(research): audit handoff + batched-persist/ripple design 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 1e551fa6e8 docs(research): full session handoff (R4 + R2 + R1 + Piece 4 partial; ripple blocked) 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 7c3af3dbd0 docs(research): standardized track model + main-track magnet design (analysis) 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 0f295a3780 docs(research): collision-push + track-insert design (R2 piece 2) 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 e9f3481197 docs(research): record magnetic-ghost revision (follow + highlight) 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 5b82ab5451 docs(research): magnetic vertical ghost design (R2 piece 1) 2026-07-10 10:23:46 -07:00