Execute the approved plan in the repository. Project directory:…
- User
Execute the approved plan in the repository.
codeProject directory: /Users/user_c042661f/Documents/announcement-video Idea:Add basic visual editing features to the Remotion Studio timeline. The project already has a working Remotion composition that reads timeline.json and renders video/audio/overlay tracks. Now we need to add interactive editing directly in the browser UI. Five features: (1) DRAG clips to reposition them on the timeline (change clip.at), (2) SPEED control - zoom/speed up/slow down clips (change clip.speed), (3) CROP/TRIM the ends of clips (change clip.from and clip.to), (4) SPLIT clips at the playhead into two separate clips, (5) MUTE clips (toggle clip.volume to 0 or back). All edits must write back to timeline.json so they persist and are picked up by Python tools. The existing viewer/ has a working drag-drop timeline using @xzdarcy/react-timeline-editor that can inform the approach. The current Remotion project is at remotion/ with compositions in remotion/src/timeline/. KEY CONSTRAINTS: (1) Edits write to timeline.json - the shared config that Python tools also read/write. (2) The UI runs inside or alongside Remotion Studio (npx remotion studio). (3) Keep it simple - these are basic NLE controls, not a full editor rebuild. (4) Project is open source.
codeExecution tracking source of truth (`finalize.json`): {"tasks": [ { "id": "T1", "description": "Create sidecar API server (remotion/server.mjs). Minimal node:http server on port 3111 with two endpoints: GET /api/timeline reads ../timeline.json, POST /api/timeline validates body has 'output' and 'clips' keys then writes to both ../timeline.json and public/timeline.json. Add CORS headers for localhost:3000. Add 'server' script to package.json. Update 'dev' script to: npm run setup-public && node server.mjs & npx remotion studio.", "depends_on": [], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T2", "description": "Create save-config.ts (remotion/src/save-config.ts). Export serializeForDisk(resolved: ResolvedTimelineConfig): TimelineConfig that strips assetEntry from each clip and removes top-level registry \u2014 only keep these TimelineClip fields: id, at, track, asset, from, to, speed, hold, volume, x, y, width, height, opacity, effects. Export saveTimeline(config) that calls serializeForDisk then POSTs to http://localhost:3111/api/timeline. Add a 300ms debounced wrapper for rapid edits. Validate round-trip: serialize current config, confirm output matches timeline.json shape exactly (no assetEntry, no registry, no src).", "depends_on": [ "T1" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T3", "description": "Create EditorOverlay component (remotion/src/timeline/EditorOverlay.tsx). Gate on getRemotionEnvironment().isStudio \u2014 return null if not in Studio. Receives config (ResolvedTimelineConfig) and onConfigChange callback. Render via React portal to document.body a floating toolbar at bottom of viewport showing track lanes with clip bars (positioned by clip.at and duration). Use useCurrentFrame() + fps to show playhead. Maintain selectedClipId state. Update Timeline.tsx to render as topmost layer, passing config and a handleConfigChange that updates local state and calls debounced saveTimeline().", "depends_on": [ "T2" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T4", "description": "Create ClipPanel component (remotion/src/timeline/ClipPanel.tsx). Floating side panel for selected clip properties. Show id, asset, track, at for all clips. For from/to clips: show from, to, speed. For hold clips: show hold. Show volume for all. Numeric inputs for direct editing of any displayed field. Wire clip selection: clicking a clip bar in EditorOverlay sets selectedClipId, which shows ClipPanel. Changes commit through onConfigChange.", "depends_on": [ "T3" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T5", "description": "Implement DRAG to reposition clips (in EditorOverlay.tsx). Horizontal drag on clip bars: onPointerDown captures initial clip.at and pointer X, onPointerMove computes delta in seconds from pixel delta using timeline scale (pixels per second), onPointerUp commits new clip.at and triggers save. Snap to 0.1s increments (Shift for frame-level 1/fps precision). Clamp at >= 0. Drag is horizontal only within same track.", "depends_on": [ "T3" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T6", "description": "Implement CROP/TRIM (in EditorOverlay.tsx). For from/to clips: left handle adjusts clip.from (source start) \u2014 CRITICAL: multiply timeline delta by clip.speed when updating from, i.e. from += timelineDelta * (speed ?? 1). Also adjust clip.at by the timeline delta. Right handle adjusts clip.to. Clamp from >= 0, to <= assetEntry.duration, from < to. For hold clips: right handle adjusts clip.hold (min 0.1s), left handle adjusts clip.at and clip.hold together (moving start while keeping end fixed). Reference: viewer/src/App.tsx:218 for speed-adjusted trim math.", "depends_on": [ "T4" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T7", "description": "Implement SPEED control (in ClipPanel.tsx). Add speed slider/input: range 0.25\u20134.0, step 0.25, default 1. Disable for hold clips (speed is meaningless for static images). On change: update clip.speed, save. Clip bar width in overlay must reflect speed-adjusted duration: (to - from) / speed, using getClipTimelineDuration from load-config.ts:156.", "depends_on": [ "T4" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T8", "description": "Implement SPLIT at playhead (in EditorOverlay.tsx + ClipPanel.tsx). Add Split button in ClipPanel, enabled when playhead is within selected clip's time range. For from/to clips: splitSource = clip.from + (playheadSeconds - clip.at) * (speed ?? 1). Clip A keeps original id, same at, same from, to = splitSource. Clip B gets collision-safe id (use or find max numeric suffix \u2014 do NOT use naive '-b'), at = playheadSeconds, from = splitSource, to = originalTo. Both inherit speed, volume, track, asset, position props. For hold clips: elapsed = playheadSeconds - clip.at. Clip A hold = elapsed. Clip B at = playheadSeconds, hold = originalHold - elapsed. Replace original clip with both in config.clips, save.", "depends_on": [ "T4" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T9", "description": "Implement MUTE toggle (in ClipPanel.tsx). Add mute toggle button. On click: set clip.volume = 0 if currently > 0, or clip.volume = 1 if currently 0 or undefined. Visual indicator: muted clips show muted icon/strikethrough on their bar in EditorOverlay.", "depends_on": [ "T4" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T10", "description": "Add keyboard shortcuts (in EditorOverlay.tsx). Only active when overlay is focused and a clip is selected. M = mute/unmute, S = split at playhead, Escape = deselect. No Delete/Backspace \u2014 deletion is not in scope. Verify no conflicts with Remotion's built-in shortcuts (Space for play/pause, arrows for frame nav).", "depends_on": [ "T5", "T6", "T7", "T8", "T9" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" }, { "id": "T11", "description": "Dev workflow polish. Add comment in setup-public.sh noting sidecar handles write-back. Validate end-to-end: npm run dev starts both Studio and sidecar, edits persist across restarts, python3 tools/view.py reflects browser edits, python3 tools/render.py --dry-run succeeds after edits.", "depends_on": [ "T10" ], "status": "pending", "executor_notes": "", "reviewer_verdict": "" } ], "watch_items": [ "TRIM-SPEED-MATH (flag: trim-speed-math): Left-trim on speed-adjusted clips MUST multiply timeline delta by clip.speed when updating clip.from. The plan says 'same delta' but this is wrong \u2014 reference viewer/src/App.tsx:218 which does . Without this, trimming sped-up/slowed-down clips writes the wrong source range.", "SPLIT-ID-COLLISION (flag: split-id-collision): Do NOT use naive '{id}-b' for split IDs. Use collision-safe scheme like or scan existing IDs for max numeric suffix. clip.id is used as React key in VideoTrack.tsx:60, AudioTrack.tsx:16, OverlayTrack.tsx:46 \u2014 duplicates break reconciliation.", "METADATA-STALE (flag: duration-metadata-stale): calculateMetadata in Root.tsx does NOT re-run when public/timeline.json changes via the sidecar. The 1.5s poll updates visual preview state, but scrubber bounds (durationInFrames) may go stale after edits that change total duration. If this becomes a problem during testing, investigate calling Remotion's reevaluateComposition API from the save callback, or document that users need to manually refresh for duration changes.", "SERIALIZATION-FIDELITY: serializeForDisk must produce EXACTLY the TimelineConfig shape \u2014 only these fields per clip: id, at, track, asset, from, to, speed, hold, volume, x, y, width, height, opacity, effects. Any assetEntry, registry, or src leaking into timeline.json will break Python tools.", "RENDER-GATING: Use getRemotionEnvironment().isStudio to gate EditorOverlay \u2014 NOT process.env checks. Verify by running npx remotion render and confirming no overlay in output.", "HOLD-VS-FROM-TO: Overlay clips use 'hold' (static duration) instead of from/to. Every editing feature must branch on this: trim adjusts hold directly, speed is disabled for hold clips, split divides hold proportionally. The ClipPanel must show different fields based on clip type.", "CORS: Sidecar on port 3111 must allow CORS from localhost:3000 (Remotion Studio default port). If Studio runs on a different port, this will silently fail.", "CONCURRENT WRITES: Both the sidecar (browser edits) and Python tools can write timeline.json. There is no locking mechanism \u2014 advise users not to edit from both simultaneously in this phase." ], "sense_checks": [ { "id": "SC1", "task_id": "T1", "question": "Does the sidecar server start on port 3111, respond to GET/POST /api/timeline, write to BOTH ../timeline.json and public/timeline.json, and does 'npm run dev' start both the sidecar and Remotion Studio?", "verdict": "" }, { "id": "SC2", "task_id": "T2", "question": "Does serializeForDisk strip assetEntry and registry, producing only {output, clips} with exactly the TimelineClip fields? Does a round-trip (load \u2192 serialize \u2192 POST \u2192 reload) produce an identical timeline.json?", "verdict": "" }, { "id": "SC3", "task_id": "T3", "question": "Does the EditorOverlay appear in Remotion Studio but NOT during npx remotion render? Is it rendered via portal outside the composition's visual area?", "verdict": "" }, { "id": "SC4", "task_id": "T4", "question": "Does clicking a clip bar select it and show the ClipPanel with correct fields (from/to/speed for media clips, hold for overlay clips)? Do numeric input edits persist to timeline.json?", "verdict": "" }, { "id": "SC5", "task_id": "T5", "question": "Can you drag a clip horizontally to reposition it, does the new clip.at value appear in timeline.json, and does the preview reflect the new position after the 1.5s poll?", "verdict": "" }, { "id": "SC6", "task_id": "T6", "question": "Does left-trim correctly multiply the timeline delta by clip.speed when updating clip.from? Does trimming a hold clip adjust the hold value instead of from/to? Are values clamped to valid ranges?", "verdict": "" }, { "id": "SC7", "task_id": "T7", "question": "Does the speed slider update clip.speed in the JSON, is it disabled for hold clips, and does the clip bar width in the overlay reflect the speed-adjusted duration?", "verdict": "" }, { "id": "SC8", "task_id": "T8", "question": "Does splitting produce two clips with collision-safe IDs, seamless playback at the split point (no gap/overlap), and correct handling of both from/to and hold clips?", "verdict": "" }, { "id": "SC9", "task_id": "T9", "question": "Does mute toggle set volume to 0 (or back to 1), persist to JSON, and show a visual indicator on the clip bar?", "verdict": "" }, { "id": "SC10", "task_id": "T10", "question": "Do M, S, and Escape shortcuts work without conflicting with Remotion's built-in shortcuts (Space, arrows)? Is there NO Delete/Backspace shortcut?", "verdict": "" }, { "id": "SC11", "task_id": "T11", "question": "Does python3 tools/view.py show edits made in the browser? Does python3 tools/render.py --dry-run succeed after browser edits?", "verdict": "" } ], "meta_commentary": "EXECUTION GUIDANCE:\n\n\n- \u2014 TimelineClip type (lines 10-26), ResolvedTimelineConfig (line 61), getClipTimelineDuration (line 156), getClipSourceDuration (line 148)\n- \u2014 1.5s poll mechanism (lines 24-46), current rendering structure (lines 54-74)\n- \u2014 calculateMetadata (lines 33-49), TimelineCompositionProps (line 28)\n- \u2014 correct trim math with speed multiplier (the reference implementation)\n- \u2014 current copy logic for bootstrapping public/\n\n\n\n1. (T6): The plan says "adjusts clip.from and clip.at by the same delta" but this is WRONG for speed-adjusted clips. The correct formula is . The viewer already implements this correctly at App.tsx:218. Get this right or trimmed clips will have wrong source ranges.\n\n2. (T8): Use or scan config.clips for existing IDs and append an incrementing number. Never use the naive suffix from the plan \u2014 splitting twice produces duplicate IDs which break React reconciliation.\n\n3. (all tasks): After edits that change total timeline duration, the scrubber range won't auto-update because calculateMetadata doesn't re-run on static file changes. The 1.5s poll updates the visual preview correctly, but the Studio scrubber bounds remain stale. This is acceptable for Phase 1 \u2014 document that users should refresh the browser tab if duration changes significantly. If time permits, investigate importing reevaluateComposition from @remotion/studio.\n\n T5 (drag), T6 (trim), T7 (speed), T8 (split), T9 (mute) all depend on T4 but are independent of each other \u2014 they can be implemented in any order. Prioritize T5 and T6 as highest value.\n\n After each feature task, manually verify in Studio AND check the on-disk timeline.json. The key invariant: timeline.json must always be valid for Python tools. Run as a quick sanity check after each feature.\n\n \u2014 verify this API exists in the installed Remotion version before relying on it for render gating. If unavailable, fall back to checking combined with checking if the Remotion Studio UI shell is present." }
- Assistant