AI media harness for planning, generating, and editing locally
TypeScript
Key scene and reference edits for undo; follow the new project tabs in tests
Bittid8748de5d398
diff --git a/src/components/ImageProject.integration.test.tsx b/src/components/ImageProject.integration.test.tsxindex 83b89ba..efaa875 100644--- a/src/components/ImageProject.integration.test.tsx+++ b/src/components/ImageProject.integration.test.tsx@@ -61,18 +61,18 @@ it("shows the full image prompt at the end of the inspector only when debug is e];project.config.imageScene!.referenceIds = ["subject", "mood"];render(<ProjectWorkspace project={project} onBack={vi.fn()} onSave={vi.fn()} />);- expect(screen.queryByRole("button", { name: "Debug Prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Debug prompt" })).not.toBeInTheDocument();act(() => saveDebugOptionsEnabled(true));// The complete scene prompt is available even with a child selected.fireEvent.contextMenu(screen.getByRole("button", { name: "Image" }));fireEvent.click(screen.getByRole("menuitem", { name: "New Text" }));fireEvent.change(screen.getByLabelText("Text to render"), { target: { value: "TO THE MOON" } });const inspector = screen.getByRole("complementary", { name: "Image node inspector" });- const button = within(inspector).getByRole("button", { name: "Debug Prompt" });+ const button = within(inspector).getByRole("button", { name: "Debug prompt" });expect(inspector.lastElementChild).toContainElement(button);button.focus();fireEvent.click(button);- const prompt = within(screen.getByRole("dialog", { name: "Debug Prompt" })).getByLabelText("The compiled MiniMax H3 prompt");+ const prompt = within(screen.getByRole("dialog", { name: "Debug prompt" })).getByLabelText("The compiled MiniMax H3 prompt");for (const line of imageScenePrompt(project.config.imageScene!, "Watercolor").split("\n")) expect(prompt.textContent).toContain(line);expect(prompt.textContent).toContain('Render the exact text "TO THE MOON".');expect(prompt.textContent).toContain("Watercolor visual style");@@ -80,13 +80,12 @@ it("shows the full image prompt at the end of the inspector only when debug is eexpect(prompt.textContent).toContain("[Shot 1] A rocket launch over the ocean at dawn.");expect(prompt.textContent).toMatch(/overall_soundscape: N\/A\n\nnon_diegetic_music: N\/A$/);expect(prompt.textContent).not.toContain("Do not include this reference");- fireEvent.keyDown(window, { key: "Escape" });- expect(screen.queryByRole("dialog", { name: "Debug Prompt" })).not.toBeInTheDocument();- expect(button).toHaveFocus();+ fireEvent.keyDown(prompt, { key: "Escape" });+ expect(screen.queryByRole("dialog", { name: "Debug prompt" })).not.toBeInTheDocument();fireEvent.click(button);act(() => saveDebugOptionsEnabled(false));- expect(screen.queryByRole("button", { name: "Debug Prompt" })).not.toBeInTheDocument();- expect(screen.queryByRole("dialog", { name: "Debug Prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Debug prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("dialog", { name: "Debug prompt" })).not.toBeInTheDocument();});it("offers image and video projects when creating a folder project", async () => {@@ -94,7 +93,6 @@ it("offers image and video projects when creating a folder project", async () =>render(<PromptComposer busy={false} onCreate={submit} onClose={vi.fn()} />);fireEvent.click(screen.getByRole("radio", { name: "Image project" }));expect(screen.getByLabelText("Project name")).toHaveValue("Untitled image");- expect(screen.getByText("Image settings")).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: /Create project/ }));await waitFor(() => expect(submit).toHaveBeenCalledWith(expect.objectContaining({ generationType: "image" })));});@@ -102,8 +100,8 @@ it("offers image and video projects when creating a folder project", async () =>it("opens the three-tab image workspace and saves hierarchy/inspector edits through the project session", async () => {const save = vi.fn(async () => undefined);render(<ProjectWorkspace project={record()} onBack={vi.fn()} onSave={save} />);- const navigation = within(screen.getByRole("navigation", { name: "Project views" }));- expect(navigation.getAllByRole("button").map((button) => button.textContent)).toEqual([" Agent", " Editor", " References"]);+ const navigation = within(screen.getByRole("tablist", { name: "Project views" }));+ expect(navigation.getAllByRole("tab").map((tab) => tab.textContent)).toEqual(["Editor", "References"]);fireEvent.contextMenu(screen.getByRole("button", { name: "Image" }));fireEvent.click(screen.getByRole("menuitem", { name: "New Text" }));fireEvent.change(screen.getByLabelText("Text to render"), { target: { value: "Hello world" } });@@ -114,8 +112,8 @@ it("opens the three-tab image workspace and saves hierarchy/inspector edits throconst saved = (save.mock.calls as unknown as [ProjectRecord][])[0][0];expect(saved.config.imageScene?.nodes.at(-1)).toMatchObject({ kind: "text", text: "Hello world", description: "Large blue letters", parentId: "image-root" });expect(parseProjectConfig(saved.config).imageScene).toEqual(saved.config.imageScene);- fireEvent.click(navigation.getByRole("button", { name: "References" }));- fireEvent.click(navigation.getByRole("button", { name: "Editor" }));+ fireEvent.click(navigation.getByRole("tab", { name: /References/ }));+ fireEvent.click(navigation.getByRole("tab", { name: /Editor/ }));expect(screen.getByRole("tree", { name: "Image nodes" })).toBeInTheDocument();});@@ -127,8 +125,8 @@ it("keeps the video tabs and applies image agent commands without changing generconst video = createProjectConfig({ name: "Film", prompt: "", aspectRatio: "16:9", resolution: "768p", targetDurationSeconds: 60 });await expect(executeAgentCommands(video, [{ op: "image.set", ...authored }])).rejects.toThrow("image project");render(<ProjectWorkspace project={{ folderPath: "D:/Film", config: video }} onBack={vi.fn()} onSave={vi.fn()} />);- const navigation = within(screen.getByRole("navigation", { name: "Project views" }));- expect(navigation.getByRole("button", { name: "Timeline" })).toBeInTheDocument();- expect(navigation.getByRole("button", { name: "Generator" })).toBeInTheDocument();- expect(navigation.queryByRole("button", { name: "Editor" })).not.toBeInTheDocument();+ const navigation = within(screen.getByRole("tablist", { name: "Project views" }));+ expect(navigation.getByRole("tab", { name: /Timeline/ })).toBeInTheDocument();+ expect(navigation.getByRole("tab", { name: /Generator/ })).toBeInTheDocument();+ expect(navigation.queryByRole("tab", { name: /Editor/ })).not.toBeInTheDocument();});diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex f29f2b5..a71aa4f 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -27,7 +27,8 @@ interface GeneratorViewProps {folderPath: string;runtime?: SlopfabStatus | null;generationCompletionTimes?: Readonly<Record<string, number>>;- onChange: (next: ProjectConfig) => void;+ /** `key` groups rapid edits of one thing into one undo step (the workspace's session.edit). */+ onChange: (next: ProjectConfig, key?: string) => void;onGenerate?: (submissions: GenerationSubmission[]) => void;onCancelGeneration?: (sceneIds: string[]) => Promise<void>;cancellingJobIds?: ReadonlySet<string>;@@ -147,7 +148,8 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCoconst updateJob = (id: string, updates: Partial<GenerationJob>) => {const current = configRef.current;- onChange({ ...current, generationJobs: current.generationJobs.map((job) => job.id === id ? { ...job, ...updates } : job) });+ // Typing in one scene's fields (or dragging its length) is one undo step.+ onChange({ ...current, generationJobs: current.generationJobs.map((job) => job.id === id ? { ...job, ...updates } : job) }, `scene:${id}`);};/* An edit from the panel. Writing a reference into a line BINDS it to thediff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 3c4b5b2..4a2398f 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -72,7 +72,8 @@ const readView = (): LibraryView => {export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon, onGenerateBuiltinIcons, onRegenerateBuiltinIcon, pendingBuiltinIconIds = new Set<string>(), pendingIconIds = new Set<string>(), onOpenGenerator }: {config: ProjectConfig;folderPath: string;- onChange: (next: ProjectConfig) => void;+ /** `key` groups rapid edits of one reference into one undo step. */+ onChange: (next: ProjectConfig, key?: string) => void;onRegenerateIcon?: (referenceId: string) => void;onGenerateBuiltinIcons?: () => void;onRegenerateBuiltinIcon?: (presetId: string) => void;@@ -155,7 +156,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,const update = (id: string, patch: Partial<ProjectReference>) => {const current = configRef.current;- onChange({ ...current, references: current.references.map((ref) => ref.id === id ? { ...ref, ...patch } : ref) });+ onChange({ ...current, references: current.references.map((ref) => ref.id === id ? { ...ref, ...patch } : ref) }, `reference:${id}`);};const selectOnly = (id: string | undefined) => {setSelectedId(id);