Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Inspector: clip item header, section summaries, effect hierarchy, empty state

Bitti5c58b6050d53
diff --git a/src/components/workspace/ClipEffects.tsx b/src/components/workspace/ClipEffects.tsx
index 93f37a3..28fd44c 100644
--- a/src/components/workspace/ClipEffects.tsx
+++ b/src/components/workspace/ClipEffects.tsx
@@ -1,4 +1,4 @@
-import { ChevronRight, Ellipsis, FolderOpen, Plus, RotateCcw } from "lucide-react";
+import { ChevronDown, Ellipsis, FolderOpen, Plus, RotateCcw } from "lucide-react";
import { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
import { DEFAULT_CLIP_CHROMA_KEY, DEFAULT_CLIP_LOOK, type TimelineClip } from "../../lib/project";
import { isEffectOn, parseCube } from "../../lib/effectSettings";
@@ -174,6 +174,20 @@ const EFFECTS: readonly EffectDefinition[] = [
},
];
+/** How many effects a clip carries, and how many of them are switched on —
+ * the inspector's section summary and the fx badge on the timeline clip. */
+export function clipEffectCount(clip: TimelineClip): { total: number; on: number } {
+ let total = 0;
+ let on = 0;
+ for (const effect of EFFECTS) {
+ const settings = clip[effect.id] as { enabled?: boolean | null } | null | undefined;
+ if (!settings) continue;
+ total += 1;
+ if (isEffectOn(settings)) on += 1;
+ }
+ return { total, on };
+}
+
/* Each effect is an Expander-style block with a 32px header — the bypass
checkbox, chevron and name, Reset, and a ⋯ menu — the way Premiere's
Effect Controls and Clipchamp's effect panel stack them. Unticking the
@@ -204,7 +218,7 @@ function EffectBlock({ effect, clip, disabled, update, onRemove }: {
<Checkbox className="clip-effect__bypass" checked={on} disabled={disabled} aria-label={`${effect.name} on`}
{...tooltipProps(on ? "Turn off (bypass)" : "Turn on")} onChange={bypass} />
<button type="button" className="clip-effect__toggle" aria-expanded={open} onClick={() => setOpen((value) => !value)}>
- <ChevronRight size={12} aria-hidden="true" className="clip-effect__chevron" />
+ <ChevronDown size={12} aria-hidden="true" className="clip-effect__chevron" />
<h3 className="clip-effect__name">{effect.name}</h3>
</button>
<button type="button" className="clip-effect__action" aria-label={`Reset ${effect.name}`} {...tooltipProps("Reset")} disabled={disabled} onClick={reset}>
diff --git a/src/components/workspace/TimelineView.test.tsx b/src/components/workspace/TimelineView.test.tsx
index 1bc68da..1d8f36a 100644
--- a/src/components/workspace/TimelineView.test.tsx
+++ b/src/components/workspace/TimelineView.test.tsx
@@ -451,6 +451,13 @@ describe("the clip inspector", () => {
const heading = screen.getByRole("heading", { name: "Macro footage" });
const name = within(heading).getByRole("textbox", { name: "Clip name" });
expect((name as HTMLInputElement).value).toBe("Macro footage");
+ // The clip heads the pane: no "Inspector" title, a kind chip and a meta line.
+ const header = container.querySelector(".clip-inspector .ui-item-header") as HTMLElement;
+ expect(header.contains(name)).toBe(true);
+ expect(header.querySelector(".ui-item-header__chip")).not.toBeNull();
+ expect(header.querySelector(".ui-item-header__meta")!.textContent).toBe("Video · V1 · 40.0 s");
+ expect(within(container.querySelector(".clip-inspector") as HTMLElement).queryByText("Inspector")).toBeNull();
+ expect(screen.getByRole("button", { name: /Timing/ }).textContent).toContain("00:00 → 40:00");
// "Starts at" is text, not a read-only field.
const starts = screen.getByText("Starts at").closest(".ui-prop-row")!;
expect(starts.querySelector("input")).toBeNull();
@@ -468,6 +475,7 @@ describe("the clip inspector", () => {
it("resets a transform value from its row", () => {
const config = withClip(measuredVideo(projectWithMedia(), 40_000), { transform: { scale: 150, rotation: 0, positionX: 0, positionY: 0 } });
const { onChange } = render_(config);
+ expect(screen.getByRole("button", { name: /Transform/ }).textContent).toContain("1 changed");
fireEvent.click(screen.getByRole("button", { name: "Reset Scale" }));
expect(wrote(onChange.mock.calls[0][0], config).timeline.tracks.flatMap((track) => track.clips)[0].transform?.scale).toBe(100);
});
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index 7f1d1c2..08dcd27 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -1,7 +1,7 @@
-import { ClipEffects } from "./ClipEffects";
+import { clipEffectCount, ClipEffects } from "./ClipEffects";
import {
- ChevronFirst, ChevronLast, Clapperboard, Copy, Film, LayoutGrid, List, Lock, LockOpen,
- PanelLeft, PanelRight, Pause, Play, Plus, Scan, Scissors, StepBack, StepForward, Trash2, Upload,
+ AudioLines, ChevronFirst, ChevronLast, Clapperboard, Copy, Ellipsis, Film, Image as ImageIcon, LayoutGrid, List, Lock, LockOpen,
+ MousePointerClick, PanelLeft, PanelRight, Pause, Play, Plus, Scan, Scissors, Sparkles, StepBack, StepForward, Trash2, Type, Upload,
Volume2, VolumeX, ZoomIn, ZoomOut,
} from "lucide-react";
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type MutableRefObject } from "react";
@@ -26,7 +26,7 @@ import {
} from "../../lib/timeline";
import { useShortcut } from "../../lib/commands";
import {
- ComboBox, EmptyState, PaneHeader, PropRow, PropSection, SelectorBar, Slider, Splitter, tooltipProps, useContextMenu, usePaneSize,
+ ComboBox, EmptyState, ItemHeader, PaneHeader, PropRow, PropSection, SelectorBar, Slider, Splitter, tooltipProps, useContextMenu, usePaneSize,
type MenuEntry,
} from "../ui";
import { MediaThumbnail, type MeasuredMedia } from "./MediaThumbnail";
@@ -73,6 +73,27 @@ const DRAG_THRESHOLD_PX = 3;
/* J/L shuttle speeds: each further press doubles, up to 4×. */
const SHUTTLE_SPEEDS = [1, 2, 4];
+/* --- Clip kinds ---------------------------------------------------------------
+ Five kinds, each with one colour and one glyph wherever it appears: the
+ clip's title strip, the track chip, the inspector's kind chip. The kind is
+ the MEDIA's; a clip whose file is missing takes its track's. */
+type ClipKind = "video" | "generated" | "image" | "audio" | "caption";
+const CLIP_KINDS: Record<ClipKind, { label: string; color: string; icon: React.ReactNode; glyph: React.ReactNode }> = {
+ video: { label: "Video", color: "var(--clip-video)", icon: <Film size={16} />, glyph: <Film size={12} aria-hidden="true" /> },
+ generated: { label: "Generated video", color: "var(--clip-generated)", icon: <Sparkles size={16} />, glyph: <Sparkles size={12} aria-hidden="true" /> },
+ image: { label: "Still image", color: "var(--clip-image)", icon: <ImageIcon size={16} />, glyph: <ImageIcon size={12} aria-hidden="true" /> },
+ audio: { label: "Audio", color: "var(--clip-audio)", icon: <AudioLines size={16} />, glyph: <AudioLines size={12} aria-hidden="true" /> },
+ caption: { label: "Caption", color: "var(--clip-caption)", icon: <Type size={16} />, glyph: <Type size={12} aria-hidden="true" /> },
+};
+const trackKindOf = (track: TimelineTrack): ClipKind => track.kind === "audio" ? "audio" : track.kind === "caption" ? "caption" : "video";
+const clipKindOf = (asset: ProjectAsset | undefined, track: TimelineTrack): ClipKind => asset?.kind ?? trackKindOf(track);
+
+/** A timecode without its empty leading groups — "12:08" for 00:00:12:08 —
+ * for a summary that has to fit beside a section title. */
+const shortTimecode = (ms: number, fps: number) => formatTimecode(ms, fps).replace(/^(00:){1,2}/, "");
+
+const TRANSFORM_DEFAULTS = { scale: 100, rotation: 0, positionX: 0, positionY: 0 } as const;
+
type DragMode = "move" | "trim-start" | "trim-end";
type MonitorZoom = "fit" | "50" | "100";
@@ -255,6 +276,13 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
const selectedTrack = tracks.find((track) => track.id === selected?.trackId);
const selectedMediaAsset = config.assets.find((asset) => asset.id === selected?.assetId);
const selectedTransform = selected ? clipTransform(selected) : null;
+ const selectedKind = selected && selectedTrack ? clipKindOf(selectedMediaAsset, selectedTrack) : null;
+ /* Section summaries: how many transform values are off their defaults, and
+ how many effects the clip carries. */
+ const transformChanges = selectedTransform
+ ? (Object.keys(TRANSFORM_DEFAULTS) as (keyof typeof TRANSFORM_DEFAULTS)[]).filter((key) => selectedTransform[key] !== TRANSFORM_DEFAULTS[key]).length
+ : 0;
+ const selectedEffects = selected ? clipEffectCount(selected) : { total: 0, on: 0 };
const visualControlsDisabled = selectedMediaAsset?.kind === "audio" || selectedTrack?.kind !== "video" || selectedTrack.locked;
const clipCount = tracks.reduce((total, track) => total + track.clips.length, 0);
/** Where the last clip ends — where playback stops, which is not the same as
@@ -1298,18 +1326,33 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
{inspectorOpen && <Splitter {...inspectorPane.splitterProps} reverse className="edit-panels__splitter" aria-label="Resize inspector" />}
{inspectorOpen && <aside className="clip-inspector" aria-label="Clip inspector">
- {selected ? <>
- <div className="inspector-title">
- <h3 aria-label={selected.label}><input
+ {selected && selectedKind ? <>
+ {/* The selected clip heads the pane: its kind, its name (editable
+ in place, and still the pane's heading for a screen reader),
+ and where it sits. */}
+ <ItemHeader
+ className="clip-inspector__header"
+ color={CLIP_KINDS[selectedKind].color}
+ icon={CLIP_KINDS[selectedKind].icon}
+ name={<h2 className="clip-inspector__heading" aria-label={selected.label}><input
ref={clipNameRef}
- className="clip-title__name"
+ className="ui-item-header__input"
value={selected.label}
aria-label="Clip name"
{...tooltipProps("Rename", "F2")}
onChange={(event) => updateClip(selected.id, { label: event.target.value || "Untitled clip" }, `label:${selected.id}`)}
- /></h3>
- </div>
- <PropSection title="Timing" persistKey="timeline.clip.timing">
+ /></h2>}
+ meta={`${CLIP_KINDS[selectedKind].label} · ${trackLabels.get(selected.trackId) ?? ""} · ${(selected.durationMs / 1000).toFixed(1)} s`}
+ actions={<button
+ type="button"
+ className="icon-button clip-inspector__more"
+ aria-label={`${selected.label} actions`}
+ aria-haspopup="menu"
+ {...tooltipProps("More options")}
+ onClick={(event) => menu.open(event.currentTarget, clipMenuItems(selected), { "aria-label": `${selected.label} actions`, placement: "bottom-end", focusFirst: true })}
+ ><Ellipsis size={16} aria-hidden="true" /></button>}
+ />
+ <PropSection title="Timing" persistKey="timeline.clip.timing" summary={`${shortTimecode(selected.startMs, fps)} → ${shortTimecode(clipEndMs(selected), fps)}`}>
<PropRow label="Starts at"><span className="inspector-value">{formatTimecode(selected.startMs, fps)}</span></PropRow>
<PropRow label="Duration" htmlFor="clip-duration">
<input
@@ -1323,7 +1366,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
/>
</PropRow>
</PropSection>
- <PropSection title="Transform" persistKey="timeline.clip.transform">
+ <PropSection title="Transform" persistKey="timeline.clip.transform" summary={transformChanges > 0 ? `${transformChanges} changed` : undefined}>
{([
["scale", "Scale", "%", 100],
["rotation", "Rotation", "°", 0],
@@ -1346,12 +1389,17 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
</PropRow>;
})}
</PropSection>
- <PropSection title="Effects" persistKey="timeline.clip.effects">
+ <PropSection title="Effects" persistKey="timeline.clip.effects" summary={selectedEffects.total > 0 ? selectedEffects.on < selectedEffects.total ? `${selectedEffects.total} · ${selectedEffects.total - selectedEffects.on} off` : String(selectedEffects.total) : undefined}>
<ClipEffects clip={selected} disabled={visualControlsDisabled} onChange={(patch, key) => updateClip(selected.id, patch, key && `effect:${selected.id}:${key}`)} />
</PropSection>
- </> : <div className="inspector-empty">
- <span>{clipCount === 0 ? "Nothing on the timeline yet" : "No clip selected"}</span>
- </div>}
+ </> : <EmptyState
+ className="inspector-empty"
+ icon={<MousePointerClick />}
+ title={clipCount === 0 ? "Nothing on the timeline yet" : "No clip selected"}
+ description={clipCount === 0
+ ? "Drag media or a scene onto a track, then select the clip to edit it here."
+ : "Select a clip on the timeline, or click the picture, to edit its timing, transform and effects."}
+ />}
</aside>}
</div>
diff --git a/src/styles/timeline.css b/src/styles/timeline.css
index 30b1d3c..a93d508 100644
--- a/src/styles/timeline.css
+++ b/src/styles/timeline.css
@@ -646,42 +646,37 @@
PropSection / PropRow: 28px rows, 12px labels that scrub, reset on the right.
No 40px stacked fields, no spin buttons. */
-.inspector-title {
- padding: var(--space-2) var(--space-2) var(--space-1);
- border-bottom: 1px solid var(--line);
+/* The clip heads the pane (ItemHeader). The name field sits inside a heading
+ so the pane still has one; the heading itself adds nothing to the look. */
+.clip-inspector {
+ display: flex;
+ flex-direction: column;
}
-.inspector-title h3 {
- margin: 0;
- font-size: var(--text-sm);
- font-weight: var(--weight-semibold);
- line-height: var(--leading-snug);
+.clip-inspector__header {
+ position: sticky;
+ top: 0;
+ z-index: 2;
}
-/* An editable field that reads as the heading it replaced until it is used. */
-.clip-inspector .clip-title__name {
- width: 100%;
+.clip-inspector__heading {
+ flex: 1;
min-width: 0;
- height: var(--control-sm);
- padding: 0 var(--space-1);
- border: 1px solid transparent;
- border-radius: var(--radius-sm);
- color: var(--text-primary);
- background: none;
+ display: flex;
+ margin: 0;
font: inherit;
}
-.clip-inspector .clip-title__name:hover {
- background: var(--fill-subtle-hover);
-}
-
-.clip-inspector .clip-title__name:focus {
- border-color: var(--stroke-control);
+.clip-inspector__heading .ui-item-header__input:focus {
border-bottom-color: var(--field-focus-line);
- background: var(--fill-input-focus);
outline: none;
}
+.clip-inspector__more.icon-button {
+ width: var(--control-sm);
+ height: var(--control-sm);
+}
+
.inspector-value {
color: var(--text-primary);
font-size: var(--text-xs);
@@ -706,14 +701,8 @@
font-size: var(--text-xs);
}
-.inspector-empty {
- min-height: 160px;
- display: grid;
- place-items: center;
- padding: var(--space-4);
- text-align: center;
- color: var(--text-muted);
- font-size: var(--text-xs);
+.inspector-empty.ui-empty-state {
+ flex: 1;
}
/* --- Effects (ClipEffects) -----------------------------------------------------
@@ -757,20 +746,24 @@
.clip-effect__toggle:hover { background: var(--fill-subtle-hover); }
+/* The same chevron as the section above it: down when open, pointing at the
+ name when closed. */
.clip-effect__chevron {
flex: none;
color: var(--text-secondary);
+ transform: rotate(-90deg);
transition: transform var(--motion-normal) var(--ease-decelerate);
}
-.clip-effect--open .clip-effect__chevron { transform: rotate(90deg); }
+.clip-effect--open .clip-effect__chevron { transform: none; }
+/* Semibold, so an effect's name outranks its parameter rows. */
.clip-effect__name {
min-width: 0;
margin: 0;
overflow: hidden;
font-size: var(--text-xs);
- font-weight: var(--weight-regular);
+ font-weight: var(--weight-semibold);
line-height: var(--leading-snug);
text-overflow: ellipsis;
white-space: nowrap;
@@ -820,7 +813,7 @@
}
.clip-effect__body .ui-prop-row {
- grid-template-columns: 84px minmax(0, 1fr) 20px;
+ grid-template-columns: var(--prop-label) minmax(0, 1fr) 20px;
}
.clip-effect__body .ui-slider,
@@ -859,7 +852,7 @@
.clip-effect__note {
margin: 0;
- padding-left: 88px;
+ padding-left: calc(var(--prop-label) + var(--space-2));
color: var(--text-muted);
font-size: var(--text-xs);
line-height: var(--leading-snug);