AI media harness for planning, generating, and editing locally
TypeScript
Add music generation variation count
Bitti8e3c91bf5e16
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex cd93731..a43b9e2 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -4,6 +4,7 @@ Changes since 0.3.2.## What's new+- **Song variations:** Duplicate a song into a draft with the same title, lyrics, style and settings. Use Generate's dropdown to queue up to 100 variations with different seeds.- **Image generators:** MOSS Image, Fibo 2.0 Base/Edit Turbo, and Krea 2 Turbo/Raw, with model-specific guidance, negative prompts and editing controls.- **Music:** YuE2 and MiniMax Music3 generation, folders, drafts, continuous playback and timeline audio. Export WAV, MP3, FLAC, AAC/M4A or Opus/WebM/Ogg.- **Album covers:** Generate artwork from a song’s context menu or the AI agent using a dedicated generator selected under Settings → Generators → Icons. The playback bar shows the current song’s cover, with a music-note placeholder when absent.diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsxindex 315cb6d..0084430 100644--- a/src/components/ProjectWorkspace.tsx+++ b/src/components/ProjectWorkspace.tsx@@ -309,7 +309,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,if (["timeline", "generator", "export"].includes(view) && event.target instanceof Element && !event.target.closest(".music-view")) notifyPreviewPlayback();}}>{musicVisited && <div hidden={view !== "music"} style={{ height: "100%", display: view === "music" ? "block" : "none" }}>- <MusicView active={view === "music"} onPlayingChange={setMusicPlaying} openSong={musicNavigation} onSongOpened={() => setMusicNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(id, template) => queue.enqueueMusic(session, id, template)} onGenerateCover={(id) => queue.enqueueAlbumCover(session, id)} onCancel={(id) => void queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "music" || item.kind === "album-cover")} />+ <MusicView active={view === "music"} onPlayingChange={setMusicPlaying} openSong={musicNavigation} onSongOpened={() => setMusicNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(id, template, count) => queue.enqueueMusic(session, id, template, count)} onGenerateCover={(id) => queue.enqueueAlbumCover(session, id)} onCancel={(id) => void queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "music" || item.kind === "album-cover")} /></div>}{view === "editor" && <ImageEditor onBackNavigationChange={setBackNavigation} openImage={imageNavigation} onImageOpened={() => setImageNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template, count) => queue.enqueueImage(session, template, count)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onGenerateExtend={(template, sourceId, options) => queue.enqueueExtendImage(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setVideoNavigation(jobId ? { id: jobId } : undefined); setView("generator"); }} onOpenReferences={() => setView("references")} />}{view === "timeline" && <TimelineView config={config} openSceneId={selectedGenerationJobId} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} onChange={changeConfig} onMeasured={recordMeasurement} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setVideoNavigation(jobId ? { id: jobId } : undefined); setView("generator"); }} />}diff --git a/src/components/workspace/MusicView.test.tsx b/src/components/workspace/MusicView.test.tsxindex 24a1e33..32d2a7a 100644--- a/src/components/workspace/MusicView.test.tsx+++ b/src/components/workspace/MusicView.test.tsx@@ -107,6 +107,39 @@ it.each(["Grid", "List"])("duplicates the context-menu song as a selected draftexpect(generate).not.toHaveBeenCalled();});+it("selects a song variation count, validates it and resets after generating", () => {+ const song = { ...newSong(), style: "Jazz" };+ render(<Harness initial={{ ...createConfig(), musicSongs: [song] }} />);+ const options = screen.getByRole("button", { name: "Generation options" });+ fireEvent.click(options);+ const input = screen.getByRole("spinbutton", { name: "Count" });+ expect(input).toHaveFocus();+ for (const value of ["", "0", "1.5", "101"]) {+ fireEvent.change(input, { target: { value } });+ expect(input).toHaveAttribute("aria-invalid", "true");+ expect(screen.getByRole("button", { name: "Generate" })).toBeDisabled();+ expect(options).toBeEnabled();+ }+ fireEvent.change(input, { target: { value: "3" } });+ fireEvent.click(options);+ fireEvent.click(screen.getByRole("button", { name: "Generate (3)" }));+ expect(generate).toHaveBeenCalledWith(song.id, expect.objectContaining({ id: "yue2" }), 3);+ expect(screen.queryByRole("dialog", { name: "Generation options" })).not.toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Generate" })).toBeEnabled();+ fireEvent.click(options);+ expect(screen.getByRole("spinbutton", { name: "Count" })).toHaveValue(1);+});++it("keeps the variation count when generation cannot be queued", () => {+ generate.mockImplementationOnce(() => { throw new Error("Cannot queue music"); });+ render(<Harness initial={{ ...createConfig(), musicSongs: [{ ...newSong(), style: "Jazz" }] }} />);+ fireEvent.click(screen.getByRole("button", { name: "Generation options" }));+ fireEvent.change(screen.getByRole("spinbutton", { name: "Count" }), { target: { value: "4" } });+ fireEvent.click(screen.getByRole("button", { name: "Generate (4)" }));+ expect(screen.getByText("Error: Cannot queue music")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Generate (4)" })).toBeEnabled();+});+it("reports missing cover generators without changing the song", () => {const song = newSong();generateCover.mockImplementationOnce(() => { throw new Error("Choose an album cover generator in Settings."); });@@ -284,7 +317,7 @@ it("adds songs, edits lyrics and style, switches layout and queues the selectedfireEvent.click(screen.getByRole("button", { name: "List view" }));expect(screen.getByRole("list", { name: "Music contents" })).toHaveClass("music-songs--list");fireEvent.click(screen.getByRole("button", { name: "Generate" }));- expect(generate).toHaveBeenCalledWith(latest.musicSongs![0].id, expect.objectContaining({ modelType: "yue2" }));+ expect(generate).toHaveBeenCalledWith(latest.musicSongs![0].id, expect.objectContaining({ modelType: "yue2" }), 1);});it("shows missing downloads in the shared selector and status bar, outside the inspector", () => {@@ -348,7 +381,7 @@ it.each([expect(latest.musicSongs![1]).toMatchObject({ id: draft.id, style: "Acoustic folk with strings", settings: { lyrics: "Keep writing" } });expect(latest.assets).toEqual([asset]);fireEvent.click(screen.getByRole("button", { name: "Generate" }));- expect(generate).toHaveBeenCalledWith(draft.id, expect.objectContaining({ id: "yue2" }));+ expect(generate).toHaveBeenCalledWith(draft.id, expect.objectContaining({ id: "yue2" }), 1);});it("copies generated music to a draft when changing its generator", () => {@@ -364,7 +397,7 @@ it("copies generated music to a draft when changing its generator", () => {fireEvent.click(screen.getByRole("button", { name: "Select Evening" }));expect(screen.getByRole("combobox", { name: "Generator" })).toHaveAttribute("data-value", "other-music");fireEvent.click(screen.getByRole("button", { name: "Generate" }));- expect(generate).toHaveBeenCalledWith(original.id, expect.objectContaining({ id: "other-music" }));+ expect(generate).toHaveBeenCalledWith(original.id, expect.objectContaining({ id: "other-music" }), 1);const saved = latest;cleanup(); render(<Harness initial={saved} />);expect(screen.getByRole("combobox", { name: "Generator" })).toHaveAttribute("data-value", "other-music");diff --git a/src/components/workspace/MusicView.tsx b/src/components/workspace/MusicView.tsxindex a809324..fda3147 100644--- a/src/components/workspace/MusicView.tsx+++ b/src/components/workspace/MusicView.tsx@@ -4,9 +4,9 @@ import type { ProjectAsset, ProjectConfig } from "../../lib/project";import { isTauri, readMediaFileUrl } from "../../lib/persistence";import { loadGeneratorTemplateSettings, subscribeGeneratorTemplates, templateSupportsMusic, templateUsable, generatorPathFields, type GeneratorTemplate } from "../../lib/settings";import { YUE2_DEFAULT_STEPS, duplicateSong, musicSettingsForModel, moveSong, newMusicFolder, newSong, newSongVariation, removeMusicFolder, songReference, updateSong, type MusicSettings, type MusicSong } from "../../lib/music";-import { isWorkActive, type WorkItem } from "../../lib/workQueue";-import { ComboBox, CommandBarButton, InfoBar, ProgressBar, ProgressRing, PropRow, PropSection, Splitter, useContextMenu, usePaneSize, type MenuEntry } from "../ui";-import { Add16, Audio16, Copy16, Delete16, Edit16, FolderAdd16, FolderOpen16, GridView16, ListView16, Pause16, Play16, References16, Sparkle16, Stop14 } from "../ui/icons";+import { isWorkActive, MAX_MUSIC_BATCH_COUNT, type WorkItem } from "../../lib/workQueue";+import { ComboBox, CommandBarButton, Flyout, InfoBar, ProgressBar, ProgressRing, PropRow, PropSection, Splitter, useContextMenu, usePaneSize, type MenuEntry } from "../ui";+import { Add16, Audio16, ChevronDown14, Copy16, Delete16, Edit16, FolderAdd16, FolderOpen16, GridView16, ListView16, Pause16, Play16, References16, Sparkle16, Stop14 } from "../ui/icons";import { MusicPlaybackControls } from "./MusicPlaybackControls";import { generatorOptions } from "../generatorOptions";import { SliderNumberInput, GENERATION_STEPS_RANGE } from "./SliderNumberInput";@@ -23,7 +23,7 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerateactive?: boolean; onPlayingChange?: (playing: boolean) => void;openSong?: { id: string }; onSongOpened?: () => void;config: ProjectConfig; folderPath: string; onChange: (update: ConfigUpdate, key?: string) => void;- onGenerate: (songId: string, template: GeneratorTemplate) => string | void; onCancel: (id: string) => void;+ onGenerate: (songId: string, template: GeneratorTemplate, count: number) => string | void; onCancel: (id: string) => void;onGenerateCover?: (songId: string) => void;workItems: readonly WorkItem[];}) {@@ -59,10 +59,20 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerateconst menu = useContextMenu();useEffect(() => { if (!active) menu.close(); }, [active, menu.close]);const [error, setError] = useState<string | null>(null);+ const [generationCount, setGenerationCount] = useState("1");+ const [generationOptionsOpen, setGenerationOptionsOpen] = useState(false);+ const [generationOptionsWidth, setGenerationOptionsWidth] = useState<number>();+ const generationControls = useRef<HTMLDivElement>(null);+ const generationOptionsButton = useRef<HTMLButtonElement>(null);+ const generationCountInput = useRef<HTMLInputElement>(null);+ const count = Number(generationCount);+ const validCount = Number.isInteger(count) && count >= 1 && count <= MAX_MUSIC_BATCH_COUNT;const activeWork = selected && workItems.find((item) => item.sceneId === selected.id && isWorkActive(item));const busy = Boolean(activeWork);+ useEffect(() => { setGenerationOptionsOpen(false); }, [active, selected?.id, busy]);const templateReady = (candidate: GeneratorTemplate) => templateUsable(candidate) && generatorPathFields(candidate).every((field) => !field.required || candidate.paths[field.id].trim() || candidate.sources?.[field.id]?.length);const ready = template && templateReady(template);+ const generateDisabled = !ready || !isTauri() || !selected?.style.trim();const generatorStatus = !isTauri()? { state: "demo", label: "Music generator unavailable", detail: "Generate music in the desktop app." }: !ready ? { state: "modelsMissing", label: "Model weights missing", detail: "Download or select music model weights in Settings → Generators." }@@ -130,9 +140,13 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerateif (next && selected) edit({ generatorId: id, steps: Math.min(100, next.defaultSteps), settings: musicSettingsForModel(selected.settings, next.modelType) });};const generate = () => {- if (!selected || !template) return;+ if (!selected || !template || !validCount) return;setError(null);- try { const id = onGenerate(selected.id, template); if (id) setSelectedId(id); } catch (reason) { setError(String(reason)); }+ try {+ const id = onGenerate(selected.id, template, count);+ setGenerationCount("1"); setGenerationOptionsOpen(false);+ if (id) setSelectedId(id);+ } catch (reason) { setError(String(reason)); }};const audio = useRef<HTMLAudioElement>(null);@@ -339,7 +353,24 @@ export function MusicView({ config, folderPath, onChange, onGenerate, onGenerate</div><div className="inspector-actions">{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 ref={generationControls} className="image-generation-controls image-generation-controls--split">+ <button type="button" className="primary-button image-generate-button" data-tooltip={generatorStatus.state !== "ready" ? generatorStatus.detail : undefined}+ disabled={generateDisabled || !validCount} onClick={generate}><Sparkle16 aria-hidden="true" />{count > 1 && validCount ? `Generate (${count})` : "Generate"}</button>+ <button ref={generationOptionsButton} type="button" className="primary-button image-generation-options" aria-label="Generation options"+ aria-haspopup="dialog" aria-expanded={generationOptionsOpen} data-tooltip="Generation options" disabled={generateDisabled}+ onClick={() => {+ setGenerationOptionsWidth(generationControls.current?.getBoundingClientRect().width);+ setGenerationOptionsOpen(!generationOptionsOpen);+ }}><ChevronDown14 aria-hidden="true" /></button>+ <Flyout open={generationOptionsOpen && active} anchor={generationOptionsButton} initialFocus={generationCountInput} onClose={() => setGenerationOptionsOpen(false)}+ placement="top-end" width={generationOptionsWidth} aria-label="Generation options" className="image-generation-options-panel">+ <PropRow label="Count" tooltip="Different seeds for each song. Resets after generating." htmlFor="music-generation-count">+ <input ref={generationCountInput} id="music-generation-count" className="text-field" type="number" min={1} max={MAX_MUSIC_BATCH_COUNT} step={1}+ value={generationCount} aria-invalid={!validCount} aria-describedby={!validCount ? "music-generation-count-help" : undefined} onChange={(event) => setGenerationCount(event.target.value)} />+ </PropRow>+ <p hidden={validCount} id="music-generation-count-help">{`Enter a whole number from 1 to ${MAX_MUSIC_BATCH_COUNT}.`}</p>+ </Flyout>+ </div>}</div></> : <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>diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.tsindex ddfd41d..19ffed8 100644--- a/src/lib/workQueue.test.ts+++ b/src/lib/workQueue.test.ts@@ -463,6 +463,52 @@ it("queues an immutable music request and saves its audio into timeline media",expect(saveGeneratedScene).not.toHaveBeenCalled();});+it.each(["draft", "completed"] as const)("queues distinct music variations from a %s and saves each result", async (status) => {+ const { queue, first } = setup();+ const source = { ...newSong("yue2", 24, "jazz"), title: "Evening", style: "Soft jazz", seed: Number.MAX_SAFE_INTEGER,+ status, assetId: status === "completed" ? "original" : null };+ source.settings.lyrics = "[Verse]\nGood evening";+ const existing = { ...newSong(), title: "Evening (2)" };+ first.update((config) => ({ ...config, musicSongs: [source, existing] }));+ const template = musicTemplates()[0];+ template.paths.transformer = "C:/weights/yue2.safetensors"; template.sources = {};+ vi.mocked(invoke).mockImplementation(async (_command, args) => ({ relativePath: `media/generated/${(args as { jobId: string }).jobId}.wav`, durationMs: 30000 }));+ const selectedId = queue.enqueueMusic(first, source.id, template, 3);+ const items = [...queue.getSnapshot()];+ expect(items).toHaveLength(3);+ expect(selectedId).toBe(items[0].sceneId);+ expect(new Set(items.map((item) => item.sceneId)).size).toBe(3);+ expect(items.map((item) => item.settings!.seed)).toEqual([Number.MAX_SAFE_INTEGER, 0, 1]);+ const songs = first.getSnapshot().config.musicSongs!;+ expect(songs).toHaveLength(status === "draft" ? 4 : 5);+ expect(items.map((item) => item.title)).toEqual(status === "draft" ? ["Evening", "Evening (3)", "Evening (4)"] : ["Evening (3)", "Evening (4)", "Evening (5)"]);+ for (const item of items) {+ expect(songs.find((song) => song.id === item.sceneId)).toMatchObject({ folderId: "jazz", style: source.style, settings: source.settings, steps: 24, assetId: null });+ }+ // Re-submitting a queued variation must not create a second batch.+ queue.enqueueMusic(first, selectedId, template, 3);+ expect(queue.getSnapshot()).toHaveLength(3);+ first.update((config) => ({ ...config, musicSongs: config.musicSongs!.map((song) => song.id === selectedId ? { ...song, style: "Edited later" } : song) }));+ for (let index = 0; index < items.length; index++) {+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(index + 1));+ expect(vi.mocked(enqueueSlopfabGeneration).mock.calls[index][0]).toMatchObject({ prompt: "Soft jazz", steps: 24, seed: items[index].settings!.seed, music: source.settings });+ await finish(queue, items[index].id);+ expect(first.getSnapshot().config.musicSongs!.find((song) => song.id === items[index].sceneId)).toMatchObject({ status: "completed", assetId: items[index].id,+ generation: { seed: items[index].settings!.seed, style: "Soft jazz", settings: source.settings } });+ }+ expect(first.getSnapshot().config.assets).toHaveLength(3);+ if (status === "completed") expect(first.getSnapshot().config.musicSongs![0]).toEqual(source);+});++it.each([0, -1, 1.5, 101, NaN, Infinity])("rejects invalid music batch count %s without creating drafts or work", (count) => {+ const { queue, first } = setup();+ const song = { ...newSong(), style: "Jazz" };+ first.update((config) => ({ ...config, musicSongs: [song] }));+ expect(() => queue.enqueueMusic(first, song.id, musicTemplates()[0], count)).toThrow("Count must be a whole number");+ expect(first.getSnapshot().config.musicSongs).toEqual([song]);+ expect(queue.getSnapshot()).toHaveLength(0);+});+it.each(["yue2", "minimax_music3"])("records the actual flow sampler sent for %s", async modelType => {const { queue, first } = setup();const song = { ...newSong(), style: "Jazz", steps: 32 };diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.tsindex e46011d..2572623 100644--- a/src/lib/workQueue.ts+++ b/src/lib/workQueue.ts@@ -42,6 +42,7 @@ import { exportReferenceRefmod, refmodExportBlocker, refmodExportRequest, type Rexport type WorkStatus = "queued" | "preparing" | "generating" | "encoding" | "completed" | "failed" | "cancelled";export interface GenerationSubmission { job: GenerationJob; request: SlopfabGenerationRequest; snapshot: string; template?: GeneratorTemplate; upscaleSource?: import("./project").SceneGenerationVersion }export const MAX_IMAGE_BATCH_COUNT = 100;+export const MAX_MUSIC_BATCH_COUNT = 100;function imageGenerationSeed(seed: number): number {if (seed !== -1) return seed;@@ -322,7 +323,8 @@ export class WorkQueue {});}- enqueueMusic(session: ProjectSession, songId: string, template: GeneratorTemplate) {+ enqueueMusic(session: ProjectSession, songId: string, template: GeneratorTemplate, count = 1) {+ if (!Number.isInteger(count) || count < 1 || count > MAX_MUSIC_BATCH_COUNT) throw new Error(`Count must be a whole number from 1 to ${MAX_MUSIC_BATCH_COUNT}.`);if (!isTauri()) throw new Error("Music generation requires the desktop app and model weights.");if (!templateSupportsMusic(template)) throw new Error("Choose a music generator.");const current = session.getSnapshot().config;@@ -330,25 +332,38 @@ export class WorkQueue {if (!source.style.trim()) throw new Error("Describe the song's style before generating.");const projectKey = projectQueueKey(session.record);if (this.items.some((item) => item.projectKey === projectKey && item.kind === "music" && item.sceneId === songId && isWorkActive(item))) return songId;- const song = source.assetId || source.status === "completed" ? newSongVariation(source, current.musicSongs ?? []) : source;- songId = song.id;- const id = `music-${crypto.randomUUID()}`;- const captured = { ...structuredClone(song), generatorId: template.id, seed: imageGenerationSeed(song.seed), settings: musicSettingsForModel(song.settings, template.modelType) };- const config = structuredClone({ ...current, providerSettings: { ...current.providerSettings,- slopfab: engineProviderSetting(template.paths, current.providerSettings.slopfab, "flash2", [], "prompt", [], false, template.sources, { modelType: template.modelType }) } });- const request: SlopfabGenerationRequest = { jobId: id, prompt: song.style, steps: song.steps, seed: captured.seed,- music: captured.settings, frames: 0, canvasWidth: 0, canvasHeight: 0, referencePaths: [] };- let finish!: () => void;- const done = new Promise<void>((resolve) => { finish = resolve; });- this.work.set(id, { id, music: captured, session, sceneId: songId, request, config, snapshot: JSON.stringify(captured), cancelled: false, submitted: false, done, finish });- session.update((value) => updateSong(value.musicSongs?.some((item) => item.id === songId) ? value- : { ...value, musicSongs: [...(value.musicSongs ?? []), song] }, songId, { status: "queued", error: null, generatorId: template.id }));- this.items = [...this.items, { id, kind: "music", projectKey, folderPath: session.record.folderPath, projectName: current.name,- sceneId: songId, title: song.title, submittedAt: new Date().toISOString(), status: "queued", progress: 0,- detail: "Waiting to generate music", error: null, completionAt: null, cancelling: false, needsSave: false,- settings: { frames: 0, steps: song.steps, seed: captured.seed, canvasWidth: 0, canvasHeight: 0 } }];+ const songs = [...(current.musicSongs ?? [])];+ const entries: MusicSong[] = [];+ for (let index = 0; index < count; index++) {+ const song = index > 0 || source.assetId || source.generation || source.status === "completed" ? newSongVariation(source, songs) : source;+ entries.push(song);+ if (song.id !== source.id) songs.push(song);+ }+ let seed = imageGenerationSeed(source.seed);+ const items: WorkItem[] = [];+ for (const song of entries) {+ const songId = song.id;+ const id = `music-${crypto.randomUUID()}`;+ const captured = { ...structuredClone(song), generatorId: template.id, seed, settings: musicSettingsForModel(song.settings, template.modelType) };+ const config = structuredClone({ ...current, providerSettings: { ...current.providerSettings,+ slopfab: engineProviderSetting(template.paths, current.providerSettings.slopfab, "flash2", [], "prompt", [], false, template.sources, { modelType: template.modelType }) } });+ const request: SlopfabGenerationRequest = { jobId: id, prompt: song.style, steps: song.steps, seed: captured.seed,+ music: captured.settings, frames: 0, canvasWidth: 0, canvasHeight: 0, referencePaths: [] };+ let finish!: () => void;+ const done = new Promise<void>((resolve) => { finish = resolve; });+ this.work.set(id, { id, music: captured, session, sceneId: songId, request, config, snapshot: JSON.stringify(captured), cancelled: false, submitted: false, done, finish });+ items.push({ id, kind: "music", projectKey, folderPath: session.record.folderPath, projectName: current.name,+ sceneId: songId, title: song.title, submittedAt: new Date().toISOString(), status: "queued", progress: 0,+ detail: "Waiting to generate music", error: null, completionAt: null, cancelling: false, needsSave: false,+ settings: { frames: 0, steps: song.steps, seed: captured.seed, canvasWidth: 0, canvasHeight: 0 } });+ seed = seed === Number.MAX_SAFE_INTEGER ? 0 : seed + 1;+ }+ const queuedIds = new Set(entries.map((song) => song.id));+ session.update((value) => ({ ...value, musicSongs: [...(value.musicSongs ?? []), ...entries.filter((song) => song.id !== source.id)]+ .map((song) => queuedIds.has(song.id) ? { ...song, status: "queued", error: null, generatorId: template.id } : song) }));+ this.items = [...this.items, ...items];this.publish(); void this.pump();- return songId;+ return entries[0].id;}enqueueAlbumCover(session: ProjectSession, songId: string) {if (!isTauri()) throw new Error("Album cover generation requires the desktop app and model weights.");