AI media harness for planning, generating, and editing locally
TypeScript
Add character sheet steps and seed
Bitti1fc4162e2440
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex c438487..09aedcf 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -5,7 +5,7 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve## What's new- First and last scene frames use the searchable reference picker with image thumbnails. Reference selectors and prompt chips share configurable filters for images, audio, video, text, and RefMods.-- Configure a character sheet from the Image toolbar's Template menu, with one reference-enabled prompt for clothing and other details and a resolution selection controlling sheet height (512–2048 px), then select Execute. A square waist-up shot and three 9:16 full-body views are combined into one child image in the image bar. The front view provides a shared clothing reference for the other views.+- Configure a character sheet from the Image toolbar's Template menu, with one reference-enabled prompt for clothing and other details, a resolution selection controlling sheet height (512–2048 px), and step count and seed controls, then select Execute. A square waist-up shot and three 9:16 full-body views are combined into one child image in the image bar. The front view provides a shared clothing reference for the other views; all four views share the selected step count and seed.- Continue scenes from a selected scene's saved latents, with adjustable overlap and a choice of beginning or end. This replaces Previous scene in First & last frame.- Export any reference with images, a video or a sound as a refmod `.safetensors` file from References. Exported refmods can be attached to other references and projects.- Copying or cutting prompts preserves reference chips when pasted into other prompt fields.diff --git a/src/components/ImageProject.integration.test.tsx b/src/components/ImageProject.integration.test.tsxindex 1c669df..1357f74 100644--- a/src/components/ImageProject.integration.test.tsx+++ b/src/components/ImageProject.integration.test.tsx@@ -47,6 +47,10 @@ it("opens template settings and executes only after configuring prompts and clotconst before = structuredClone(queue.project(project).getSnapshot().config);choose("Character sheet resolution", "2048 px high");expect(panel.getByText(/Sheet size:/)).toHaveTextContent("5504 × 2048 px");+ fireEvent.change(panel.getByRole("spinbutton", { name: "Steps" }), { target: { value: "" } });+ expect(panel.getByRole("button", { name: "Execute" })).toBeDisabled();+ fireEvent.change(panel.getByRole("spinbutton", { name: "Steps" }), { target: { value: "37" } });+ fireEvent.change(panel.getByRole("spinbutton", { name: "Seed" }), { target: { value: "0" } });expect(panel.queryByRole("textbox", { name: "Clothing and accessories" })).not.toBeInTheDocument();const prompt = panel.getByRole("textbox", { name: "Character sheet prompt" });typePrompt(prompt, "Soft studio lighting. Wear");@@ -56,7 +60,7 @@ it("opens template settings and executes only after configuring prompts and clotexpect(prompt.querySelector(".prompt-chip")).toHaveTextContent("Red coat");expect(queue.project(project).getSnapshot().config).toEqual(before);fireEvent.click(panel.getByRole("button", { name: "Execute" }));- expect(generate).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ id: "test" }), "Selected", { prompt: "Soft studio lighting. Wear @[ref:outfit]", height: 2048 });+ expect(generate).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ id: "test" }), "Selected", { prompt: "Soft studio lighting. Wear @[ref:outfit]", height: 2048, steps: 37, seed: 0 });fireEvent.click(panel.getByRole("button", { name: "Close template settings" }));expect(screen.getByRole("complementary", { name: "Image node inspector" })).toBeInTheDocument();fireEvent.click(toolbar.getByRole("button", { name: "Template" }));diff --git a/src/components/workspace/CharacterSheetSettings.tsx b/src/components/workspace/CharacterSheetSettings.tsxindex 5ee0e3d..bc44e1b 100644--- a/src/components/workspace/CharacterSheetSettings.tsx+++ b/src/components/workspace/CharacterSheetSettings.tsx@@ -5,12 +5,13 @@ import { ComboBox, InfoBar, ItemHeader, PropRow } from "../ui";import { Dismiss16, Sparkle16 } from "../ui/icons";import { PromptTextField, type PromptReference } from "./PromptTextField";-export function CharacterSheetSettings({ config, source, references, missingLabel, disabledReason, busy, onExecute, onClose }: {+export function CharacterSheetSettings({ config, source, references, missingLabel, defaultSteps, disabledReason, busy, onExecute, onClose }: {config: ProjectConfig; source: ProjectAsset; references: PromptReference[]; missingLabel: (id: string) => string;- disabledReason: string | null; busy: boolean;+ defaultSteps: number; disabledReason: string | null; busy: boolean;onExecute: (options: CharacterSheetOptions) => void; onClose: () => void;}) {- const [options, setOptions] = useState<CharacterSheetOptions>(() => ({ ...emptyCharacterSheetOptions(), height: characterSheetDimensions(config.settings.resolution)[0].height }));+ const [options, setOptions] = useState<CharacterSheetOptions>(() => ({ ...emptyCharacterSheetOptions(), height: characterSheetDimensions(config.settings.resolution)[0].height,+ steps: config.imageScene?.steps ?? defaultSteps, seed: config.imageScene?.seed ?? -1 }));const dimensions = characterSheetDimensions(config.settings.resolution, options.height);const [error, setError] = useState<string | null>(null);const validation = useMemo(() => {@@ -34,6 +35,11 @@ export function CharacterSheetSettings({ config, source, references, missingLabe<PropRow label="Resolution" htmlFor="character-sheet-resolution"><ComboBox id="character-sheet-resolution" aria-label="Character sheet resolution" value={options.height} disabled={busy}options={CHARACTER_SHEET_HEIGHTS.map((height) => ({ value: height, label: `${height} px high` }))} onChange={(height) => update("height", height)} /></PropRow><p className="image-inspector__caption">Sheet size: {dimensions.reduce((width, view) => width + view.width, 0)} × {dimensions[0].height} px. Width follows the four view proportions.</p>+ <PropRow label="Steps" htmlFor="character-sheet-steps"><input id="character-sheet-steps" className="text-field" type="number" min="2" max="1000" step="1" required disabled={busy}+ value={Number.isNaN(options.steps) ? "" : options.steps} onChange={(event) => update("steps", event.target.valueAsNumber)} /></PropRow>+ <PropRow label="Seed" htmlFor="character-sheet-seed"><input id="character-sheet-seed" className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} step="1" required disabled={busy}+ value={Number.isNaN(options.seed) ? "" : options.seed} onChange={(event) => update("seed", event.target.valueAsNumber)} /></PropRow>+ <p className="image-inspector__caption">Use -1 for a random seed. All four views use the same seed and step count.</p><div className="image-inspector__area"><span>Prompt</span><PromptTextField aria-label="Character sheet prompt" value={options.prompt} onChange={(value) => update("prompt", value)} references={references} missingLabel={missingLabel} disabled={busy} placeholder="Describe the character, clothing, accessories, style, or lighting…" /></div>diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 769c8bc..93336a0 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -646,7 +646,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene</section><Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" />{output && templateSourceId === output.id ? <CharacterSheetSettings- config={config} source={output} references={promptReferences} missingLabel={missingReference} busy={Boolean(active)}+ config={config} source={output} references={promptReferences} missingLabel={missingReference} defaultSteps={template?.defaultSteps ?? 20} busy={Boolean(active)}disabledReason={!isTauri() ? "Template execution is available in the desktop app." : !onGenerateCharacterSheet || !template || !templateUsable(template) ? "Choose a downloaded generator to execute this template." : null}onExecute={(options) => onGenerateCharacterSheet?.(template!, output.id, options)} onClose={() => setTemplateSourceId(null)}/> : <aside className="image-inspector" aria-label="Image node inspector">diff --git a/src/lib/characterSheet.test.ts b/src/lib/characterSheet.test.tsindex 69e04d0..14c050e 100644--- a/src/lib/characterSheet.test.ts+++ b/src/lib/characterSheet.test.ts@@ -126,6 +126,35 @@ it("rejects unsupported sheet heights before queueing generation", () => {expect(queue.getSnapshot()).toHaveLength(0);});+it.each([0, 12345, -1])("uses template steps and seed %s for every view and saved settings", async (seed) => {+ const { queue, session } = setup();+ const original = structuredClone(session.getSnapshot().config.imageScene);+ const options = { prompt: "", steps: 37, seed };+ queue.enqueueCharacterSheet(session, template, "source", options);+ options.steps = 10; options.seed = 999;+ const usedSeed = queue.getSnapshot()[0].settings.seed;+ expect(Number.isSafeInteger(usedSeed)).toBe(true);+ expect(usedSeed).toBeGreaterThanOrEqual(0);+ if (seed !== -1) expect(usedSeed).toBe(seed);+ expect(queue.getSnapshot()[0].settings.steps).toBe(37);+ for (let index = 0; index < 4; index++) {+ const request = await requestAt(index);+ expect(request).toMatchObject({ steps: 37, seed: usedSeed });+ expect(session.getSnapshot().config.imageScene).toEqual(original);+ emit("framesReady", request.jobId);+ }+ await waitFor(() => expect(queue.getSnapshot()[0].status).toBe("completed"));+ const reopened = parseProjectConfig(JSON.parse(JSON.stringify(session.getSnapshot().config)));+ expect(reopened.assets.at(-1)?.imageGeneration).toMatchObject({ usedSeed, scene: { steps: 37, seed } });+});++it.each([{ steps: 1 }, { steps: 1001 }, { steps: 2.5 }, { steps: NaN }, { seed: -2 }, { seed: 0.5 }, { seed: Number.MAX_SAFE_INTEGER + 1 }])("rejects invalid template sampling settings %j", (settings) => {+ const { queue, session } = setup();+ expect(() => queue.enqueueCharacterSheet(session, template, "source", { prompt: "", ...settings })).toThrow();+ expect(queue.getSnapshot()).toHaveLength(0);+ expect(enqueueSlopfabGeneration).not.toHaveBeenCalled();+});+it.each(["cancelled", "failed"])("discards partial views after the second render is %s", async (state) => {const { queue, session } = setup();queue.enqueueCharacterSheet(session, template, "source");diff --git a/src/lib/characterSheet.ts b/src/lib/characterSheet.tsindex 1c42b21..4f2516b 100644--- a/src/lib/characterSheet.ts+++ b/src/lib/characterSheet.ts@@ -14,7 +14,7 @@ export const CHARACTER_SHEET_VIEWS = [export const CHARACTER_SHEET_ORDER = [1, 0, 2, 3] as const;export const CHARACTER_SHEET_HEIGHTS = [512, 1024, 1536, 2048] as const;-export interface CharacterSheetOptions { prompt: string; height?: number }+export interface CharacterSheetOptions { prompt: string; height?: number; steps?: number; seed?: number }export const emptyCharacterSheetOptions = (): CharacterSheetOptions => ({ prompt: "" });export function characterSheetDimensions(resolution: ProjectConfig["settings"]["resolution"], requestedHeight?: number) {@@ -26,6 +26,8 @@ export function characterSheetDimensions(resolution: ProjectConfig["settings"]["}export function compileCharacterSheet(config: ProjectConfig, source: ProjectAsset, frontRelativePath: string, options: CharacterSheetOptions = emptyCharacterSheetOptions()) {+ if (options.steps !== undefined && (!Number.isInteger(options.steps) || options.steps < 2 || options.steps > 1000)) throw new Error("Steps must be a whole number from 2 to 1000.");+ if (options.seed !== undefined && (!Number.isSafeInteger(options.seed) || options.seed < -1)) throw new Error("Seed must be -1 for random or a whole number from 0 to 9007199254740991.");let sourceReferenceId = "character-sheet-source";while (config.references.some((reference) => reference.id === sourceReferenceId)) sourceReferenceId += "-source";const reference: ProjectReference = {diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.tsindex 91abdaa..b7ee740 100644--- a/src/lib/workQueue.ts+++ b/src/lib/workQueue.ts@@ -276,14 +276,17 @@ export class WorkQueue {const id = `character-sheet-${crypto.randomUUID()}`;const frontRelativePath = `cache/character-sheets/${id}/1.png`;const views = compileCharacterSheet(config, source, frontRelativePath, options);+ config.imageScene = { ...(config.imageScene ?? createImageScene()),+ steps: generationStepsWithLoras(options?.steps ?? current.imageScene?.steps ?? template.defaultSteps, config),+ seed: options?.seed ?? current.imageScene?.seed ?? -1 };const dimensions = characterSheetDimensions(config.settings.resolution, options?.height);const firstView = CHARACTER_SHEET_ORDER[0];const { width, height } = dimensions[firstView];let finish!: () => void;const done = new Promise<void>((resolve) => { finish = resolve; });const request: SlopfabGenerationRequest = { jobId: `${id}-view-${firstView + 1}`, stillImage: true, frames: 1, prompt: views[firstView].prompt,- canvasWidth: width, canvasHeight: height, steps: generationStepsWithLoras(current.imageScene?.steps ?? template.defaultSteps, config),- seed: imageGenerationSeed(current.imageScene?.seed ?? -1),+ canvasWidth: width, canvasHeight: height, steps: config.imageScene.steps,+ seed: imageGenerationSeed(config.imageScene.seed),referencePaths: views[firstView].references.flatMap((reference) => referenceImages(reference).map((image) => projectItemPath(session.record.folderPath, image)!)),refmods: referenceRefmodInputs(session.record.folderPath, views[firstView].references) };this.work.set(id, { id, image: true, characterSheet: { views, dimensions, sourceId, name: `Character sheet - ${source.name}`, index: 0 },