Skip to content

Open source CapCut alternative.

TypeScript

refactor(cut): rename base-track terms to track 0 [rebuild]

David Le3b2019d21192
diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsx
index f2c8ee3b..00493b3d 100644
--- a/site/src/cut/components/Inspector.tsx
+++ b/site/src/cut/components/Inspector.tsx
@@ -20,7 +20,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { Textarea } from "@/components/ui/textarea";
-import { baseClips, clipWindow, useEditor, type EditorState } from "@/cut/lib/store";
+import { track0Clips, clipWindow, useEditor, type EditorState } from "@/cut/lib/store";
import { GenerateSubtitlesAudio } from "@/cut/components/VoicePicker";
import {
parseNumberInput,
@@ -287,19 +287,19 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
const asset = useEditor((s) => s.assets.find((a) => a.id === clip.assetId));
const updateClip = useEditor((s) => s.updateClip);
// A transition hands this clip into the next one, so only offer it when
- // there is a next clip on the base row — layer clips share the sorted array
- // but sit outside the sequence, so position checks read the base row only.
+ // there is a next clip on track 0 — layer clips share the sorted array
+ // but sit outside the sequence, so position checks read track 0 only.
const hasNext = useEditor((s) => {
- const base = baseClips(s.clips);
- const i = base.findIndex((c) => c.id === clip.id);
- return i >= 0 && i < base.length - 1;
+ const row = track0Clips(s.clips);
+ const i = row.findIndex((c) => c.id === clip.id);
+ return i >= 0 && i < row.length - 1;
});
// The whole-video fades are project-level but live on the clips that show
// them: fade in on the first clip's panel, fade out on the last clip's.
- const isFirst = useEditor((s) => baseClips(s.clips)[0]?.id === clip.id);
+ const isFirst = useEditor((s) => track0Clips(s.clips)[0]?.id === clip.id);
const isLast = useEditor((s) => {
- const base = baseClips(s.clips);
- return base[base.length - 1]?.id === clip.id;
+ const row = track0Clips(s.clips);
+ return row[row.length - 1]?.id === clip.id;
});
const fadeIn = useEditor((s) => s.fadeIn);
const fadeOut = useEditor((s) => s.fadeOut);
@@ -603,8 +603,8 @@ function ClipPanel({ clip }: { clip: VideoClip }) {
/** Per-clip generated-audio block: the voice picker, "Generate audio for clip"
* (which transcribes just this clip when it has no cues yet), and one volume
- * slider driving the voiceovers laid over the clip. Shared by the base-row and
- * layer clip panels. */
+ * slider driving the voiceovers laid over the clip. Shared by every clip
+ * panel on any track. */
function ClipGeneratedAudio({ clip }: { clip: VideoClip }) {
// Subtitle cues overlapping this clip's timeline span, for the per-clip
// readout. A selector rather than a snapshot so the generate button reads
diff --git a/site/src/cut/components/Preview.tsx b/site/src/cut/components/Preview.tsx
index 9113c64b..7e323e3a 100644
--- a/site/src/cut/components/Preview.tsx
+++ b/site/src/cut/components/Preview.tsx
@@ -149,8 +149,8 @@ function OverlayPipHandle({ stage }: { stage: { w: number; h: number } }) {
const currentTime = useEditor((s) => s.currentTime);
// Resolve the selected, live, regioned clip (any track) plus how to patch its
- // rect. A clip's own footprint equals its span length, so one path serves the
- // base row and the layers.
+ // rect. A clip's own footprint equals its span length, so one path serves
+ // every track.
let rect: FrameRect | null = null;
let apply: ((frame: FrameRect) => void) | null = null;
if (selection?.kind === "clip") {
diff --git a/site/src/cut/components/Timeline.tsx b/site/src/cut/components/Timeline.tsx
index 39cacc59..5b4e9004 100644
--- a/site/src/cut/components/Timeline.tsx
+++ b/site/src/cut/components/Timeline.tsx
@@ -34,7 +34,7 @@ import { useExports } from "@/cut/lib/exportStore";
import { isDragActive, startDrag, subscribeDragActive } from "@/cut/lib/drag";
import { CLIP_GAP, startLaneMove, startLaneTrim, type LaneDrag } from "@/cut/lib/laneTracks";
import { ensurePeaks, importImage, importStockMusic, importStockVideo } from "@/cut/lib/media";
-import { baseClips, clipLen, clipSpeed, getClipSpans, overlayLayers, projectDuration, rippleInsertBase, TIMELINE_H_MAX, useEditor } from "@/cut/lib/store";
+import { track0Clips, clipLen, clipSpeed, getClipSpans, overlayLayers, projectDuration, rippleInsert, TIMELINE_H_MAX, useEditor } from "@/cut/lib/store";
import type { VideoTrackPlacement } from "@/cut/lib/store";
import { subtitleLaneCount } from "@/cut/lib/subtitles";
import { formatTime, formatTimecode } from "@/cut/lib/time";
@@ -147,7 +147,7 @@ function draggingStockMusic(e: React.DragEvent): AssetRef | null {
export function Timeline() {
const clips = useEditor((s) => s.clips);
const audioClips = useEditor((s) => s.audioClips);
- // The composited layers (every clip off the base row), derived from the one
+ // The composited layers (every clip off track 0), derived from the one
// clip list — the timeline draws them as the tracks around track 0.
const overlayClips = useMemo(() => overlayLayers(clips), [clips]);
const overlays = useEditor((s) => s.overlays);
@@ -734,7 +734,7 @@ export function Timeline() {
// rippling later clips right, so the ghost sits where the segment will
// actually land — a box under the pointer that lands minutes away lies.
const cur = useEditor.getState();
- const { start } = rippleInsertBase(baseClips(cur.clips), dropTimeAt(e.clientX), duration);
+ const { start } = rippleInsert(track0Clips(cur.clips), dropTimeAt(e.clientX), duration);
setAssetDrop({ t: start, len: duration, thumb });
}}
onDragLeave={(e) => {
@@ -977,7 +977,7 @@ export function Timeline() {
>
{spans.length > 0 && laneRail(VIDEO_H - 2)}
{/* An external asset drag previews as an on-track segment ghost
- (below), so the base row skips the full-width dashed guide that
+ (below), so track 0 skips the full-width dashed guide that
would otherwise cover it; an internal clip move still shows it. */}
{videoDragging && trackGuide(TRACK_ZERO)}
{trackSlot(TRACK_ZERO, VIDEO_H - 4)}
diff --git a/site/src/cut/hooks/usePlayback.ts b/site/src/cut/hooks/usePlayback.ts
index 9a2c0b73..77a37723 100644
--- a/site/src/cut/hooks/usePlayback.ts
+++ b/site/src/cut/hooks/usePlayback.ts
@@ -152,7 +152,7 @@ class Engine {
return this.elFor(this.videoEls, clip.id, asset);
}
- /** Decode-ahead for the base track: build each soon-to-enter clip's element
+ /** Decode-ahead for track 0: build each soon-to-enter clip's element
* and seek it to its entrance frame now, so its file is fetching and frame 0
* is decoded before the playhead arrives. Only clips strictly ahead of `t`
* are touched — the live master (and any dissolve partner) steers its own
@@ -636,7 +636,7 @@ class Engine {
const s = useEditor.getState();
const spans = getClipSpans(s.clips, s.assets);
// Drop decoders for clips that no longer exist (deleted or replaced).
- // videoEls holds base-row decoders only, so compare against the spans —
+ // videoEls holds track-0 decoders only, so compare against the spans —
// gating on the whole clip list would let layer clips mask deletions and
// keep dead <video> elements alive.
if (this.videoEls.size > spans.length) {
diff --git a/site/src/cut/lib/aiContext.ts b/site/src/cut/lib/aiContext.ts
index f12d336f..b89cf8df 100644
--- a/site/src/cut/lib/aiContext.ts
+++ b/site/src/cut/lib/aiContext.ts
@@ -80,7 +80,7 @@ export function buildAiContext(opts?: { fullCues?: boolean; chatId?: string | nu
speed: r(sp.clip.speed ?? 1),
};
}
- // A layer clip carries no span (spans are the base row); describe its
+ // A layer clip carries no span (spans are track 0); describe its
// compositing shape instead.
const c = s.clips.find((x) => x.id === id);
return c ? { kind, id, ...describeOverlayClip(c, assetById) } : { kind, id };
diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.ts
index 404dac50..a3de7f17 100644
--- a/site/src/cut/lib/aiTools.ts
+++ b/site/src/cut/lib/aiTools.ts
@@ -24,7 +24,7 @@ import { blobToInlineAudio, refToInlineAudio, type InlineImage } from "./refMedi
import { characterPrompt, stockTitle } from "./stock";
import { STOCK_IMAGES } from "./stockManifest";
import { STOCK_VIDEOS } from "./stockVideoManifest";
-import { baseClips, getClipSpans, nextFreeStart, overlayLayers, TIMELINE_H_MAX, TIMELINE_H_MIN, totalDuration, useEditor } from "./store";
+import { track0Clips, getClipSpans, nextFreeStart, overlayLayers, TIMELINE_H_MAX, TIMELINE_H_MIN, totalDuration, useEditor } from "./store";
import { buildAiContext } from "./aiContext";
import { laneCues, subtitleLaneCount } from "./subtitles";
import { synthesizeMusic } from "./audioGen";
@@ -304,9 +304,9 @@ export async function runAiTool(
"That clip is on an overlay track — use update_overlay_video to move it."
);
if (!isNum(input.toIndex)) throw new ToolError("toIndex is required.");
- const base = baseClips(s.clips);
- s.moveClip(clip.id, clamp(Math.round(input.toIndex), 0, base.length - 1));
- return { order: baseClips(useEditor.getState().clips).map((c) => c.id) };
+ const row = track0Clips(s.clips);
+ s.moveClip(clip.id, clamp(Math.round(input.toIndex), 0, row.length - 1));
+ return { order: track0Clips(useEditor.getState().clips).map((c) => c.id) };
}
case "place_clip": {
@@ -1486,11 +1486,11 @@ export async function runAiTool(
case "set_transition": {
const clip = requireItem(s.clips, input.clipId, "video clip");
- // Transitions join the base sequence; a layer clip has no next clip.
+ // Transitions join the track-0 sequence; a layer clip has no next clip.
if (clip.track !== 0)
throw new ToolError("That clip is on an overlay track — transitions join timeline (track 0) clips.");
- const base = baseClips(s.clips);
- if (base.findIndex((c) => c.id === clip.id) === base.length - 1)
+ const row = track0Clips(s.clips);
+ if (row.findIndex((c) => c.id === clip.id) === row.length - 1)
throw new ToolError("The last clip has no next clip to transition into.");
if (!isNum(input.seconds)) throw new ToolError("seconds is required (0 clears the transition).");
let style: TransitionStyle | undefined;
@@ -1822,7 +1822,7 @@ function placeAssetOnTimeline(asset: MediaAsset, input: Record<string, unknown>)
return {
id: c.id,
kind: asset.type,
- index: baseClips(useEditor.getState().clips).findIndex((x) => x.id === c.id),
+ index: track0Clips(useEditor.getState().clips).findIndex((x) => x.id === c.id),
start: round2(c.start),
len: round2(c.out - c.in),
};
diff --git a/site/src/cut/lib/exportClient.ts b/site/src/cut/lib/exportClient.ts
index 5aeae8c3..2bb409f3 100644
--- a/site/src/cut/lib/exportClient.ts
+++ b/site/src/cut/lib/exportClient.ts
@@ -127,7 +127,7 @@ export async function deleteExport(projectId: string, file: string) {
export interface ExportDoc {
assets: MediaAsset[];
- /** Every video clip, any track (track 0 = base row, others composite). */
+ /** Every video clip, any track (track 0 folds sequentially, others composite). */
clips: VideoClip[];
audioClips: AudioClip[];
overlays: TextOverlay[];
@@ -152,7 +152,7 @@ async function buildExportForm(
const duration = projectDuration(doc);
const form = new FormData();
const assetById = new Map(doc.assets.map((a) => [a.id, a]));
- // Overlay-only cuts (empty track 0) still export: the base becomes a black bed
+ // Overlay-only cuts (empty track 0) still export: track 0 becomes a black bed
// the length of the project and the overlays/soundtrack composite onto it —
// the same path as a gap before the first track-0 clip. Refuse only a cut with
// no renderable content at all.
diff --git a/site/src/cut/lib/laneTracks.ts b/site/src/cut/lib/laneTracks.ts
index d06a04ce..e68cf148 100644
--- a/site/src/cut/lib/laneTracks.ts
+++ b/site/src/cut/lib/laneTracks.ts
@@ -30,7 +30,7 @@
import type React from "react";
import { refFromAsset, startPointerRefDrag } from "./assetRef";
import { startDrag } from "./drag";
-import { baseClips, clipLen, getClipSpans, overlayLayers, projectDuration, transitionOverlap, useEditor } from "./store";
+import { track0Clips, clipLen, getClipSpans, overlayLayers, projectDuration, transitionOverlap, useEditor } from "./store";
import type {
AudioClip,
MediaAsset,
@@ -42,12 +42,12 @@ import type {
type S = ReturnType<typeof useEditor.getState>;
-// A drag lane. "clip" is the base row (track 0), "overlayClip" a layer track —
+// A drag lane. "clip" is track 0, "overlayClip" a layer track —
// distinct adapters, but both select as a plain video-clip selection.
export type LaneKind = "clip" | "audio" | "text" | "overlayClip" | "cue";
-/** The Selection kind a lane maps to. Base and layer video lanes both select as
- * `"clip"` — a video clip is a video clip whatever track it sits on. */
+/** The Selection kind a lane maps to. Track-0 and layer video lanes both select
+ * as `"clip"` — a video clip is a video clip whatever track it sits on. */
const laneSelectionKind = (kind: LaneKind): NonNullable<Selection>["kind"] =>
kind === "overlayClip" ? "clip" : kind;
@@ -107,7 +107,7 @@ const clipAdapter: LaneAdapter<VideoClip> = {
// Verticality is the video placement system (upper tracks and insert
// zones), fed in as the move gesture's `vertical` strategy.
multiLane: false,
- raws: (s) => baseClips(s.clips),
+ raws: (s) => track0Clips(s.clips),
view: (c) => ({ id: c.id, start: c.start, len: clipLen(c), lane: 0 }),
apply: (patches) => useEditor.getState().updateClipsTransient(patches),
movePatch: (c, start) => ({ id: c.id, patch: { start } }),
diff --git a/site/src/cut/lib/store.ts b/site/src/cut/lib/store.ts
index dd0420c8..9939ac90 100644
--- a/site/src/cut/lib/store.ts
+++ b/site/src/cut/lib/store.ts
@@ -35,18 +35,18 @@ const uid = () => crypto.randomUUID().slice(0, 8);
const MIN_LEN = 0.1;
/** Where a video clip lands when dropped: an existing track or a brand-new
- * track inserted at z-level `level`. Track numbers are signed: track 0 is the
- * base row, positive tracks sit above it (higher = closer to the top), negative
- * tracks sit below it (more negative = further behind). Inserting shifts the
+ * track inserted at z-level `level`. Track numbers are signed: positive tracks
+ * sit above track 0 (higher = closer to the top), negative tracks sit below it
+ * (more negative = further behind). Inserting shifts the
* tracks past `level` (up for positive, down for negative) to open the slot. */
export type VideoTrackPlacement =
| { kind: "track"; track: number }
| { kind: "insert"; level: number };
-/** The base row (track 0) clips — the master sequence that carries transitions
- * and drives playback. */
-export const baseClips = (clips: VideoClip[]) => clips.filter((c) => c.track === 0);
-/** Every video clip not on the base row (track 0) — the composited layers. */
+/** The track-0 clips — the sequence that carries transitions and drives
+ * playback. */
+export const track0Clips = (clips: VideoClip[]) => clips.filter((c) => c.track === 0);
+/** Every video clip not on track 0 — the composited layers. */
export const overlayLayers = (clips: VideoClip[]) => clips.filter((c) => c.track !== 0);
/** Open a slot at a non-zero `level`, moving other clips out of the way: above
@@ -91,9 +91,9 @@ export interface EditorState {
saveState: SaveState;
assets: MediaAsset[];
- /** Every video clip, on any track. Track 0 is the base row (the master
- * sequence); other tracks composite around it (positive above, negative
- * behind). A clip's `track` field is the only thing that places it. */
+ /** Every video clip, on any track. Track 0 carries the transition sequence;
+ * other tracks composite around it (positive above, negative behind). A
+ * clip's `track` field is the only thing that places it. */
clips: VideoClip[];
audioClips: AudioClip[];
overlays: TextOverlay[];
@@ -150,7 +150,7 @@ export interface EditorState {
/** Add a video clip from an asset onto video track 0 — at `start` (sliding
* to the track's next free slot), or appended at the end when omitted. */
addClipFromAsset: (assetId: string, start?: number) => void;
- /** Drop a video/still onto base track 0 at pointer-time `t`: inserts at the
+ /** Drop a video/still onto track 0 at pointer-time `t`: inserts at the
* drop and ripples later clips right, so a drop into a leading gap or between
* clips lands there instead of sliding to the end (the drop gesture's
* placement, distinct from `addClipFromAsset`'s slide-to-end). */
@@ -355,9 +355,9 @@ let laneEpoch = 0;
* own track sound: a live dissolve into the next clip stays a dissolve (the
* run follows the resize so the pair keeps its overlap); otherwise a longer
* footprint pushes the run right by the overflow and a shorter one just opens
- * a gap. Everything is scoped to the clip's track — resizing a base clip never
- * drags the composited layers (or vice versa), so each track's annotations
- * keep the timing they were placed at. One undo step. */
+ * a gap. Everything is scoped to the clip's track — resizing a track-0 clip
+ * never drags the composited layers (or vice versa), so each track's
+ * annotations keep the timing they were placed at. One undo step. */
function resizeClipFootprint(clip: VideoClip, patch: Partial<VideoClip>, newLen: number) {
useEditor.getState().pushHistory();
useEditor.getState().updateClipTransient(clip.id, patch);
@@ -416,18 +416,18 @@ export function footprints(items: (VideoClip | AudioClip)[]): { start: number; e
return items.map((c) => ({ start: c.start, end: c.start + clipLen(c) }));
}
-/** Where a `len`-long clip dropped at pointer-time `t` lands on the base row,
+/** Where a `len`-long clip dropped at pointer-time `t` lands on its row,
* and how the clips after it slide to open room. The drop-at-pointer companion
* to `nextFreeStart` (which only ever appends): clips whose center sits left of
* the drop hold their place; the rest shift right as one run, so a clip dropped
* into a leading gap or between two others inserts there instead of piling up at
* the end when it is longer than the gap. */
-export function rippleInsertBase(
- base: VideoClip[],
+export function rippleInsert(
+ row: VideoClip[],
t: number,
len: number
): { start: number; shifts: { id: string; start: number }[] } {
- const items = base
+ const items = row
.map((c) => ({ id: c.id, start: c.start, len: clipLen(c) }))
.sort((a, b) => a.start - b.start);
const center = t + len / 2;
@@ -625,23 +625,23 @@ export const useEditor = create<EditorState>((set, get) => {
// Older docs stored video track 0 packed (array order implied the
// position); bake explicit starts in once so every clip is free-placed.
const legacy = (doc.clips as LegacyClip[]).some((c) => typeof c.start !== "number");
- const base = (legacy ? packStarts(doc.clips as LegacyClip[]) : doc.clips).map((c) => ({
+ const folded = (legacy ? packStarts(doc.clips as LegacyClip[]) : doc.clips).map((c) => ({
...c,
track: c.track ?? 0,
}));
- // Older docs kept non-base tracks in a separate `overlayClips` array;
+ // Older docs kept tracks other than 0 in a separate `overlayClips` array;
// fold them into the one clip list (each already carries its `track`).
// Entries whose id already sits in `clips` are the same clip persisted
// twice by a version-skewed save (an older engine keeps overlayClips
// after a merged client writes the folded list) — keep the folded copy.
// Entries with track 0 were unreachable dead data under the split shape
// (never rendered, never played); promoting them would insert them into
- // the master sequence, so they stay dropped.
- const seen = new Set(base.map((c) => c.id));
+ // track 0's sequence, so they stay dropped.
+ const seen = new Set(folded.map((c) => c.id));
const legacyLayers = (doc.overlayClips ?? []).filter(
(c) => c.track !== 0 && !seen.has(c.id)
);
- const merged = [...base, ...legacyLayers];
+ const merged = [...folded, ...legacyLayers];
set({
projectName: doc.name,
assets,
@@ -900,13 +900,13 @@ export const useEditor = create<EditorState>((set, get) => {
push();
const out = asset.type === "image" ? IMAGE_CLIP_SECONDS : asset.duration;
const len = Math.max(MIN_LEN, out);
- const base = baseClips(get().clips);
+ const row = track0Clips(get().clips);
// An explicit target time always wins (a drop at the pointer, AI placing
// b-roll against a voiceover). Without one: the first clip on an empty
- // base row anchors at 0 — a lone clip with dead space before it reads as
+ // track 0 anchors at 0 — a lone clip with dead space before it reads as
// broken — and later clips append at the end of the row.
- const want = Math.max(0, start ?? (base.length === 0 ? 0 : totalDuration(get().clips)));
- const taken = footprints(base);
+ const want = Math.max(0, start ?? (row.length === 0 ? 0 : totalDuration(get().clips)));
+ const taken = footprints(row);
const clip: VideoClip = {
id: uid(),
assetId,
@@ -928,7 +928,7 @@ export const useEditor = create<EditorState>((set, get) => {
push();
const out = asset.type === "image" ? IMAGE_CLIP_SECONDS : asset.duration;
const len = Math.max(MIN_LEN, out);
- const { start, shifts } = rippleInsertBase(baseClips(get().clips), Math.max(0, t), len);
+ const { start, shifts } = rippleInsert(track0Clips(get().clips), Math.max(0, t), len);
const move = new Map(shifts.map((sh) => [sh.id, sh.start]));
const clip: VideoClip = { id: uid(), assetId, track: 0, start, in: 0, out, muted: false };
set((s) => ({
@@ -1049,8 +1049,8 @@ export const useEditor = create<EditorState>((set, get) => {
// (and the run behind it, gaps preserved) so it starts `newOverlap`
// before this clip ends — closing any gap, since a dissolve needs
// contact. Clearing one pushes the pair back to a hard cut. Edge styles
- // overlap nothing: they leave the layout alone. Only the base row moves:
- // transitions are a base-sequence concept, and the composited layers
+ // overlap nothing: they leave the layout alone. Only track 0 moves:
+ // transitions live on its sequence, and the composited layers
// stay pinned to the absolute times they annotate.
if (next) {
const oldOverlap = spans[idx].transitionOut;
@@ -1154,14 +1154,14 @@ export const useEditor = create<EditorState>((set, get) => {
// its absolute time, so audio, titles, and captions stay synced to the
// clips they annotate. Pointer drags never come here — they free-place
// through the lane coordinator.
- const base = baseClips(get().clips).sort((a, b) => a.start - b.start);
- const from = base.findIndex((c) => c.id === id);
+ const row = track0Clips(get().clips).sort((a, b) => a.start - b.start);
+ const from = row.findIndex((c) => c.id === id);
if (from < 0) return;
- const to = Math.max(0, Math.min(base.length - 1, toIndex));
+ const to = Math.max(0, Math.min(row.length - 1, toIndex));
if (to === from) return;
push();
- const moved = base[from];
- const others = base.filter((c) => c.id !== id);
+ const moved = row[from];
+ const others = row.filter((c) => c.id !== id);
const len = clipLen(moved);
const anchor = to < others.length ? others[to] : null;
const newStart = anchor ? anchor.start : totalDuration(others);
@@ -1182,7 +1182,7 @@ export const useEditor = create<EditorState>((set, get) => {
const out = asset.type === "image" ? IMAGE_CLIP_SECONDS : asset.duration;
push();
if (place.kind === "track" && place.track === 0) {
- const taken = footprints(baseClips(get().clips));
+ const taken = footprints(track0Clips(get().clips));
const v: VideoClip = {
id: uid(),
assetId,
@@ -1221,12 +1221,12 @@ export const useEditor = create<EditorState>((set, get) => {
if (!src) return;
// No checkpoint here: the lane coordinator's drag gesture already pushed
// one at pointer-down, so the whole move is a single undo step.
- const onBase = src.track === 0;
+ const onTrack0 = src.track === 0;
if (place.kind === "track" && place.track === 0) {
- if (onBase) return; // a same-track move commits through the lane coordinator
- // Drop a layer clip down onto the base row: slide to its next free slot.
- const taken = footprints(baseClips(get().clips));
+ if (onTrack0) return; // a same-track move commits through the lane coordinator
+ // Drop a layer clip down onto track 0: slide to its next free slot.
+ const taken = footprints(track0Clips(get().clips));
const at = nextFreeStart(taken, Math.max(0, start), clipLen(src));
set((st) => ({
clips: st.clips.map((c) =>
@@ -1301,7 +1301,7 @@ export const useEditor = create<EditorState>((set, get) => {
}
}
- // A layer clip (not on the base row) selected: slice it in place. A base
+ // A layer clip (off track 0) selected: slice it in place. A track-0
// clip falls through to the playhead-driven span split below.
if (selection?.kind === "clip") {
const c = get().clips.find((x) => x.id === selection.id);
@@ -1445,7 +1445,7 @@ export const useEditor = create<EditorState>((set, get) => {
if (sp) {
add(sp.start, sp.start + sp.len);
} else {
- // A layer clip carries no span (spans are the base row); use its
+ // A layer clip carries no span (spans are track 0); use its
// own footprint.
const c = s.clips.find((x) => x.id === sel.id);
if (c) {
@@ -1500,7 +1500,7 @@ export const useEditor = create<EditorState>((set, get) => {
if (sp) {
const mi = mediaFor(sp.clip.assetId);
if (mi == null) continue;
- // Base-row clips re-materialize onto track 0 (asClip), so a template
+ // Track-0 clips re-materialize onto track 0 (asClip), so a template
// stands up its own video instead of an empty timeline.
layers.push({ media: mi, start: sp.start - start0, in: sp.clip.in, out: sp.clip.out, frame: sp.clip.frame, fit: sp.clip.fit, muted: sp.clip.muted, speed: sp.clip.speed, track: 1, asClip: true });
} else {
@@ -1583,7 +1583,7 @@ export const useEditor = create<EditorState>((set, get) => {
insertTemplate: (template, assetIds, offset) => {
push();
const usable = template.layers.filter((l) => assetIds[l.media]);
- // Templates saved before the base-track removal persisted `onBase`;
+ // Templates saved by older builds persisted `onBase`;
// read it as asClip so their footage still lands on track 0.
const isClip = (l: (typeof usable)[number]) =>
l.asClip ?? (l as { onBase?: boolean }).onBase;
@@ -1611,8 +1611,8 @@ export const useEditor = create<EditorState>((set, get) => {
// Template layers store `track` as the source track + 1 (so a track-1
// layer saved as 2, a track −1 backdrop as 0). Above-layers stack on top
// of the project's current top; a backdrop (stored ≤ 0) goes back behind
- // the base row at its original negative level — never onto track 0, which
- // would splice it into the master sequence.
+ // track 0 at its original negative level — never onto track 0 itself,
+ // which would splice it into the transition sequence.
const newLayers: VideoClip[] = overlayLayerDefs.map((l) => ({
id: uid(),
assetId: assetIds[l.media],
@@ -1696,7 +1696,7 @@ export const useEditor = create<EditorState>((set, get) => {
const duration = projectDuration(s);
const assetById = new Map(s.assets.map((a) => [a.id, a]));
// Speech can live on the soundtrack or on a layer video track, not just
- // the base row. Layer-clip audio mixes into the transcribe pass as a
+ // track 0. Layer-clip audio mixes into the transcribe pass as a
// positioned source (exactly like a soundtrack clip), so dialogue carried
// on a layer clip gets captioned and a layer-only cut still works.
const audio = s.audioClips
@@ -2359,7 +2359,7 @@ export const useEditor = create<EditorState>((set, get) => {
for (const cb of clipboard) {
if (cb.kind === "clip") {
// Collision is per-track: a clip lands clear of others on its own
- // row (the base row, or its layer).
+ // row only.
const taken = footprints(clips.filter((c) => c.track === cb.item.track));
const clip: VideoClip = {
...cb.item,
@@ -2504,8 +2504,8 @@ export function getClipSpans(
clips: VideoClip[],
assets: MediaAsset[]
): ClipSpan[] {
- // Spans are the base row (track 0): the master sequence that carries
- // transitions and drives playback. Layer clips composite separately.
+ // Spans are track 0: the sequence that carries transitions and drives
+ // playback. Layer clips composite separately.
// Map lookup, not a per-clip assets.find — this runs every playback frame.
const byId = new Map(assets.map((a) => [a.id, a]));
const present = clips
diff --git a/site/src/cut/lib/types.ts b/site/src/cut/lib/types.ts
index 17fb5b85..8db46091 100644
--- a/site/src/cut/lib/types.ts
+++ b/site/src/cut/lib/types.ts
@@ -111,8 +111,8 @@ export function regionLabel(r: FrameRect): string {
export interface VideoClip {
id: string;
assetId: string;
- /** Which video track this clip sits on. Track 0 is the base row — its clips
- * form the master sequence that carries transitions and drives playback.
+ /** Which video track this clip sits on. Track 0's clips form the sequence
+ * that carries transitions and drives playback.
* Positive tracks composite above it (higher = closer to the top and wins
* where clips overlap); negative tracks sit behind as a backdrop. Absent in
* older docs, which are all track 0. */
diff --git a/site/src/cut/server/projects.ts b/site/src/cut/server/projects.ts
index 495d549f..7151a012 100644
--- a/site/src/cut/server/projects.ts
+++ b/site/src/cut/server/projects.ts
@@ -145,13 +145,13 @@ async function dirSize(dir: string): Promise<number> {
}
async function summarize(id: string, doc: ProjectDoc): Promise<ProjectSummary> {
- // The base row (track 0) is the cut: layer clips composite over it, so they
- // add nothing to the summary's duration, count, or poster. Legacy docs carry
- // no `track` on clips — those are all base-row.
- const base = doc.clips.filter((c) => (c.track ?? 0) === 0);
- const duration = base.reduce((sum, c) => sum + Math.max(0, c.out - c.in), 0);
+ // Track 0 is the cut: layer clips composite over it, so they add nothing to
+ // the summary's duration, count, or poster. Legacy docs carry no `track` on
+ // clips — those are all track 0.
+ const track0 = doc.clips.filter((c) => (c.track ?? 0) === 0);
+ const duration = track0.reduce((sum, c) => sum + Math.max(0, c.out - c.in), 0);
// Preview: the first clip's source video, else any video asset.
- const firstClip = base[0];
+ const firstClip = track0[0];
const firstClipAsset = firstClip
? doc.assets.find((a) => a.id === firstClip.assetId)
: undefined;
@@ -169,7 +169,7 @@ async function summarize(id: string, doc: ProjectDoc): Promise<ProjectSummary> {
createdAt: doc.createdAt,
updatedAt: doc.updatedAt,
duration,
- clipCount: base.length,
+ clipCount: track0.length,
assetCount: doc.assets.length,
previewFile: previewAsset?.fileName,
previewIsImage: previewAsset?.type === "image",