Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add remove action to Video header

Bittid49fe21e4857
diff --git a/src/components/workspace/VideoLibraryView.test.tsx b/src/components/workspace/VideoLibraryView.test.tsx
index 88eb484..e02b6df 100644
--- a/src/components/workspace/VideoLibraryView.test.tsx
+++ b/src/components/workspace/VideoLibraryView.test.tsx
@@ -103,11 +103,12 @@ it("restores the open video after leaving the tab, respects Back and lets scene
switchTab(); switchTab(); expect(screen.getByLabelText("Scenes editor")).toHaveTextContent("b");
});
-it("removes folders without deleting their videos and removes video scenes without removing timeline media", async () => {
+it.each(["menu", "header"])("removes folders without deleting their videos and removes video scenes from the %s without removing timeline media", async (action) => {
const config = project(); config.videoFolders = [{ id: "folder", name: "Collection" }]; config.videos = [{ ...newVideo("folder"), title: "Film", sceneIds: ["a"] }]; config.generationJobs = [createDraftGenerationJob("A", { id: "a" })];
const view = mount(config); fireEvent.contextMenu(screen.getByRole("button", { name: "Open Collection" })); fireEvent.click(screen.getByRole("menuitem", { name: "Remove folder" }));
expect(view.config().videoFolders).toHaveLength(0); expect(screen.getByRole("button", { name: "Select Film" })).toBeInTheDocument();
- fireEvent.contextMenu(screen.getByRole("button", { name: "Select Film" })); fireEvent.click(screen.getByRole("menuitem", { name: "Remove video" }));
+ if (action === "header") fireEvent.click(screen.getByRole("button", { name: "Remove video Film" }));
+ else { fireEvent.contextMenu(screen.getByRole("button", { name: "Select Film" })); fireEvent.click(screen.getByRole("menuitem", { name: "Remove video" })); }
await waitFor(() => expect(view.config().videos).toHaveLength(0)); expect(view.config().generationJobs).toHaveLength(0); expect(view.config().timeline).toEqual(config.timeline);
});
diff --git a/src/components/workspace/VideoLibraryView.tsx b/src/components/workspace/VideoLibraryView.tsx
index 2ce2d83..9eab6c7 100644
--- a/src/components/workspace/VideoLibraryView.tsx
+++ b/src/components/workspace/VideoLibraryView.tsx
@@ -151,7 +151,9 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {
<aside className="music-inspector" aria-label="Video settings">
{selected && <ItemHeader color="var(--clip-generated)" icon={<Film16 />}
name={<h2 className="generator-panel__name"><input ref={titleInput} className="ui-item-header__input" aria-label="Video title" aria-keyshortcuts="F2" maxLength={200} value={selected.title} onChange={(event) => edit({ title: event.target.value || "New video" })} /></h2>}
- meta={`${videoScenes(selected, config).length} scenes · ${videoScenes(selected, config).reduce((seconds, scene) => seconds + sceneDurationSeconds(scene), 0).toFixed(1)} s`} />}
+ meta={`${videoScenes(selected, config).length} scenes · ${videoScenes(selected, config).reduce((seconds, scene) => seconds + sceneDurationSeconds(scene), 0).toFixed(1)} s`}
+ actions={<button type="button" className="icon-button" aria-label={`Remove video ${selected.title}`} data-tooltip="Remove video"
+ disabled={videoScenes(selected, config).some(sceneGenerationPending)} onClick={() => { void remove(selected); }}><Delete16 aria-hidden="true" /></button>} />}
<div className="music-inspector__fields">{selected ? <>
<PropSection title="Video">
<div className="music-prompt"><span>Shared prompt</span><PromptTextField aria-label="Video prompt" rows={5} value={selected.prompt} references={citableReferences(config.references).map((reference) => ({ id: reference.id, name: reference.name, mediaTypes: referenceMediaTypes(reference), detail: referenceTypeLabel(reference) }))} placeholder="Visual style and references for every scene…" onChange={(prompt) => edit({ prompt: prompt.slice(0, 30000) })} /></div>