Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Move video title into scene generator toolbar

Bittiaeb679469985
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index c40f5d2..fe5662f 100644
--- a/src/components/workspace/GeneratorView.tsx
+++ b/src/components/workspace/GeneratorView.tsx
@@ -9,7 +9,7 @@ import { refreshDownloadedLoras } from "../../lib/weightDownloads";
import { continuationBlocker, continuationSceneId, isVideoTransition, sceneGenerationSteps, sceneTypeFor } from "../../lib/project";
import { Add16, Delete16, GridView16, GridView16Filled, ListView16, ListView16Filled, Scene16, Scene32, Sparkle16, Stop14, Wand16 } from "../ui/icons";
import { invoke } from "@tauri-apps/api/core";
-import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
+import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
import { useShortcut } from "../../lib/commands";
import { askNative } from "../../lib/nativeShell";
import { ProjectStatus } from "./ProjectStatus";
@@ -30,6 +30,7 @@ import { DebugPromptDialog } from "./DebugPromptDialog";
import { videoGuidedScene } from "../../lib/videoLibrary";
interface GeneratorViewProps {
+ toolbarStart?: ReactNode;
sceneIds?: readonly string[];
config: ProjectConfig;
folderPath: string;
@@ -64,7 +65,7 @@ const readDensity = (): BoardDensity => {
* The panel is whatever is open — one shot, or the scene itself. Nothing is
* edited on the board, and nothing is duplicated in the panel: there is exactly
* one place to change any given thing. */
-export function GeneratorView({ config, sceneIds, folderPath, runtime = null, generationCompletionTimes = {}, onChange, selectedJobId, onSelectedJobChange, onRuntimeChange, onGenerate, onCancelGeneration, cancellingJobIds = new Set() }: GeneratorViewProps) {
+export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runtime = null, generationCompletionTimes = {}, onChange, selectedJobId, onSelectedJobChange, onRuntimeChange, onGenerate, onCancelGeneration, cancellingJobIds = new Set() }: GeneratorViewProps) {
const jobs = sceneIds ? sceneIds.flatMap((id) => { const job = config.generationJobs.find((job) => job.id === id); return job ? [job] : []; }) : config.generationJobs;
const [selection, setSelection] = useState<GeneratorSelection>(() => ({ jobId: selectedJobId ?? jobs.find((job) => job.status === "generating")?.id ?? jobs[0]?.id ?? "", shotId: null }));
const [templateSettings, setTemplateSettings] = useState(loadGeneratorTemplateSettings);
@@ -528,6 +529,7 @@ export function GeneratorView({ config, sceneIds, folderPath, runtime = null, ge
onClick={() => void generateAll()}
/>}
>
+ {toolbarStart}
{/* The generator the next render uses, with its readiness as a glyph
beside the name; the words for a state that needs attention are
in the tooltip and the status bar. */}
diff --git a/src/components/workspace/VideoLibraryView.test.tsx b/src/components/workspace/VideoLibraryView.test.tsx
index fa3d5c6..7f0070e 100644
--- a/src/components/workspace/VideoLibraryView.test.tsx
+++ b/src/components/workspace/VideoLibraryView.test.tsx
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
-import { useState } from "react";
+import { useState, type ReactNode } from "react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { createDraftGenerationJob, createProjectConfig, generationAssetId, type ProjectConfig } from "../../lib/project";
import { newVideo } from "../../lib/videoLibrary";
@@ -13,7 +13,8 @@ import { choose } from "./comboTestUtils";
vi.mock("./ShotThumbnail", async (original) => ({ ...await original<typeof import("./ShotThumbnail")>(), shotPoster: vi.fn(async () => ({ poster: "data:image/jpeg;base64,preview", failed: false })) }));
vi.mock("../../lib/nativeShell", async (original) => ({ ...await original<typeof import("../../lib/nativeShell")>(), askNative: vi.fn(async () => true) }));
-vi.mock("./GeneratorView", () => ({ GeneratorView: ({ config, sceneIds, onChange }: { config: ProjectConfig; sceneIds: string[]; onChange: (next: ProjectConfig) => void }) => <div aria-label="Scenes editor">
+vi.mock("./GeneratorView", () => ({ GeneratorView: ({ config, sceneIds, toolbarStart, onChange }: { config: ProjectConfig; sceneIds: string[]; toolbarStart?: ReactNode; onChange: (next: ProjectConfig) => void }) => <div aria-label="Scenes editor">
+ {toolbarStart}
<span>{sceneIds.join(",")}</span><span data-testid="all-scenes">{config.generationJobs.length}</span>
<button onClick={() => onChange({ ...config, generationJobs: [...config.generationJobs, createDraftGenerationJob("New", { id: "added" })] })}>Add scene</button>
</div> }));
diff --git a/src/components/workspace/VideoLibraryView.tsx b/src/components/workspace/VideoLibraryView.tsx
index 4dee42a..e39f90a 100644
--- a/src/components/workspace/VideoLibraryView.tsx
+++ b/src/components/workspace/VideoLibraryView.tsx
@@ -84,8 +84,8 @@ export function VideoLibraryView(props: ComponentProps<typeof GeneratorView> & {
...config.references.filter((reference) => reference.kind === kind && (reference.relativePath || reference.sourcePath)).map((reference) => ({ value: `reference:${reference.id}`, label: `${reference.name} (reference range)` })),
];
if (open) return <div className="video-scenes">
- <div className="music-toolbar video-scenes__path"><button type="button" className="secondary-button" onClick={() => setOpenId(undefined)}>Back to Video</button><strong>{open.title}</strong><span>Scenes</span></div>
<GeneratorView {...props} key={open.id} config={{ ...config, videos }} sceneIds={open.sceneIds} selectedJobId={open.sceneIds.includes(props.selectedJobId ?? "") ? props.selectedJobId : undefined}
+ toolbarStart={<><button type="button" className="secondary-button" onClick={() => setOpenId(undefined)}>Back to Video</button><strong className="video-scenes__title" title={open.title}>{open.title}</strong></>}
onChange={(next, key) => onChange(mergeVideoScenes(latest.current, open.id, next), key)} />
</div>;
return <div className="video-library-view" style={pane.style}>
diff --git a/src/styles/video-library.css b/src/styles/video-library.css
index c0ac37b..496f397 100644
--- a/src/styles/video-library.css
+++ b/src/styles/video-library.css
@@ -6,9 +6,8 @@
.video-library-body > .music-inspector { grid-row: 1; }
.video-scenes { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.video-scenes > .generator-view { flex: 1; min-height: 0; height: auto; }
-.video-scenes__path { flex: none; }
-.video-scenes__path strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.video-scenes__path span, .video-reference-help { color: var(--text-secondary); font-size: var(--text-xs); }
+.video-scenes__title { min-width: 0; max-width: 200px; margin-inline: var(--space-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.video-reference-help { color: var(--text-secondary); font-size: var(--text-xs); }
.video-reference-range { display: block; margin-block: var(--space-1); }
.video-library-stage .music-songs--grid { grid-template-columns: repeat(auto-fill, minmax(0, min(300px, 100%))); gap: var(--space-2); }
.video-card { overflow: hidden; container-type: inline-size; border-radius: var(--radius-sm); }