Replace @xzdarcy/react-timeline-editor entirely with a custom lightweight timeline renderer. The library bundles interact.js (~85KB minified) and we only use it for: time ruler rendering, row layout with virtualization, resize via interact.js, and cursor/playhead rendering. We've already reimplemented drag (useClipDrag), drop (useExternalDrop, useDragCoordinator), and cross-track moves ourselves. The goal is to eliminate the ~250KB minified dependency entirely and build a custom using our existing hooks + a simple pointer-event resize handler. Key files: src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx (main consumer), useClipDrag.ts, useClipResize.ts, useDragCoordinator.ts, useExternalDrop.ts, coordinate-utils.ts. The library provides: Timeline component from @xzdarcy/react-timeline-editor, TimelineAction/TimelineRow/TimelineState types from @xzdarcy/timeline-engine, CSS from @xzdarcy/react-timeline-editor/dist/react-timeline-editor.css.
User notes and answers:
User answers: Q1: Clean reimplementation acceptable, not pixel-perfect parity. Q2: Might have 50+ tracks, so consider virtualization. Q3: Simple pointer-event resize with min-width clamping is sufficient, no inertia/snap needed. Q4: One PR, all in one go.
code
Plan:
# Implementation Plan: Replace @xzdarcy/react-timeline-editor with Custom TimelineCanvas
Overview
Goal: Eliminate @xzdarcy/react-timeline-editor (~250KB minified, bundles interact.js and react-virtualized) by replacing its <Timeline> component with a custom <TimelineCanvas> that reuses the existing custom hooks.
Current state: The library is used as a thin rendering shell. Almost all behavior is already custom:
Drag — fully custom (useClipDrag with pointer capture, useExternalDrop with HTML5 DnD)
Resize — delegates to library via onActionResizeStart/End callbacks (the only real behavioral dependency)
Cursor/playhead — library renders the cursor line; sync uses timelineRef.current.setTime(time) — the only method called on TimelineState
Ruler — library renders the time ruler (scale ticks + labels)
Assistant
Row layout — library uses react-virtualized to render rows; each action rendered via getActionRender callback (fully custom <ClipAction>)
onChange — only fires during resize (since movable: false on all actions)
What the library actually provides (that we must replicate):
Time ruler — tick marks at scaleSplitCount intervals, scale labels
Row grid — rows of rowHeight px, horizontally scrollable, actions positioned by start/end × pixelsPerSecond
Action positioning — absolute-positioned divs for each action with left/width computed from time
Cursor line — vertical line at current time, draggable via pointer on ruler
Click-on-ruler — onClickTimeArea callback
Scroll sync — header ruler syncs scroll with edit area
Virtualization — react-virtualized Grid for the edit area (only matters with many tracks)
What we DON'T need to replicate:
Built-in drag (movable: false everywhere)
Row drag reordering (custom track management)
Timeline engine/playback engine (we use Remotion)
dragLine assist lines
Effect system (custom ClipMeta)
Key constraint: The drop-position.ts module queries .timeline-editor-edit-area and .ReactVirtualized__Grid DOM nodes for scroll offsets. These selectors must be replaced with refs or new class names.
Phase 1: Foundation — Types, Ruler, Grid Shell
Step 1: Define own types to replace @xzdarcy/timeline-engine types
Calls getActionRender(action, row) for each action's content.
Horizontal + vertical scroll via native overflow: auto on the grid container.
Syncs scroll position with <TimeRuler> via a shared ref or callback.
Background grid lines at scaleWidth / scaleSplitCount intervals using background-image: repeating-linear-gradient(...).
Exposeref: TimelineCanvasHandle via useImperativeHandle:
setTime(t) — updates cursor position state.
getTime() — returns current cursor time.
target — the grid container DOM node.
Render cursor line as an absolute-positioned div at currentTime * pixelsPerSecond + startLeft within the grid, updating on every setTime call via a ref (not state, for perf during playback).
Skip virtualization initially — the video editor typically has 2–8 tracks. If needed later, add windowing for rows.
WireeditAreaRef to the grid container's DOM node (replaces .timeline-editor-edit-area queries).
Phase 2: Resize + Interaction Wiring
Step 4: Build pointer-event resize handles
Scope: Medium
Add left and right resize handles to each action wrapper in <TimelineCanvas>:
Thin (8px) absolute-positioned divs at left and right edges, cursor: ew-resize.
On pointerdown: capture pointer, record initial action.start/action.end and clientX.
On pointermove: compute new start or end based on delta, clamp to >= 0 and maintain minimum width.
Fire onActionResizing({ action: updatedAction, row, start, end, dir }) during drag for live preview.
On pointerup: fire onActionResizeEnd({ action: updatedAction, row, dir }).
On pointerdown also fire onActionResizeStart({ action, row, dir }).
Keep the same callback signatures as the library so useClipResize.ts needs zero changes.
Validate: Resize a clip and confirm useClipResize receives correct start/end/dir values and persists correctly.
Step 5: Update drop-position.ts DOM queries
Scope: Small
Replace.timeline-editor-edit-area query with a ref passed from TimelineCanvas (or a stable class like .timeline-canvas-edit-area).
Replace.ReactVirtualized__Grid scroll queries with the grid container ref's scrollLeft/scrollTop.
UpdategetTimelineDomNodes cache in drop-position.ts to use new selectors.
Validate: Internal clip drag and external drop still compute correct positions.
Step 6: Wire TimelineCanvas into TimelineEditor.tsx
Scope: Medium
Replace the <Timeline> import and JSX with <TimelineCanvas>:
Pass same props: ref={timelineRef}, rows={immovableRows} (can drop immovableRows mapping since we no longer need movable: false), effects, scale, scaleWidth, etc.
Interaction testing after Steps 4–6 (resize, drag, drop).
Bundle size verification after Step 8.
Full end-to-end pass in Step 9.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-03-25T19:59:01Z",
"hash": "sha256:88785b83b61d24a6b1a143ef01f06a9d2acfb6a5b0a25f3fafa2108887c0d7d7",
"questions": [
"The library's time ruler renders at 32px height with specific tick styling. Do you want pixel-perfect parity with the existing ruler, or is a clean reimplementation with similar functionality acceptable?",
"Virtualization: The library uses react-virtualized for the grid. With typical track counts (2-8), native scroll should be fine. Is there a scenario where you'd have 50+ tracks that would require windowed rendering?",
"The library's resize handles use interact.js which provides features like inertia, snap-to-grid, and minimum-size constraints. Do you need any of these, or is a simple pointer-event resize with just minimum-width clamping sufficient?",
"Should this be done as one large PR or broken into smaller PRs (e.g., PR1: own types + TimelineCanvas shell, PR2: resize + wiring, PR3: cleanup)?"
],
"success_criteria": [
"Zero imports from @xzdarcy/react-timeline-editor or @xzdarcy/timeline-engine remain in the codebase",
"npm package @xzdarcy/react-timeline-editor is removed from package.json and node_modules",
"Bundle size decreases by ~200KB+ minified (interact.js + react-virtualized + timeline-engine removed)",
"All 12 interaction paths pass manual testing: ruler click, cursor drag, left resize, right resize, internal drag, cross-track drag, external file drop, external asset drop, new-track drop, clip split, clip delete, playback sync",
"tsc --noEmit and npm run build succeed with zero errors",
"No visual regressions: clips render at correct time positions, ruler ticks align with clip boundaries, cursor tracks playhead correctly",
"Existing hooks (useClipDrag, useClipResize, useDragCoordinator, useExternalDrop) require minimal or zero changes to their core logic"
],
"assumptions": [
"Track count stays under ~20, so native scroll without virtualization is acceptable. Virtualization can be added later if needed.",
"The library's autoScroll feature (auto-scroll during drag) is handled by useClipDrag's existing scroll logic, not the library.",
"The effects map passed to the library (data.effects) is not meaningfully used by the library at runtime since we use custom renderers \u2014 it can be dropped from TimelineCanvas props.",
"The library's onChange callback is only needed for resize events (since movable: false disables move-driven onChange). The custom resize handler will call the same applyTimelineEdit path directly.",
"The dragLine assist line feature (snapping guidelines during drag) is not critical and can be omitted \u2014 useClipDrag doesn't use it.",
"The library's cursor rendering (blue vertical line with draggable top handle) can be simplified to a plain vertical line positioned by time. The drag-on-ruler interaction replaces the cursor drag handle."
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered step sections (`### Step N:` under `## Phase` headers, or flat `## Step N:`) with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`.
- Missing required sections or step coverage (for example: no H1, no `## Overview`, or no step sections at all) should be flagged as category `completeness` with severity_hint `likely-significant`.
- Structural formatting within steps (for example: prose instead of numbered substeps, or a missing file reference inside an otherwise actionable step) should usually be category `completeness` with severity_hint `likely-minor` because the executor can still follow the instructions.
- Ask whether the plan is the simplest approach that solves the stated problem, whether it could use fewer steps or less machinery, and whether it introduces unnecessary complexity.
- Over-engineering concerns should use category `maintainability`, should usually prefix the concern with "Over-engineering:", and should scale severity_hint to the practical impact.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.
{"flags":[{"id":"resize-preview-path-missing","concern":"The resize step drops the repo's current live-update path. Today the editor relies on row updates during resize, while useClipResize only does start/end bookkeeping and final persistence. A custom pointer handler that only fires onActionResizeStart/onActionResizeEnd will not visibly resize clips unless TimelineCanvas also owns transient action geometry or drives onChange during drag.","category":"correctness","severity_hint":"likely-significant","evidence":"src/tools/video-editor/hooks/useClipEditing.ts:62-65 documents onChange as the resize-driven row update path. src/tools/video-editor/hooks/useClipResize.ts:12-15 exposes only start/end handlers, and src/tools/video-editor/hooks/useClipResize.ts:36-89 commits the final row/meta update only on resize end. There is no existing consumer for an onActionResizing callback in this repo."},{"id":"virtualization-and-scroll-sync-regression","concern":"The plan explicitly defers virtualization even though the stated usage includes 50+ tracks, and it does not call out vertical scroll syncing between the track-label column and the timeline body. In this repo those are separate panes, so a naive native-scroll replacement is likely to regress both performance and row/label alignment on large timelines.","category":"correctness","severity_hint":"likely-significant","evidence":"src/tools/video-editor/components/TimelineEditor/TimelineEditor.tsx:179-223 renders the left track labels and right timeline as separate containers. src/tools/video-editor/components/TimelineEditor/TrackLabel.tsx:30-86 renders one DOM row per track. src/tools/video-editor/lib/drop-position.ts:60-86 currently depends on the library grid's scroll container (.ReactVirtualized__Grid), which shows the existing implementation already assumes a dedicated scrolling surface."},{"id":"timeline-effect-type-leftover","concern":"The type-replacement step is incomplete for the stated goal of removing all @xzdarcy imports. The repo still pulls TimelineEffect from @xzdarcy/timeline-engine, so replacing only TimelineAction/TimelineRow/the ref handle will leave either a broken import or an orphaned effects field.","category":"completeness","severity_hint":"likely-minor","evidence":"src/tools/video-editor/lib/timeline-data.ts:1-6 imports TimelineEffect as EditorTimelineEffect, and src/tools/video-editor/lib/timeline-data.ts:60-67 keeps it on TimelineData.effects. The proposed local type file only covers TimelineAction, TimelineRow, and TimelineCanvasHandle."}],"verified_flag_ids":[],"disputed_flag_ids":[]}