AI media harness for planning, generating, and editing locally
TypeScript
Add Timeline Motions tab
Bitticfd3f115c3c1
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex c10ebf8..155ebba 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -24,6 +24,7 @@ Changes since 0.3.2.- Improved video playback, thumbnails and Back navigation.- Video folders stack vertically beside video cards in grid view.- The Timeline scene list browses video folders and videos, with Back as the first item inside each.+- A dedicated Timeline Motions tab creates empty Motions and browses existing ones for dragging onto tracks.- Timeline preview selection follows the clip's displayed bounds, with correct move and resize gestures for portrait projects.- Clicking empty space in the video or music library clears the selection.- Image edits preserve their sources and settings. Generator lists and inspector controls are more compact and consistently ordered.diff --git a/src/components/workspace/TimelineView.test.tsx b/src/components/workspace/TimelineView.test.tsxindex 77d73b6..a0ed93a 100644--- a/src/components/workspace/TimelineView.test.tsx+++ b/src/components/workspace/TimelineView.test.tsx@@ -10,9 +10,11 @@ import completeFixture from "../../../fixtures/project-v1-complete.json";import { createProjectConfig, parseProjectConfig, STORY_TRACK_ID, type ProjectAsset, type ProjectConfig, type TimelineClip } from "../../lib/project";import { TimelineView } from "./TimelineView";import { newVideo } from "../../lib/videoLibrary";+import { emptyMotion, MOTION_MIME } from "../../lib/motion";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));+vi.mock("./MotionCanvas", () => ({ MotionCanvas: () => <canvas aria-label="Motion preview" /> }));afterEach(() => {cleanup();@@ -316,7 +318,7 @@ describe("the media and scene panels", () => {it("keeps imported media in Media and lists Generator scenes even before generation", () => {const config = withClip(projectWithMedia(), { durationMs: 5_000 });const { container } = render_(config);- expect(screen.getByRole("tablist", { name: "Scenes and media" })).toBeTruthy();+ expect(screen.getByRole("tablist", { name: "Scenes, media and motions" })).toBeTruthy();expect(container.querySelector(".scene-list")!.textContent).toContain("First scene");expect(container.querySelector(".scene-list")!.textContent).not.toContain("Macro footage");expect(container.querySelector(".scene-card__thumb")).not.toBeNull();@@ -1083,10 +1085,18 @@ describe("measuring media", () => {});-it("creates an empty inline Motion and places it on an unlocked video track", () => {+it.each(["Add Motion", "New Motion"])("creates an empty Motion from %s in the Motions tab and places it on a video track", (action) => {const config = projectWithMedia();const { onChange } = render_(config);- fireEvent.click(screen.getByRole("button", { name: "Add Motion" }));+ const tabs = screen.getByRole("tablist", { name: "Scenes, media and motions" });+ expect(within(tabs).getAllByRole("tab").map((tab) => tab.textContent)).toEqual(["Scenes", "Media", "Motions"]);+ expect(screen.queryByRole("button", { name: "Add Motion" })).toBeNull();+ fireEvent.click(screen.getByRole("tab", { name: "Media" }));+ expect(screen.queryByRole("button", { name: "Add Motion" })).toBeNull();+ fireEvent.click(screen.getByRole("tab", { name: "Motions" }));+ expect(screen.getByText("No motions yet")).toBeTruthy();+ expect(screen.queryByRole("button", { name: "Import" })).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: action }));const update = onChange.mock.calls.at(-1)![0];const next = typeof update === "function" ? update(config) : update;const motion = next.assets.find((asset: ProjectAsset) => asset.kind === "motion")!;@@ -1094,4 +1104,34 @@ it("creates an empty inline Motion and places it on an unlocked video track", ()expect(motion.motion.source).toContain("export function update");expect(motion.relativePath).toBeUndefined();expect(next.timeline.tracks.flatMap((track: ProjectConfig["timeline"]["tracks"][number]) => track.clips).some((clip: TimelineClip) => clip.assetId === motion.id)).toBe(true);+ expect(screen.getByRole("tab", { name: "Motions" }).getAttribute("aria-selected")).toBe("true");+});++it.each(["Grid", "List"])("browses placed and unused Motions in %s view and drags them onto the timeline", (layout) => {+ const config = projectWithMedia();+ const motions: ProjectAsset[] = ["Placed Motion", "Unused Motion"].map((name, index) => ({+ id: `motion-${index}`, name, kind: "motion", mimeType: MOTION_MIME, motion: emptyMotion(), durationMs: 5000, createdAt: config.createdAt,+ }));+ config.assets.push(...motions);+ config.timeline.tracks[0].clips = [{ id: "placed-motion", assetId: motions[0].id, trackId: config.timeline.tracks[0].id,+ startMs: 0, durationMs: 5000, sourceStartMs: 0, label: motions[0].name, status: "approved" }];+ const { container, onChange } = render_(config);+ fireEvent.click(screen.getByRole("tab", { name: "Media" }));+ expect(cardFor(motions[0])).toBeNull();+ expect(cardFor(motions[1])).toBeNull();+ fireEvent.click(screen.getByRole("tab", { name: "Motions" }));+ fireEvent.click(screen.getByRole("button", { name: layout }));+ const panel = screen.getByRole("tabpanel", { name: "Motions" });+ expect(panel.classList.contains(`media-grid--${layout.toLowerCase()}`)).toBe(true);+ expect(within(panel).getByText("Placed Motion")).toBeTruthy();+ expect(within(panel).getByText("Unused Motion")).toBeTruthy();+ expect(within(panel).queryByText("Macro footage")).toBeNull();+ const dataTransfer = fakeDataTransfer();+ fireEvent.dragStart(cardFor(motions[1]), { dataTransfer });+ expect(dataTransfer.getData("application/x-slopus-asset")).toBe(motions[1].id);+ fireEvent.drop(laneAt(container, 1), { dataTransfer });+ const next = wrote(onChange.mock.calls.at(-1)![0], config);+ expect(next.assets).toEqual(config.assets);+ expect(next.timeline.tracks[1].clips[0]).toMatchObject({ assetId: motions[1].id, durationMs: 5000, label: "Unused Motion" });+ expect(parseProjectConfig(next)).toBeTruthy();});diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsxindex bf3e68b..6bde8dc 100644--- a/src/components/workspace/TimelineView.tsx+++ b/src/components/workspace/TimelineView.tsx@@ -235,7 +235,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {const [playing, setPlaying] = useState(false);/* Shuttle speed: 1, 2, 4 forward or −1, −2, −4 in reverse (J/K/L). */const [rate, setRate] = useState(1);- const [panelTab, setPanelTab] = useState<"scenes" | "media">("scenes");+ const [panelTab, setPanelTab] = useState<"scenes" | "media" | "motions">("scenes");const [sceneLocation, setSceneLocation] = useState<{ kind: "folder" | "video"; id: string } | null>(() => {const owner = config.videos?.find((video) => video.sceneIds.includes(openSceneId ?? ""));return owner ? { kind: "video", id: owner.id } : null;@@ -339,7 +339,9 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {* asked for, however little of it is cut yet). */const contentEndMs = tracks.reduce((end, track) => track.clips.reduce((furthest, clip) => Math.max(furthest, clipEndMs(clip)), end), 0);const duration = useMemo(() => canvasDuration(config), [config]);- const mediaAssets = useMemo(() => config.assets.filter((asset) => asset.kind !== "generated"), [config.assets]);+ const mediaAssets = useMemo(() => config.assets.filter((asset) => asset.kind !== "generated" && asset.kind !== "motion"), [config.assets]);+ const motionAssets = useMemo(() => config.assets.filter((asset) => asset.kind === "motion"), [config.assets]);+ const sourceAssets = panelTab === "motions" ? motionAssets : mediaAssets;const assetsById = useMemo(() => new Map(config.assets.map((asset) => [asset.id, asset])), [config.assets]);const generatedJobsByAssetId = useMemo(() => new Map(config.generationJobs.map((job) => [generationAssetId(job.id), job]),@@ -1160,7 +1162,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {const item: TimelineClip = { id: clipId, assetId: id, trackId: track.id, label: asset.name, startMs: start, durationMs: 5000, sourceStartMs: 0, status: "approved" };onChange((current) => ({ ...current, assets: [...current.assets, asset], timeline: { ...current.timeline,tracks: current.timeline.tracks.map((t) => t.id === track.id ? { ...t, clips: [...t.clips, item] } : t) } }));- setSelectedId(clipId); setMotionNodeId(null); setMediaSelectedId(id); setPanelTab("media"); setPlayhead(start);+ setSelectedId(clipId); setMotionNodeId(null); setMediaSelectedId(id); setPanelTab("motions"); setPlayhead(start);};const addScene = () => {if (sceneVideo) {@@ -1348,28 +1350,27 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {no landmark for it. Sighted users already see the title bar. */}<h1 className="sr-only">Timeline editor</h1><div className={panelsClass}>- {sourcesOpen && <aside className="scene-panel" aria-label="Scenes and media">- {/* One toolbar for both views: the views lead, the actions trail, and- the content below starts at the same height on either tab. */}+ {sourcesOpen && <aside className="scene-panel" aria-label="Scenes, media and motions">+ {/* One toolbar for the source views: the views lead, the actions trail, and+ each tab supplies its own actions. */}<PaneHeaderclassName="scene-panel__toolbar"views={<SelectorBarcompact- aria-label="Scenes and media"+ aria-label="Scenes, media and motions"value={panelTab}onChange={setPanelTab}- items={[{ value: "scenes", label: "Scenes" }, { value: "media", label: "Media" }]}+ items={[{ value: "scenes", label: "Scenes" }, { value: "media", label: "Media" }, { value: "motions", label: "Motions" }]}/>}actions={<>- <button type="button" className="scene-panel__import" aria-label="Add Motion" onClick={() => addMotion()} {...tooltipProps("Add empty Motion")}><Sparkle16 /><span className="sr-only">Add Motion</span></button>- <button+ {panelTab === "motions" ? <button type="button" className="scene-panel__import" aria-label="Add Motion" onClick={() => addMotion()} {...tooltipProps("Add empty Motion")}><Sparkle16 /><span className="sr-only">Add Motion</span></button> : <buttontype="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")}- ><Import16 aria-hidden="true" /><span className="sr-only">Import</span></button>- {panelTab === "media" && <div className="scene-panel__layout" role="group" aria-label="Media layout">+ ><Import16 aria-hidden="true" /><span className="sr-only">Import</span></button>}+ {panelTab !== "scenes" && <div className="scene-panel__layout" role="group" aria-label={panelTab === "motions" ? "Motions layout" : "Media layout"}><buttontype="button"className="ui-toggle-button scene-panel__toggle"@@ -1445,14 +1446,14 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {{(sceneVideo || !sceneFolder) && <button className="secondary-button scene-add" onClick={addScene}><Add16 /> Add scene</button>}</div>) : (- <div className={`media-grid media-grid--${mediaLayout}`} role="tabpanel" aria-label="Media">+ <div className={`media-grid media-grid--${mediaLayout}`} role="tabpanel" aria-label={panelTab === "motions" ? "Motions" : "Media"}>{/* Draggable onto the timeline. `draggable` on a <button> is thewhole mechanism — the button still clicks and still takesfocus, so keyboard users are not shut out of selecting it.Removing a file is Delete on the focused card, or its contextmenu: no × on every card. The selected card is the one Deleteacts on — the focused one, or the last one clicked. */}- {mediaAssets.map((asset) => <div className="media-card" key={asset.id}>+ {sourceAssets.map((asset) => <div className="media-card" key={asset.id}><buttonclassName={`media-card__source ui-selectable ui-selectable--card${asset.id === mediaSelectedId ? " is-selected" : ""}`}draggable@@ -1480,7 +1481,12 @@ 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+ {panelTab === "motions" && motionAssets.length === 0 && <EmptyState+ className="media-grid__empty" icon={<Sparkle16 />} title="No motions yet"+ description="Create a Motion, then drag it onto a video track to use it."+ action={<button type="button" className="secondary-button" onClick={() => addMotion()}><Add16 aria-hidden="true" />New Motion</button>}+ />}+ {panelTab === "media" && mediaAssets.length === 0 && !importError && <EmptyStateclassName="media-grid__empty"icon={<Film32 />}title="No media yet"diff --git a/src/styles/timeline.css b/src/styles/timeline.cssindex 8510430..9343eb8 100644--- a/src/styles/timeline.css+++ b/src/styles/timeline.css@@ -84,7 +84,10 @@height (--command-row) and their 32px, 14px controls. */.scene-panel__toolbar {- height: var(--command-row);+ height: auto;+ min-height: var(--command-row);+ flex-wrap: wrap;+ padding-block: var(--space-1);}.scene-panel__toolbar .ui-selector-bar--compact {@@ -92,14 +95,14 @@}.scene-panel__toolbar .ui-selector-bar--compact .ui-selector-bar__item {- padding: 0 var(--space-3);+ padding: 0 var(--space-2);font-size: var(--text-base);line-height: var(--leading-normal);}/* Icon-only, like the layout toggles beside it, so it never crowds the- Scenes / Media switch; the name is in an .sr-only span and the tooltip. */+ source tabs; the name is in an .sr-only span and the tooltip. */.scene-panel__import {width: var(--control-md);height: var(--control-md);