AI media harness for planning, generating, and editing locally
TypeScript
Deselect media on empty library clicks
Bittiacefec226b3f
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex a8c4bf7..3ebf2dc 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -22,6 +22,7 @@ Changes since 0.3.2.## Fixes and improvements- Improved video playback, thumbnails and Back navigation.+- 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.- Corrected First/Last Frame prompts, cached VAE checks across restarts and fixed AppImage launcher permissions.diff --git a/src/components/workspace/MusicView.test.tsx b/src/components/workspace/MusicView.test.tsxindex b2585e4..40256dd 100644--- a/src/components/workspace/MusicView.test.tsx+++ b/src/components/workspace/MusicView.test.tsx@@ -29,6 +29,31 @@ beforeEach(() => {vi.stubGlobal("URL", Object.assign(URL, { revokeObjectURL: vi.fn() }));});+it.each(["Grid", "List"])("clears song selection on empty %s space and allows selecting again", (mode) => {+ const songs = [{ ...newSong(), title: "First" }, { ...newSong(), title: "Second" }];+ render(<Harness initial={{ ...createConfig(), musicSongs: songs }} />);+ fireEvent.click(screen.getByRole("button", { name: `${mode} view` }));+ const first = screen.getByRole("button", { name: "Select First" });+ const second = screen.getByRole("button", { name: "Select Second" });+ for (const surface of [screen.getByLabelText("Music library"), screen.getByRole("list", { name: "Music contents" }), within(screen.getByLabelText("Music library")).getByText("2 songs")]) {+ fireEvent.click(second.querySelector("strong")!);+ fireEvent.click(screen.getByLabelText("Song title"));+ expect(second).toHaveAttribute("aria-pressed", "true");+ fireEvent.click(surface);+ expect(first).toHaveAttribute("aria-pressed", "false");+ expect(second).toHaveAttribute("aria-pressed", "false");+ expect(screen.queryByLabelText("Song title")).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Generate" })).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: `${mode} view` }));+ expect(screen.getByText("Select a song to edit its lyrics, style and generation settings.")).toBeInTheDocument();+ }+ fireEvent.click(first);+ fireEvent.click(screen.getByRole("button", { name: "New folder" }));+ fireEvent.click(screen.getByLabelText("Folder name"));+ expect(first).toHaveAttribute("aria-pressed", "true");+ expect(screen.getByLabelText("Song title")).toHaveValue("First");+});+it("generates artwork for the context-menu song and displays saved covers in both views", async () => {const songs = [{ ...newSong(), title: "First" }, { ...newSong(), title: "Second", coverRelativePath: "media/generated/cover.jpg" }];render(<Harness initial={{ ...createConfig(), musicSongs: songs }} />);diff --git a/src/components/workspace/MusicView.tsx b/src/components/workspace/MusicView.tsxindex 9f6a13e..16dd194 100644--- a/src/components/workspace/MusicView.tsx+++ b/src/components/workspace/MusicView.tsx@@ -47,9 +47,10 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerateconst [creatingFolder, setCreatingFolder] = useState(false);const [folderName, setFolderName] = useState("");const [dropFolder, setDropFolder] = useState<string>();- const [selectedId, setSelectedId] = useState(config.musicSongs?.[0]?.id);+ // null explicitly clears selection; undefined keeps the initial first-item fallback.+ const [selectedId, setSelectedId] = useState<string | null | undefined>(config.musicSongs?.[0]?.id);useEffect(() => { if (openSong) { setFolderId(config.musicSongs?.find((song) => song.id === openSong.id)?.folderId ?? null); setSelectedId(openSong.id); onSongOpened?.(); } }, [openSong]);- const selected = visibleSongs.find((song) => song.id === selectedId) ?? visibleSongs[0];+ const selected = selectedId === null ? undefined : visibleSongs.find((song) => song.id === selectedId) ?? visibleSongs[0];const activeGeneratorId = useSyncExternalStore(subscribeActiveGenerators, () => loadActiveGeneratorId("music"));const chosenTemplate = selectedGeneratorTemplate("music", loadGeneratorTemplateSettings(), activeGeneratorId);const template = templates.find((item) => item.id === chosenTemplate.id) ?? templates[0];@@ -245,6 +246,7 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerate</div><div className="music-body"><div className="music-library" tabIndex={0} aria-label="Music library"+ onClick={(event) => { if (!(event.target as Element).closest(".music-song, button, form")) setSelectedId(null); }}onContextMenu={(event) => { if (!(event.target as HTMLElement).closest("input, textarea")) folderContext(event, currentFolderId); }}onKeyDown={(event) => { if (event.target === event.currentTarget && (event.key === "ContextMenu" || event.shiftKey && event.key === "F10")) folderContext(event, currentFolderId); }}><div className="music-library__heading">@@ -328,7 +330,7 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerate{activeWork ? <button type="button" className="primary-button" disabled={activeWork.cancelling || activeWork.status === "encoding"} onClick={() => onCancel(activeWork.id)}><Stop14 aria-hidden="true" />{activeWork.cancelling ? "Cancelling…" : "Cancel"}</button> :<button type="button" className="primary-button" data-tooltip={generatorStatus.state !== "ready" ? generatorStatus.detail : undefined} disabled={!ready || !isTauri() || !selected.style.trim()} onClick={generate}><Sparkle16 aria-hidden="true" />Generate</button>}</div>- </> : <p className="music-inspector__empty">Add a song to edit its lyrics, style and generation settings.</p>}+ </> : <p className="music-inspector__empty">{visibleSongs.length ? "Select a song to edit its lyrics, style and generation settings." : "Add a song to edit its lyrics, style and generation settings."}</p>}</aside>{error && <InfoBar className="music-error" severity="error" title="Couldn’t update music" message={error} onClose={() => setError(null)} />}{(activeWork || selected?.error) && <div className="music-generation-status" role={selected?.error ? "alert" : "status"}>diff --git a/src/components/workspace/VideoLibraryView.test.tsx b/src/components/workspace/VideoLibraryView.test.tsxindex 77c737d..12443f2 100644--- a/src/components/workspace/VideoLibraryView.test.tsx+++ b/src/components/workspace/VideoLibraryView.test.tsx@@ -37,6 +37,32 @@ function mount(config = project(), openScene?: { id: string }) {return { ...render(<Harness />), config: () => latest };}+it.each(["Grid", "List"])("clears video selection on empty %s space and allows selecting again", (mode) => {+ const config = project();+ config.videos = [{ ...newVideo(null), title: "First" }, { ...newVideo(null), title: "Second" }];+ mount(config);+ fireEvent.click(screen.getByRole("button", { name: `${mode} view` }));+ const first = screen.getByRole("button", { name: "Select First" });+ const second = screen.getByRole("button", { name: "Select Second" });+ for (const surface of [screen.getByLabelText("Video library"), screen.getByRole("list", { name: "Video contents" }), screen.getByText("2 videos")]) {+ fireEvent.click(second.querySelector("strong")!);+ fireEvent.click(screen.getByLabelText("Video title"));+ expect(second).toHaveAttribute("aria-pressed", "true");+ fireEvent.click(surface);+ expect(first).toHaveAttribute("aria-pressed", "false");+ expect(second).toHaveAttribute("aria-pressed", "false");+ expect(screen.queryByLabelText("Video title")).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Edit Scenes" })).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: `${mode} view` }));+ expect(screen.getByText("Select a video to edit its settings.")).toBeInTheDocument();+ }+ fireEvent.click(first);+ fireEvent.click(screen.getByRole("button", { name: "New folder" }));+ fireEvent.click(screen.getByLabelText("Folder name"));+ expect(first).toHaveAttribute("aria-pressed", "true");+ expect(screen.getByLabelText("Video title")).toHaveValue("First");+});+it("creates nested folders and videos, moves cards to a folder, and opens only that video's scenes", () => {const config = project(); config.generationJobs = [createDraftGenerationJob("Existing", { id: "legacy" })]; const view = mount(config);fireEvent.click(screen.getByRole("button", { name: "New folder" })); fireEvent.change(screen.getByRole("textbox", { name: "Folder name" }), { target: { value: "Album" } }); fireEvent.click(screen.getByRole("button", { name: "Create folder" }));diff --git a/src/components/workspace/VideoLibraryView.tsx b/src/components/workspace/VideoLibraryView.tsxindex 394b177..4bc3818 100644--- a/src/components/workspace/VideoLibraryView.tsx+++ b/src/components/workspace/VideoLibraryView.tsx@@ -27,7 +27,8 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {const latest = useRef(config); latest.current = config;const videos = videoLibrary(config), folders = config.videoFolders ?? [];const [folderId, setFolderId] = useState<string | null>(() => videos.find((video) => video.id === props.initialOpenVideoId)?.folderId ?? null);- const [selectedId, setSelectedId] = useState<string | undefined>(props.initialOpenVideoId);+ // null explicitly clears selection; undefined keeps the initial first-item fallback.+ const [selectedId, setSelectedId] = useState<string | null | undefined>(props.initialOpenVideoId);const [openId, setOpenId] = useState<string | undefined>(props.initialOpenVideoId);const [playback, setPlayback] = useState<{ id: string; popout: boolean }>();const [creatingFolder, setCreatingFolder] = useState(false), [folderName, setFolderName] = useState("");@@ -36,7 +37,7 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {const menu = useContextMenu();const currentFolder = folders.find((folder) => folder.id === folderId), currentFolderId = currentFolder?.id ?? null;const visible = videos.filter((video) => (video.folderId ?? null) === currentFolderId);- const selected = visible.find((video) => video.id === selectedId) ?? visible[0];+ const selected = selectedId === null ? undefined : visible.find((video) => video.id === selectedId) ?? visible[0];const selectedSettings = videoSettings(selected, config);const resolutionLabel = (resolution: Resolution) => { const size = outputDimensions(resolution, selectedSettings.aspectRatio); return `${size.width} × ${size.height}`; };const open = videos.find((video) => video.id === openId);@@ -113,7 +114,9 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {</CommandBar><div className="video-library-body"><div className="video-library-stage">- <div className="music-library" aria-label="Video library" tabIndex={0} onContextMenu={(event) => { if (!(event.target as HTMLElement).closest("input, textarea")) menu.open(event, newItems()); }}>+ <div className="music-library" aria-label="Video library" tabIndex={0}+ onClick={(event) => { if (!(event.target as Element).closest(".music-song, button, form")) setSelectedId(null); }}+ onContextMenu={(event) => { if (!(event.target as HTMLElement).closest("input, textarea")) menu.open(event, newItems()); }}><div className="music-library__heading"><nav aria-label="Video path"><h2 className="music-path">{breadcrumbs.map((folder, index) => <span key={folder.id ?? "root"}>{index > 0 && <span className="music-path__separator">/</span>}<button type="button" aria-current={folder.id === currentFolderId ? "page" : undefined} onClick={() => browse(folder.id)} {...dropProps(folder.id)}>{folder.name}</button></span>)}</h2></nav><span>{visible.length} videos</span></div>{creatingFolder && <form className="music-new-folder" onSubmit={(event) => { event.preventDefault(); if (!folderName.trim()) return; const folder = newMusicFolder(folderName, currentFolderId); update((current) => ({ ...current, videoFolders: [...(current.videoFolders ?? []), folder] })); browse(folder.id); }}><input className="text-field" aria-label="Folder name" maxLength={200} autoFocus value={folderName} onChange={(event) => setFolderName(event.target.value)} />