Timeline editing
Timeline editing is the editor's frame-based workspace for arranging media and generated layers into tracks. It turns pointer, keyboard, and drag-and-drop input into synchronized clip, track, transition, and animation changes that feed preview, composition, and project save flows. See the Editor workspace page for the wider editor model.
Timeline model
Tracks
Tracks are ordered lanes that organize timeline items and control how they participate in the edit. A track can be video or audio, and it carries user controls for lock, visibility, mute, solo, volume, sync lock, and row size; grouped tracks can form a collapsible layer group. The timeline keeps track records separate from their items so a track can be reordered or changed without changing the clips it owns. src/…/timeline.ts• L476-495
The main surface presents video and audio lanes as separate sections when both kinds exist. Track headers and clip rows share vertical scrolling, and a section divider lets the user give more room to either section. Track-size presets and the divider position are view preferences rather than project edits. New media can target a compatible lane or create a suitable lane when the drop is outside the existing stack. src/…/timeline.tsx• L125-165, src/…/timeline.tsx• L777-1060, src/…/timeline-content.tsx• L596-717
References: src/…/timeline.ts• L476-495 src/…/timeline.tsx• L125-165 src/…/timeline.tsx• L777-1060 src/…/timeline-content.tsx• L596-717
Clips
Clips are timeline items with a start frame and a duration. They may refer to source media, text, images, shapes, compositions, or subtitles. Media clips also carry a source range and playback settings, which lets a timeline edit change the visible part of a source without changing the source file. src/…/timeline.ts• L57-91, src/…/timeline.ts• L191-243, src/…/timeline.ts• L428-474
The model keeps relationships that must survive edits. A linkedGroupId ties items such as video and its audio companion together. An originId keeps split pieces in one lineage. Composition items point to reusable sub-compositions. Transitions and keyframes belong to the timeline state but remain separate from the clip record. src/…/timeline.ts• L57-75, src/…/timeline.ts• L392-400, src/…/types.ts• L50-63
Each clip has an interactive shell that presents its frame range and carries selection, drag, pointer, context-menu, and effect-drop behavior. The shell separates these shared controls from the clip-specific content shown inside the clip, so visual previews can change without changing the edit contract. src/…/timeline-item-shell.tsx• L54-163
References: src/…/timeline.ts• L57-75 src/…/timeline.ts• L191-243 src/…/timeline.ts• L392-400 src/…/timeline.ts• L428-474 src/…/timeline-item-shell.tsx• L54-163
Composition contexts
The visible timeline can represent the Main timeline, a standalone sequence, or a sub-composition. Entering a composition changes the live editing context and maps the global playhead to the local frame of the opened composition. Leaving the context saves its current edits and restores the parent timeline. This makes a nested composition behave like an editable timeline while preserving the parent clip that contains it. src/…/composition-navigation-store.ts• L141-215, src/…/composition-navigation-store.ts• L256-333
The same context boundary applies to markers, in/out points, audio bus settings, view state, and undo history. A change made inside one composition must not restore or undo content from another composition. src/…/composition-navigation-store.ts• L21-60, src/…/timeline-command-store.ts• L7-43
References: src/…/composition-navigation-store.ts• L141-215 src/…/composition-navigation-store.ts• L256-333 src/…/composition-navigation-store.ts• L21-60 src/…/timeline-command-store.ts• L7-43
Editing surface
Interaction controls
The timeline header exposes the tools and view controls that define an edit gesture. The select tool moves and selects clips. Trim edit exposes edge and body edits. Razor splits a clip. Rate stretch changes timing. Slip changes source content inside a fixed window. Slide moves a clip while its adjacent clips preserve the cut. Snap, audio skim, markers, in/out points, linked selection, keyframe lanes, zoom, and undo/redo support these tools without changing the core timeline model. src/…/timeline-header.tsx• L438-483, src/…/timeline-header.tsx• L513-838
The pointer router chooses the operation from the active tool and the part of the clip under the pointer. A clip click selects it, a double-click opens its source or composition, and a body or edge gesture starts the matching edit. A locked track blocks clip edits. The shared clip shell carries this pointer and drag surface while preserving the selected and constrained visual states during the gesture. src/…/use-timeline-item-pointer-handlers.ts• L76-81, src/…/use-timeline-item-pointer-handlers.ts• L104-237, src/…/use-timeline-item-pointer-handlers.ts• L241-345, src/…/timeline-item-shell.tsx• L99-163
References: src/…/timeline-header.tsx• L513-838 src/…/use-timeline-item-pointer-handlers.ts• L76-81 src/…/use-timeline-item-pointer-handlers.ts• L104-237 src/…/use-timeline-item-pointer-handlers.ts• L241-345 src/…/timeline-item-shell.tsx• L99-163
Clip movement
Moving a clip changes time and can change its track. The edit keeps a multi-clip selection together, expands linked companions when linked selection is on, rejects incompatible tracks, and uses clip boundaries as collision walls. Snap targets help align clip edges with nearby edits. Holding the copy modifier turns the gesture into a duplicate rather than a move. src/…/use-timeline-drag.ts• L392-425, src/…/use-timeline-drag.ts• L741-866, src/…/use-timeline-drag.ts• L1207-1335
Media and generated layers can also enter the timeline through drag and drop. The surface first shows a placement ghost, then resolves the media and chooses collision-free placements. A video with owned audio can become a linked video/audio pair. Composition drops are checked for cycles before they can add a nested composition. Media source ownership and import behavior are described in Media and scene management. src/…/timeline-track.tsx• L367-445, src/…/timeline-track.tsx• L699-868, src/…/timeline-track.tsx• L1074-1218
References: src/…/use-timeline-drag.ts• L741-866 src/…/timeline-track.tsx• L699-868 src/…/timeline-track.tsx• L1074-1218
Edge and body edits
Normal trim changes a clip edge within the available source and neighboring space. Rolling trim moves the shared cut between two adjacent clips. Ripple trim changes the edit point and shifts later content. Slip keeps the clip window fixed while changing the source range. Slide moves the clip and adjusts its immediate neighbors. Rate stretch changes duration and playback speed for source-based clips. src/…/use-timeline-trim.ts• L77-85, src/…/use-timeline-trim.ts• L177-326, src/…/use-timeline-slip-slide.ts• L211-218
These edits show constrained feedback while the pointer moves. The final action is limited by source handles, track walls, transitions, keyframes, and the start of the timeline. This lets the user see a valid result before the edit reaches the shared timeline state. src/…/use-timeline-trim.ts• L277-399, src/…/use-timeline-slip-slide.ts• L854-1141
References: src/…/use-timeline-trim.ts• L77-85 src/…/use-timeline-trim.ts• L177-326 src/…/use-timeline-trim.ts• L684-764 src/…/use-timeline-slip-slide.ts• L211-218 src/…/use-timeline-slip-slide.ts• L854-1178
Selection and navigation
The timeline supports direct selection, modifier-based multi-selection, marquee selection, and linked selection. Empty-space clicks clear clip and marker selection. The playhead, ruler, preview scrubber, markers, and in/out range provide time navigation. Zoom keeps the chosen cursor or playhead position stable while the timeline width changes, and playback can follow the playhead at the viewport edge. src/…/timeline-content.tsx• L479-507, src/…/timeline-content.tsx• L1204-1333, src/…/timeline-content.tsx• L1678-1786
The timeline short-cut layer composes separate controls for playback, editing, tools, markers, in/out points, user-interface actions, clipboard actions, and the Source Monitor. It keeps keyboard behavior available across timeline variants while the visual surface changes. src/…/use-timeline-shortcuts.ts• L20-41
References: src/…/timeline-header.tsx• L438-483 src/…/use-timeline-item-pointer-handlers.ts• L76-81 src/…/use-timeline-drag.ts• L392-425 src/…/use-timeline-trim.ts• L77-85 src/…/use-timeline-slip-slide.ts• L211-218 src/…/timeline-content.tsx• L1204-1333 src/…/use-timeline-shortcuts.ts• L20-41
Edit synchronization
Preview and commit
An active gesture uses local state and dedicated preview stores to show the proposed clip bounds and related movement without repeatedly committing project data. On release, the operation becomes one timeline command. The command system records the before state, clears redo history for a new change, and restores the matching snapshot for undo or redo. src/…/use-timeline-trim.ts• L77-85, src/…/use-timeline-trim.ts• L684-764, src/…/timeline-command-store.ts• L45-76
The same history boundary covers item changes, project metadata changes, and a rate-stretch gesture that produces many preview steps. The committed path is the contract for downstream systems: it updates the item or track domain, repairs affected transitions, marks the timeline dirty, and removes related records when a clip is deleted. src/…/shared.ts• L27-70, src/…/item-actions.ts• L717-733, src/…/item-actions.ts• L915-943, src/…/timeline-command-store.test.ts• L33-225
This diagram shows how an edit travels from the surface to the synchronized timeline and its consumers.
flowchart LR
U[Pointer or keyboard gesture] --> P[Live edit preview]
P --> C[Committed timeline command]
C --> I[Items and tracks]
C --> R[Transitions and keyframes]
C --> S[Selection and playback view]
I --> V[Preview and composition runtime]
R --> V
I --> D[Dirty project state]
D --> W[Project persistence]
References: src/…/use-timeline-trim.ts• L77-85 src/…/use-timeline-trim.ts• L684-764 src/…/timeline-command-store.ts• L45-76 src/…/shared.ts• L27-70 src/…/item-actions.ts• L717-733 src/…/item-actions.ts• L915-943 src/…/timeline-command-store.test.ts• L33-225
Linked edits
Linked items are synchronized companions that should keep time and source relationships during an edit. Video and audio companions can move, trim, slip, slide, reverse, or ripple together when linked selection is enabled. Generated captions attached to a media clip are included in relevant move and trim operations. src/…/use-timeline-drag.ts• L392-425, src/…/use-timeline-trim.ts• L507-644, src/…/index.tsx• L377-419
Track sync lock extends ripple behavior beyond the edited track. When an edit removes or inserts a time interval, eligible locked tracks receive the same time change. Tracks that are not part of the edit and do not use sync lock can remain in place, which lets an engineer distinguish linked-item sync from cross-track ripple sync. src/…/item-actions.ts• L945-1079, src/…/range-removal-actions.ts• L60-175
References: src/…/use-timeline-drag.ts• L392-425 src/…/use-timeline-trim.ts• L507-644 src/…/item-actions.ts• L945-1079 src/…/range-removal-actions.ts• L60-175
Transitions and animation
Transitions depend on the positions and adjacency of their two clips. Move, trim, ripple, slide, and delete actions therefore repair or remove transitions after changing clip bounds. The edit surface also exposes keyframe lanes and keeps keyframe state in the same command boundary as related clip changes. src/…/shared.ts• L37-70, src/…/item-actions.ts• L1205-1293, src/…/index.tsx• L628-674
Effects, motion, transforms, and keyframes are clip-level or related timeline state. They are not separate timeline documents. Their actions pass through the same timeline action boundary so a visual edit can remain undoable and can be serialized with the composition. For feature detail, see Effects and animation. src/…/timeline-actions.ts• L13-29, src/…/timeline-store-facade.ts• L149-178
References: src/…/use-timeline-trim.ts• L684-764 src/…/timeline-command-store.ts• L45-76 src/…/shared.ts• L27-70 src/…/item-actions.ts• L945-1079 src/…/range-removal-actions.ts• L60-175 src/…/timeline-actions.ts• L13-29
Worker-assisted operations
Waveform preparation
Audio and video clips can display waveforms that help the user see sound while editing. The waveform cache loads existing data when possible and requests new data only when a clip needs it. A worker decodes audio and sends progressive peak chunks, while the service stores and publishes those updates for visible clips. If the worker path is not available, the service uses a main-thread audio fallback. src/…/waveform-worker.ts• L1-7, src/…/waveform-cache.ts• L1-10, src/…/waveform-cache.ts• L683-941
The timeline prefetches waveform data ahead of the viewport instead of waiting for a clip to become visible. It biases work toward the scroll direction and defers it during drag, trim, and zoom gestures. This keeps media preparation useful without competing with an active edit. src/…/use-waveform-prefetch.ts• L15-47, src/…/use-waveform-prefetch.ts• L58-127
References: src/…/waveform-worker.ts• L1-7 src/…/waveform-cache.ts• L683-941 src/…/use-waveform-prefetch.ts• L58-127
Filmstrip preparation
Video clips use filmstrips as visual context. The extraction worker decodes frames and sends immediate display bitmaps plus encoded frames for storage. The cache can extract priority frames near the active view, refine a partial result, and coordinate several workers under memory limits. src/…/filmstrip-extraction-worker.ts• L1-7, src/…/filmstrip-extraction-worker.ts• L236-349, src/…/filmstrip-cache.ts• L1066-1121
Filmstrip and waveform services are display aids, not the edit source of truth. A missing or delayed preview asset should affect visual detail or readiness, not the clip's frame range, track membership, or saved project data.
References: src/…/waveform-worker.ts• L1-7 src/…/waveform-cache.ts• L683-941 src/…/use-waveform-prefetch.ts• L58-127 src/…/filmstrip-extraction-worker.ts• L236-349 src/…/filmstrip-cache.ts• L1066-1121
References: src/…/filmstrip-extraction-worker.ts• L1-7 src/…/filmstrip-extraction-worker.ts• L236-349 src/…/filmstrip-cache.ts• L144-169 src/…/filmstrip-cache.ts• L1066-1121
Content analysis and source preparation
Silence removal uses source-time analysis to find removable ranges. Signal analysis sends decoded audio slices to a worker. Speech analysis uses transcript ranges to find gaps between spoken words. The result is shown as an overlay before the edit action splits clips and applies ripple removal. src/…/silence-removal-preview.ts• L136-191, src/…/silence-removal-preview.ts• L194-259, src/…/silence-removal-preview.ts• L341-369
The committed range removal path preserves linked items and applies the same transition, keyframe, and sync-lock cleanup as other ripple edits. This separates analysis failure or cancellation from the destructive edit itself. src/…/range-removal-actions.ts• L178-214, src/…/range-removal-actions.ts• L240-353
Reversed video uses a prepared conform when the source cannot play backward smoothly in the normal preview path. The service shares work for the same source request, keeps preview and full-quality results distinct, stores the result for later hydration, and commits the reverse state only after preparation succeeds. src/…/reverse-conform-service.ts• L337-367, src/…/reverse-conform-service.ts• L374-443, src/…/item-actions.ts• L873-912
References: src/…/silence-removal-preview.ts• L136-191 src/…/silence-removal-preview.ts• L341-369 src/…/range-removal-actions.ts• L178-214 src/…/reverse-conform-service.ts• L374-443 src/…/item-actions.ts• L873-912
State and persistence
Domain stores
Timeline state is split by concern but presented to the editor through one facade. Item and track state form the core content. Separate domains hold transitions, keyframes, markers, and timeline settings. Cross-domain actions coordinate them when one edit affects more than one domain. src/…/timeline-store-facade.ts• L7-12, src/…/timeline-store-facade.ts• L57-108, src/…/timeline-actions.ts• L1-11
The facade is a compatibility boundary for timeline consumers. Its snapshot combines current domain state with stable actions, while its subscriptions notify the editor when any relevant domain changes. The settings domain also tracks the dirty flag, frame rate, snap mode, audio skim mode, and saved scroll position. src/…/timeline-store-facade.ts• L190-205, src/…/timeline-settings-store.ts• L3-28
References: src/…/timeline-store-facade.ts• L7-12 src/…/timeline-store-facade.ts• L57-108 src/…/timeline-store-facade.ts• L190-205 src/…/timeline-actions.ts• L1-11 src/…/timeline-settings-store.ts• L3-28
View state
Viewport measurements are kept apart from timeline content. The viewport store tracks scroll position and size and can request that a frame become visible. Scroll-only updates are throttled, while size changes apply at once. This lets culling, waveform prefetch, and playback follow-scroll respond without making every timeline edit a project edit. src/…/timeline-viewport-store.ts• L3-31, src/…/timeline-viewport-store.ts• L68-129
The timeline also reduces work for large projects by rendering only items near the visible range and by using a compact overview for dense tracks. These choices change presentation detail, not the underlying clip set. src/…/timeline-track-items.tsx• L61-83, src/…/timeline-track-items.tsx• L211-244
References: src/…/timeline-viewport-store.ts• L3-31 src/…/timeline-viewport-store.ts• L68-129 src/…/timeline-track-items.tsx• L61-83 src/…/timeline-track-items.tsx• L211-244
Project synchronization
Saving serializes the current timeline and composition state into the project model. Loading reverses that path: it reads the project, applies migrations and repairs, hydrates the domain stores, restores view and playback state, and validates media references. Ephemeral object URLs are removed from saved items because media-backed clips resolve their source again when loaded. src/…/timeline-persistence.ts• L141-223, src/…/timeline-persistence.ts• L800-910, src/…/timeline-persistence.ts• L1065-1084
When a nested composition is active, persistence folds its live edits into the saved composition without navigating the editor. This keeps the visible context and the saved project aligned. The resulting timeline data is then available to preview and export paths; see Preview and export. src/…/timeline-persistence.ts• L730-796, src/…/timeline-persistence.ts• L916-1058
References: src/…/timeline-store-facade.ts• L7-12 src/…/timeline-actions.ts• L1-11 src/…/timeline-settings-store.ts• L3-28 src/…/timeline-viewport-store.ts• L68-129 src/…/timeline-persistence.ts• L800-910 src/…/timeline-persistence.ts• L1065-1084
References: src/…/timeline-persistence.ts• L730-796 src/…/timeline-persistence.ts• L916-1058
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
TimelineItemorTimelineTrackmust remain compatible with timeline actions, composition navigation, persistence, and the composition input consumed by preview and export. - Changes to linked-item behavior must cover move, trim, ripple, slip, slide, delete, and source-range analysis. Video/audio companions and attached captions must not lose alignment.
- Changes to track sync lock must keep inserted and removed intervals consistent across ripple edits and range-removal edits.
- Changes to transition-sensitive clip bounds must preserve transition repair and breakage reporting after moves, trims, splits, joins, and deletes.
- Changes to worker preview data must preserve the distinction between transient display assets and saved timeline content. Worker cancellation or cache misses must not commit an edit.
- Changes to composition navigation must update both the live domain stores and the matching undo-history context before edits can continue.
- Changes to the shared command boundary must keep item edits, project metadata edits, and multi-step preview gestures within the correct undo and redo scope.
- Changes to the timeline surface must keep track-header scrolling, clip-row scrolling, video/audio section sizing, and drag previews synchronized.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Edit targets a locked track | The clip does not move, trim, stretch, slip, or slide. | Track lock is checked by the pointer router and each edit hook. src/…/use-timeline-item-pointer-handlers.ts• L241-345 |
| Clip move enters an incompatible track | The visual move is rejected or the drop is marked invalid. | Track-kind compatibility and linked-drop target resolution gate the commit. src/…/use-timeline-drag.ts• L593-681 |
| Trim exceeds source or neighbor bounds | The edit stops at the last valid edge and shows a constraint. | Source, adjacency, transition, and keyframe limits clamp the preview and commit. src/…/use-timeline-trim.ts• L277-399 |
| Composition drop would create a cycle | The nested clip is not added. | Composition graph checks run during both preview and drop handling. src/…/timeline-track.tsx• L763-785, src/…/timeline-track.tsx• L1097-1107 |
| Transition loses valid clip geometry after an edit | The transition is repaired or a breakage event is reported. | Cross-domain actions run transition repair after changed clip bounds. src/…/shared.ts• L37-70 |
| A committed preview sequence is recorded as separate commands | Undo steps expose intermediate states instead of the user's single gesture. | Preview actions omit history until commit, then add one snapshot-backed command. src/…/timeline-command-store.test.ts• L169-225 |
| Worker decode or cache read fails | Preview detail remains incomplete, but the timeline can use a fallback or retry path. | Waveform generation falls back to AudioContext; filmstrip work reports errors and keeps extraction state separate from clips. src/…/waveform-cache.ts• L1158-1197, src/…/filmstrip-cache.ts• L144-169 |
| Saved media reference no longer resolves | The clip is marked as orphaned and the user is shown an orphaned-clip flow. | Load validates media references after hydration. src/…/timeline-persistence.ts• L1320-1336 |
Key files
| File | Why to read it |
|---|---|
| src/…/timeline.ts | Defines the frame-based track and clip model and the relationships used by edits. |
| src/…/timeline.tsx | Shows how the timeline surface joins the toolbar, track headers, content, sections, navigation, and view-only sizing controls. |
| src/…/timeline-header.tsx | Shows the user-facing tools and edit controls. |
| src/…/timeline-content.tsx | Shows selection, playhead, zoom, scrolling, culling, and viewport coordination. |
| src/…/timeline-item-shell.tsx | Shows the shared clip surface for geometry, selection, pointer input, drag input, and effect drops. |
| src/…/use-timeline-item-pointer-handlers.ts | Shows how pointer intent maps to selection, source/composition entry, split, trim, and movement. |
| src/…/use-timeline-drag.ts | Shows move, duplicate, snap, collision, and cross-track behavior. |
| src/…/use-timeline-trim.ts | Shows normal, rolling, ripple, and transition-aware edge edits. |
| src/…/item-actions.ts | Shows atomic clip changes and their linked, transition, keyframe, and dirty-state effects. |
| src/…/timeline-command-store.ts | Shows the undo/redo contract and context-scoped history. |
| src/…/timeline-command-store.test.ts | Shows the shared history guarantees for item changes, project metadata, and collapsed preview gestures. |
| src/…/composition-navigation-store.ts | Shows how nested and standalone composition timelines become the active edit context. |
| src/…/timeline-persistence.ts | Shows how live timeline state is saved, loaded, migrated, repaired, and hydrated. |
| src/…/waveform-cache.ts | Shows how audio preview data is prepared, cached, and streamed to the timeline. |
| src/…/filmstrip-cache.ts | Shows how video preview frames are prioritized, cached, and coordinated across workers. |