Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Sources pane: one toolbar, selected scene and media cards, media empty state

Bitti7a3d7b4747f5
diff --git a/src/components/workspace/TimelineView.test.tsx b/src/components/workspace/TimelineView.test.tsx
index 3146735..7066f1b 100644
--- a/src/components/workspace/TimelineView.test.tsx
+++ b/src/components/workspace/TimelineView.test.tsx
@@ -247,6 +247,26 @@ describe("the media and scene panels", () => {
expect(within(media).getByText("Room tone")).not.toBeNull();
});
+ it("heads both views with one toolbar, marks the open scene and the chosen media card, and says when there is no media", () => {
+ const config = projectWithMedia();
+ const job = config.generationJobs[0];
+ const { container } = render(createElement(TimelineView, { config, folderPath: "C:\\Ceramic Lamp", onChange: vi.fn(), onOpenGenerator: () => undefined, openSceneId: job.id }));
+ expect(container.querySelectorAll(".scene-panel .ui-pane-header")).toHaveLength(1);
+ expect(container.querySelector(".scene-panel .ui-pane-header__title")).toBeNull();
+ const scene = container.querySelector(`[data-scene-id="${job.id}"]`)!;
+ expect(scene.classList.contains("is-selected")).toBe(true);
+ expect(scene.querySelector(".scene-card__status")).not.toBeNull();
+ fireEvent.click(screen.getByRole("tab", { name: "Media" }));
+ expect(screen.getByRole("button", { name: "Grid" }).getAttribute("aria-pressed")).toBe("true");
+ fireEvent.focus(cardFor(config.assets[1]));
+ expect(cardFor(config.assets[1]).classList.contains("is-selected")).toBe(true);
+ expect(cardFor(config.assets[0]).classList.contains("is-selected")).toBe(false);
+ cleanup();
+ mediaPanel(parseProjectConfig({ ...config, assets: [] }));
+ expect(screen.getByText("No media yet")).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Import media" })).toBeTruthy();
+ });
+
it("offers Add scene as a plain button that opens the unstarted draft", () => {
const opened = vi.fn();
const config = projectWithMedia();
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index 522f2de..ea79c7b 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -1,6 +1,6 @@
import { ClipEffects } from "./ClipEffects";
import {
- ChevronFirst, ChevronLast, Copy, Film, Layers3, LayoutGrid, List, Lock, LockOpen,
+ ChevronFirst, ChevronLast, Copy, Film, LayoutGrid, List, Lock, LockOpen,
PanelLeft, PanelRight, Pause, Play, Plus, Scissors, StepBack, StepForward, Trash2, Upload,
Volume2, VolumeX, ZoomIn, ZoomOut,
} from "lucide-react";
@@ -26,12 +26,12 @@ import {
} from "../../lib/timeline";
import { useShortcut } from "../../lib/commands";
import {
- ComboBox, PropRow, PropSection, SelectorBar, Slider, Splitter, tooltipProps, useContextMenu, usePaneSize,
+ ComboBox, EmptyState, PaneHeader, PropRow, PropSection, SelectorBar, Slider, Splitter, tooltipProps, useContextMenu, usePaneSize,
type MenuEntry,
} from "../ui";
import { MediaThumbnail, type MeasuredMedia } from "./MediaThumbnail";
import { ProgramMonitor } from "./ProgramMonitor";
-import { sceneShape, STATUS_WORD } from "./sceneStatus";
+import { sceneShape, STATUS_BADGE } from "./sceneStatus";
import { ShotThumbnail } from "./ShotThumbnail";
import { CommittedNumberInput } from "./CommittedNumberInput";
import { TimelineClipThumbnails } from "./TimelineClipThumbnails";
@@ -164,7 +164,7 @@ interface TrackActions {
dropLane: (event: React.DragEvent<HTMLDivElement>, track: TimelineTrack) => void;
}
-export function TimelineView({ config, folderPath, generationCompletionTimes = {}, onChange, onMeasured, onOpenGenerator }: {
+export function TimelineView({ config, folderPath, generationCompletionTimes = {}, onChange, onMeasured, onOpenGenerator, openSceneId }: {
config: ProjectConfig;
folderPath: string;
generationCompletionTimes?: Readonly<Record<string, number>>;
@@ -177,6 +177,8 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
* Omitted, measurements go back through onChange like any other change. */
onMeasured?: (update: (current: ProjectConfig) => ProjectConfig) => void;
onOpenGenerator: (jobId?: string) => void;
+ /** The scene the Generator has open, marked selected in the Scenes list. */
+ openSceneId?: string;
}) {
const firstClip = config.timeline.tracks.flatMap((track) => track.clips)[0];
const fps = config.settings.frameRate;
@@ -190,6 +192,9 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
names. Which one a cutter wants is a habit, not a per-project choice, so
it is remembered on this machine rather than written into the project. */
const [mediaLayout, setMediaLayout] = useState<MediaLayout>(loadMediaLayout);
+ /* The media card Delete would act on: the focused one, or the last one
+ clicked or right-clicked. */
+ const [mediaSelectedId, setMediaSelectedId] = useState<string | null>(null);
const viewRef = useRef<HTMLDivElement>(null);
const scrollRef = useRef<HTMLDivElement>(null);
const rulerRef = useRef<HTMLDivElement>(null);
@@ -1085,38 +1090,43 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
<h1 className="sr-only">Timeline editor</h1>
<div className={panelsClass}>
{sourcesOpen && <aside className="scene-panel" aria-label="Scenes and media">
- <SelectorBar
- className="panel-tabs"
- aria-label="Scenes and media"
- value={panelTab}
- onChange={setPanelTab}
- items={[
- { value: "scenes", label: "Scenes", icon: <Layers3 size={16} /> },
- { value: "media", label: "Media", icon: <Film size={16} /> },
- ]}
- />
- {panelTab === "media" && <div className="scene-panel__head">
- <button
- className="secondary-button media-import-button"
- onClick={() => void importMedia()}
- disabled={importing || !isTauri()}
- {...tooltipProps(isTauri() ? "Add video, sound or image files. Video and sound stay where they are; images are copied in." : "Importing files is available in the desktop app")}
- ><Upload size={16} /> Import</button>
- <div className="layout-toggle" role="group" aria-label="Media layout">
- <button
- className={mediaLayout === "grid" ? "active" : ""}
- aria-pressed={mediaLayout === "grid"}
- onClick={() => chooseMediaLayout("grid")}
- {...tooltipProps("Grid")}
- ><LayoutGrid size={16} /><span className="sr-only">Grid</span></button>
+ {/* One toolbar for both views: the views lead, the actions trail, and
+ the content below starts at the same height on either tab. */}
+ <PaneHeader
+ className="scene-panel__toolbar"
+ views={<SelectorBar
+ compact
+ aria-label="Scenes and media"
+ value={panelTab}
+ onChange={setPanelTab}
+ items={[{ value: "scenes", label: "Scenes" }, { value: "media", label: "Media" }]}
+ />}
+ actions={<>
<button
- className={mediaLayout === "list" ? "active" : ""}
- aria-pressed={mediaLayout === "list"}
- onClick={() => chooseMediaLayout("list")}
- {...tooltipProps("List")}
- ><List size={16} /><span className="sr-only">List</span></button>
- </div>
- </div>}
+ type="button"
+ className="scene-panel__import"
+ onClick={() => void importMedia()}
+ disabled={importing || !isTauri()}
+ {...tooltipProps(isTauri() ? "Add video, sound or image files. Video and sound stay where they are; images are copied in." : "Importing files is available in the desktop app")}
+ ><Upload size={16} aria-hidden="true" /> Import</button>
+ {panelTab === "media" && <div className="scene-panel__layout" role="group" aria-label="Media layout">
+ <button
+ type="button"
+ className="ui-toggle-button scene-panel__toggle"
+ aria-pressed={mediaLayout === "grid"}
+ onClick={() => chooseMediaLayout("grid")}
+ {...tooltipProps("Grid")}
+ ><LayoutGrid size={16} aria-hidden="true" /><span className="sr-only">Grid</span></button>
+ <button
+ type="button"
+ className="ui-toggle-button scene-panel__toggle"
+ aria-pressed={mediaLayout === "list"}
+ onClick={() => chooseMediaLayout("list")}
+ {...tooltipProps("List")}
+ ><List size={16} aria-hidden="true" /><span className="sr-only">List</span></button>
+ </div>}
+ </>}
+ />
{panelTab === "scenes" ? (
<div className="scene-list" role="tabpanel" aria-label="Scenes">
{config.generationJobs.map((job, index) => {
@@ -1125,11 +1135,13 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
...config.assets.filter((asset) => job.outputRelativePath && asset.relativePath === job.outputRelativePath).map((asset) => asset.id),
]);
const placements = tracks.flatMap((track) => track.clips).filter((clip) => clip.id === job.clipId || assetIds.has(clip.assetId)).length;
+ const open = job.id === openSceneId;
return <button
key={job.id}
- className="scene-card"
+ className={`scene-card ui-selectable ui-selectable--separated${open ? " is-selected" : ""}`}
draggable
data-scene-id={job.id}
+ aria-current={open ? "true" : undefined}
onClick={() => onOpenGenerator(job.id)}
onContextMenu={(event) => menu.open(event, [
{ label: "Open in Generator", onSelect: () => onOpenGenerator(job.id) },
@@ -1141,14 +1153,19 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
setDraggedAsset(undefined);
}}
onDragEnd={() => { setDraggedScene(undefined); setDropTrackId(null); }}
- {...tooltipProps(`${job.title}. Drag onto a track to use it.`)}
+ {...tooltipProps(`${job.title} · ${sceneShape(job)}. Drag onto a track to use it.`)}
>
<span className="scene-card__thumb">
{job.status !== "draft" ? <ShotThumbnail folderPath={folderPath} job={job} seconds={0} shotNumber={1} estimatedCompletionAt={generationCompletionTimes[job.id] ?? null} />
: <Film size={20} aria-hidden="true" />}
<i>{String(index + 1).padStart(2, "0")}</i><em>{sceneDurationSeconds(job).toFixed(1)}s</em>
</span>
- <span><b>{job.title}</b><small>{STATUS_WORD[job.status]}{placements > 0 ? ` · ${placements} on timeline` : ""}</small><small>{sceneShape(job)}</small></span>
+ <span>
+ <b>{job.title}</b>
+ {/* A status dot before the word; the scene's shape (length,
+ shots) moved into the tooltip. */}
+ <small><span className={`scene-card__status scene-card__status--${job.status}`}>{STATUS_BADGE[job.status]}</span>{placements > 0 ? ` · ${placements} on timeline` : ""}</small>
+ </span>
</button>;
})}
<button className="secondary-button scene-add" onClick={addScene}><Plus size={16} /> Add scene</button>
@@ -1159,12 +1176,15 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
whole mechanism — the button still clicks and still takes
focus, so keyboard users are not shut out of selecting it.
Removing a file is Delete on the focused card, or its context
- menu: no × on every card. */}
+ menu: no × on every card. The selected card is the one Delete
+ acts on — the focused one, or the last one clicked. */}
{mediaAssets.map((asset) => <div className="media-card" key={asset.id}>
<button
- className="media-card__source"
+ className={`media-card__source ui-selectable ui-selectable--card${asset.id === mediaSelectedId ? " is-selected" : ""}`}
draggable
data-asset-id={asset.id}
+ onFocus={() => setMediaSelectedId(asset.id)}
+ onClick={() => setMediaSelectedId(asset.id)}
onDragStart={(event) => {
event.dataTransfer.setData(ASSET_DRAG_TYPE, asset.id);
event.dataTransfer.effectAllowed = "copy";
@@ -1172,9 +1192,12 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
setDraggedScene(undefined);
}}
onDragEnd={() => { setDraggedAsset(undefined); setDropTrackId(null); }}
- onContextMenu={(event) => menu.open(event, [
- { label: "Remove from project", icon: <Trash2 size={16} />, shortcut: "Delete", danger: true, onSelect: () => removeMediaAsset(asset.id) },
- ], { "aria-label": `${asset.name} actions` })}
+ onContextMenu={(event) => {
+ setMediaSelectedId(asset.id);
+ menu.open(event, [
+ { label: "Remove from project", icon: <Trash2 size={16} />, shortcut: "Delete", danger: true, onSelect: () => removeMediaAsset(asset.id) },
+ ], { "aria-label": `${asset.name} actions` });
+ }}
{...tooltipProps(`${asset.name}. Drag onto a track to use it.`)}
>
<MediaThumbnail folderPath={folderPath} asset={asset} onMeasured={(measured) => recordMeasured(asset.id, measured)} />
@@ -1183,6 +1206,19 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
<small>{asset.kind}{asset.durationMs ? ` · ${(asset.durationMs / 1000).toFixed(1)}s` : ""}</small>
</button>
</div>)}
+ {mediaAssets.length === 0 && !importError && <EmptyState
+ className="media-grid__empty"
+ icon={<Film />}
+ title="No media yet"
+ description="Import video, sound or images, then drag them onto a track."
+ action={<button
+ type="button"
+ className="secondary-button"
+ onClick={() => void importMedia()}
+ disabled={importing || !isTauri()}
+ {...tooltipProps(isTauri() ? undefined : "Importing files is available in the desktop app")}
+ ><Upload size={16} aria-hidden="true" /> Import media</button>}
+ />}
{importError && <p className="panel-hint panel-hint--error" role="alert">{importError}</p>}
</div>
)}
diff --git a/src/styles/timeline.css b/src/styles/timeline.css
index 3aabfd8..1f3c81a 100644
--- a/src/styles/timeline.css
+++ b/src/styles/timeline.css
@@ -69,46 +69,58 @@
overflow-y: auto;
}
-/* --- Panel tabs ------------------------------------------------------------
- A SelectorBar: text tabs with the 3×16px accent pill under the chosen one. */
+/* --- Sources toolbar ---------------------------------------------------------
+ One PaneHeader for both views: Scenes / Media as a compact segmented
+ control, Import and (on Media) the grid/list toggle on the trailing edge. */
-.panel-tabs {
- height: 32px;
+.scene-panel__import {
+ height: var(--control-sm);
flex: none;
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-1);
padding: 0 var(--space-2);
- border-bottom: 1px solid var(--line);
-}
-
-.panel-tabs .ui-selector-bar__item {
- min-height: 0;
- height: 100%;
- font-size: var(--text-xs);
+ border: 0;
border-radius: var(--radius-sm);
+ color: var(--text-primary);
+ background: transparent;
+ font-size: var(--text-xs);
+ line-height: var(--leading-snug);
+ transition: var(--transition-control);
}
-/* --- Scene panel ----------------------------------------------------------- */
+.scene-panel__import:hover:not(:disabled) { background: var(--fill-subtle-hover); }
+.scene-panel__import:active:not(:disabled) { background: var(--fill-subtle-pressed); }
+.scene-panel__import:disabled { color: var(--text-disabled); }
-.scene-panel__head {
- height: 36px;
- flex: none;
+.scene-panel__layout {
display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 var(--space-2);
+ gap: 2px;
}
-.media-import-button.secondary-button {
- min-height: var(--control-sm);
+/* Icon-only, so each button carries its name in an .sr-only span. The on
+ state is the shared accent tint (.ui-toggle-button[aria-pressed]). */
+.scene-panel__toggle {
+ width: var(--control-sm);
height: var(--control-sm);
- gap: var(--space-2);
- padding: 0 var(--space-2);
- font-size: var(--text-xs);
+ display: grid;
+ place-items: center;
+ padding: 0;
+ border: 0;
+ border-radius: var(--radius-sm);
+ color: var(--text-secondary);
+ background: transparent;
+ transition: var(--transition-control);
}
+.scene-panel__toggle:hover { background: var(--fill-subtle-hover); }
+
+/* --- Scene panel ----------------------------------------------------------- */
+
.scene-list {
flex: 1 1 auto;
min-height: 0;
- padding: var(--space-1) var(--space-2) var(--space-3);
+ padding: 0 0 var(--space-3);
overflow-y: auto;
}
@@ -119,6 +131,9 @@
line-height: var(--leading-snug);
}
+/* A row in a separated list (.ui-selectable--separated): transparent at rest,
+ a hairline under it, the accent pill when it is the scene the Generator
+ has open. No background of its own, or the shared states would lose. */
.scene-card {
width: 100%;
min-height: 64px;
@@ -126,17 +141,14 @@
grid-template-columns: 88px minmax(0, 1fr);
gap: var(--space-2);
align-items: center;
- margin-bottom: 2px;
- padding: var(--space-1);
+ padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
border: 0;
- border-radius: var(--radius-sm);
+ border-bottom: 1px solid var(--line);
+ border-radius: 0;
text-align: left;
color: var(--text-muted);
- background: transparent;
- transition: var(--transition-control);
}
-.scene-card:hover { background: var(--fill-subtle-hover); }
.scene-card:active { background: var(--fill-subtle-pressed); }
/* Flat placeholder with a glyph: no hatching, no invented art. */
@@ -220,39 +232,31 @@
white-space: nowrap;
}
-.scene-add.secondary-button {
- width: 100%;
- margin-top: var(--space-2);
- gap: var(--space-2);
-}
-
-/* --- Panel layout toggle ---------------------------------------------------
- Grid or list for the media panel. Icon-only, so each button carries its name
- for screen readers in an .sr-only span. */
-
-.layout-toggle {
- display: flex;
- gap: 2px;
+/* The status word with a dot before it, coloured by where the scene is. */
+.scene-card__status {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-1);
}
-.layout-toggle button {
- width: var(--control-sm);
- height: var(--control-sm);
- display: grid;
- place-items: center;
- padding: 0;
- border: 0;
- border-radius: var(--radius-sm);
- color: var(--text-secondary);
- background: none;
- transition: var(--transition-control);
+.scene-card__status::before {
+ content: "";
+ width: 6px;
+ height: 6px;
+ flex: none;
+ border-radius: var(--radius-pill);
+ background: var(--text-faint);
}
-.layout-toggle button:hover { background: var(--fill-subtle-hover); }
+.scene-card__status--generating::before,
+.scene-card__status--ready::before { background: var(--accent); }
+.scene-card__status--completed::before { background: var(--success); }
+.scene-card__status--failed::before { background: var(--danger); }
-.layout-toggle button.active {
- color: var(--text-primary);
- background: var(--fill-subtle-pressed);
+.scene-add.secondary-button {
+ width: calc(100% - 2 * var(--space-2));
+ margin: var(--space-2) var(--space-2) 0;
+ gap: var(--space-2);
}
/* --- Media panel ----------------------------------------------------------- */
@@ -268,14 +272,23 @@
grid-auto-rows: max-content;
align-content: start;
gap: var(--space-2);
- padding: 0 var(--space-2) var(--space-3);
+ padding: var(--space-2) var(--space-2) var(--space-3);
}
-.media-grid .panel-hint {
+.media-grid .panel-hint,
+.media-grid__empty {
grid-column: 1 / -1;
}
-.media-grid .media-card__source {
+.media-grid:has(> .media-grid__empty) {
+ height: 100%;
+ padding-top: 0;
+}
+
+/* A card (.ui-selectable--card): the rest state is set with single-class
+ selectors (or :where) so the shared hover and selected states — an accent
+ ring on the card's own edge — still win. */
+.media-card__source {
min-width: 0;
min-height: var(--control-sm);
padding: 0 0 var(--space-1);
@@ -284,11 +297,6 @@
border-radius: var(--radius-sm);
text-align: left;
background: var(--card);
- transition: var(--transition-control);
-}
-
-.media-grid .media-card__source:hover:not(:disabled) {
- background: var(--card-hover);
}
.media-grid .media-card__source b,
@@ -360,12 +368,11 @@
align-content: center;
column-gap: var(--space-2);
padding: 0;
- border-color: transparent;
- background: transparent;
}
-.media-grid--list .media-card__source:hover:not(:disabled) {
- background: var(--fill-subtle-hover);
+:where(.media-grid--list) .media-card__source {
+ border-color: transparent;
+ background: transparent;
}
.media-grid--list .media-thumb {