Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add character sheet template settings

Bitti749a607946e4
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index bddd6b3..17a2a54 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -4,7 +4,7 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve
## What's new
-- Generate a character sheet from the Image toolbar's Template menu: a square portrait and three 9:16 full-body views, combined into one PNG 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 reference-enabled prompts for clothing and other details, then select Execute. A square portrait 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.
- 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.tsx
index 7dc5984..82a77fb 100644
--- a/src/components/ImageProject.integration.test.tsx
+++ b/src/components/ImageProject.integration.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 { typePrompt } from "./workspace/promptTestUtils";
+import { placePromptCaret, typePrompt } from "./workspace/promptTestUtils";
import { afterEach, expect, it, vi } from "vitest";
import { ProjectWorkspace } from "./ProjectWorkspace";
import { PromptComposer } from "./PromptComposer";
@@ -23,13 +23,14 @@ vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefi
afterEach(() => { cleanup(); localStorage.clear(); vi.restoreAllMocks(); });
const record = (): ProjectRecord => ({ folderPath: "D:/Images", config: parseProjectConfig(fixture) });
-it("runs the character sheet template on the selected image and requires an image file", () => {
+it("opens template settings and executes only after configuring prompts and clothing references", () => {
vi.spyOn(persistence, "isTauri").mockReturnValue(true);
vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);
const template = { id: "test", name: "Test", modelType: "minimax-h3" as const, defaultSteps: 20, attention: "sage2" as const, paths: { ...EMPTY_ENGINE_SETTINGS, transformer: "D:/h3.safetensors" } };
saveGeneratorTemplateSettings({ defaultTemplateId: "test", templates: [template] });
const project = record();
project.config.assets = ["First", "Selected"].map((id) => ({ id, name: id, kind: "image", relativePath: `media/${id}.png`, mimeType: "image/png", createdAt: project.config.createdAt }));
+ project.config.references = [{ id: "outfit", name: "Red coat", kind: "image", description: "A red wool coat", relativePath: "references/coat.png", intendedUse: [], createdAt: project.config.createdAt }];
const queue = new WorkQueue(vi.fn(async (record) => record));
const generate = vi.spyOn(queue, "enqueueCharacterSheet").mockImplementation(() => undefined);
render(<ProjectWorkspace project={project} workQueue={queue} onBack={vi.fn()} onSave={vi.fn()} />);
@@ -39,9 +40,27 @@ it("runs the character sheet template on the selected image and requires an imag
toolbar.getByRole("button", { name: "Template" }).focus();
fireEvent.click(toolbar.getByRole("button", { name: "Template" }));
fireEvent.click(screen.getByRole("menuitem", { name: "Character sheet" }));
- expect(generate).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ id: "test" }), "Selected");
+ expect(generate).not.toHaveBeenCalled();
expect(screen.queryByRole("menu", { name: "Image templates" })).not.toBeInTheDocument();
- expect(toolbar.getByRole("button", { name: "Template" })).toHaveFocus();
+ expect(screen.queryByRole("complementary", { name: "Image node inspector" })).not.toBeInTheDocument();
+ const panel = within(screen.getByRole("complementary", { name: "Character sheet settings" }));
+ const before = structuredClone(queue.project(project).getSnapshot().config);
+ typePrompt(panel.getByRole("textbox", { name: "Character sheet prompt" }), "Soft studio lighting");
+ const clothing = panel.getByRole("textbox", { name: "Clothing and accessories" });
+ typePrompt(clothing, "Wear");
+ placePromptCaret(clothing);
+ fireEvent.click(within(clothing.closest(".image-inspector__area") as HTMLElement).getByRole("button", { name: "Reference" }));
+ fireEvent.click(screen.getByRole("button", { name: /Red coat/ }));
+ expect(clothing.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", clothing: "Wear @[ref:outfit]" });
+ 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" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Character sheet" }));
+ fireEvent.click(screen.getByRole("button", { name: "View First" }));
+ expect(screen.queryByRole("complementary", { name: "Character sheet settings" })).not.toBeInTheDocument();
});
it.each(["Create Scene", "Create Reference"])("opens and saves the item created by %s in the image bar", async (action) => {
diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsx
index d4e1a75..733872f 100644
--- a/src/components/ProjectWorkspace.tsx
+++ b/src/components/ProjectWorkspace.tsx
@@ -286,7 +286,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,
<ProjectStatusSlot.Provider value={statusSlot}>
<div className={`project-body${agentOpen ? " project-body--agent" : ""}`} style={agentPane.style}>
<div id={`${panelId}-view`} role="tabpanel" aria-label={VIEW_LABELS[view]} className={`project-content project-content--${view}`}>
- {view === "editor" && <ImageEditor config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template) => queue.enqueueImage(session, template)} onGenerateCharacterSheet={(template, sourceId) => queue.enqueueCharacterSheet(session, template, sourceId)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} onOpenReferences={() => setView("references")} />}
+ {view === "editor" && <ImageEditor config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template) => queue.enqueueImage(session, template)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); 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); setView("generator"); }} />}
{view === "generator" && <GeneratorView onGenerate={(submissions) => queue.enqueue(session, submissions)} onCancelGeneration={(ids) => queue.cancelScenes(session, ids)} cancellingJobIds={cancellingJobIds} config={config} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} runtime={runtime?.slopfab ?? null} onRuntimeChange={onGeneratorRuntimeChange} onChange={changeConfig} selectedJobId={selectedGenerationJobId} onSelectedJobChange={setSelectedGenerationJobId} onOpenTimeline={() => setView("timeline")} />}
{view === "references" && <ReferencesView config={config} folderPath={project.folderPath} onChange={changeConfig} onRegenerateIcon={(id) => queue.regenerateReferenceIcon(session, id)} onExportRefmod={(id, outputPath) => queue.exportReferenceRefmod(session, id, outputPath)} onGenerateBuiltinIcons={() => queue.generateBuiltinReferenceIcons(session)} onRegenerateBuiltinIcon={(id) => queue.regenerateBuiltinReferenceIcon(session, id)} pendingBuiltinIconIds={queue.pendingBuiltinIconIds()} pendingIconIds={new Set(config.references.filter((reference) => queue.isReferenceIconPending(session, reference.id)).map((reference) => reference.id))} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} />}
diff --git a/src/components/workspace/CharacterSheetSettings.tsx b/src/components/workspace/CharacterSheetSettings.tsx
new file mode 100644
index 0000000..806d9b9
--- /dev/null
+++ b/src/components/workspace/CharacterSheetSettings.tsx
@@ -0,0 +1,48 @@
+import { useMemo, useState } from "react";
+import { compileCharacterSheet, emptyCharacterSheetOptions, type CharacterSheetOptions } from "../../lib/characterSheet";
+import type { ProjectAsset, ProjectConfig } from "../../lib/project";
+import { InfoBar, ItemHeader } 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 }: {
+ config: ProjectConfig; source: ProjectAsset; references: PromptReference[]; missingLabel: (id: string) => string;
+ disabledReason: string | null; busy: boolean;
+ onExecute: (options: CharacterSheetOptions) => void; onClose: () => void;
+}) {
+ const [options, setOptions] = useState(emptyCharacterSheetOptions);
+ const [error, setError] = useState<string | null>(null);
+ const validation = useMemo(() => {
+ try { compileCharacterSheet(config, source, "cache/character-sheet-preview/1.png", options); return null; }
+ catch (reason) { return reason instanceof Error ? reason.message : String(reason); }
+ }, [config, source, options]);
+ const update = (field: keyof CharacterSheetOptions, value: string) => {
+ setOptions((current) => ({ ...current, [field]: value })); setError(null);
+ };
+ return <aside className="image-inspector image-template-settings" aria-label="Character sheet settings">
+ <ItemHeader name="Character sheet" meta="Template" actions={<button type="button" className="icon-button" aria-label="Close template settings" data-tooltip="Back to image settings" onClick={onClose}><Dismiss16 aria-hidden="true" /></button>} />
+ <form className="image-template-settings__form" onSubmit={(event) => {
+ event.preventDefault();
+ if (disabledReason || validation || busy) return;
+ try { setError(null); onExecute(options); }
+ catch (reason) { setError(reason instanceof Error ? reason.message : String(reason)); }
+ }}>
+ <div className="image-inspector__fields image-template-settings__fields">
+ <p className="image-inspector__caption">Source: {source.name}</p>
+ <p className="image-inspector__caption">A square portrait and three full-body views (front, side, back), combined into one image.</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, style, lighting, or other details…" />
+ </div>
+ <div className="image-inspector__area"><span>Clothing and accessories</span>
+ <PromptTextField aria-label="Clothing and accessories" value={options.clothing} onChange={(value) => update("clothing", value)} references={references} missingLabel={missingLabel} disabled={busy} placeholder="Describe the outfit or add clothing references…" />
+ </div>
+ <p className="image-inspector__caption">Leave these blank to keep the source appearance. Clothing instructions apply to the front view, then the same outfit is used for every angle.</p>
+ {(validation || error) && <InfoBar severity="error" title="Couldn't prepare the template" message={validation ?? error ?? ""} />}
+ </div>
+ <div className="image-template-settings__footer">
+ {disabledReason && <p className="image-inspector__caption">{disabledReason}</p>}
+ <button type="submit" className="primary-button" disabled={Boolean(disabledReason || validation || busy)}><Sparkle16 aria-hidden="true" />{busy ? "Executing…" : "Execute"}</button>
+ </div>
+ </form>
+ </aside>;
+}
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index 1228e4c..6aae522 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -15,6 +15,8 @@ import { ReferenceImage } from "./ReferenceImage";
import { PromptTextField } from "./PromptTextField";
import { ReferenceIcon } from "./ReferenceIcon";
import { ImageBar } from "./ImageBar";
+import { CharacterSheetSettings } from "./CharacterSheetSettings";
+import type { CharacterSheetOptions } from "../../lib/characterSheet";
import { DebugPromptDialog } from "./DebugPromptDialog";
import { TagEditor } from "./TagEditor";
import styleSuggestions from "../../lib/imageStyleSuggestions.json";
@@ -41,7 +43,7 @@ function UsedImageSeed({ id, seed, onError }: { id: string; seed: number | undef
export function ImageEditor({ config, folderPath, onChange: changeConfig, onGenerate, onGenerateCharacterSheet, onCancel, onOpenGenerator, onOpenReferences, workItems = [] }: {
config: ProjectConfig; folderPath: string; onChange: (update: ConfigUpdate) => void;
onGenerate: (template: GeneratorTemplate) => void; onCancel: (id: string) => Promise<void>; workItems?: readonly WorkItem[];
- onGenerateCharacterSheet?: (template: GeneratorTemplate, sourceId: string) => void;
+ onGenerateCharacterSheet?: (template: GeneratorTemplate, sourceId: string, options: CharacterSheetOptions) => void;
onOpenGenerator?: (jobId: string) => void;
onOpenReferences?: () => void;
}) {
@@ -64,6 +66,8 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null);
const [imageMenu, setImageMenu] = useState<{ id: string | null; x: number; y: number; inFamily: boolean; source: "bar" | "canvas" } | null>(null);
const templateMenu = useContextMenu();
+ const [templateSourceId, setTemplateSourceId] = useState<string | null>(null);
+ useEffect(() => setTemplateSourceId(null), [scene.outputAssetId]);
const imageResults = useRef<HTMLDivElement>(null);
const [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null);
const renameEnding = useRef(false);
@@ -546,9 +550,9 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
</div>
<div className="image-tools__end">
<button type="button" className="secondary-button" aria-haspopup="menu" aria-expanded={templateMenu.isOpen}
- disabled={!isTauri() || !onGenerateCharacterSheet || !output || (!output.relativePath && !output.sourcePath) || Boolean(active) || !template || !templateUsable(template)}
+ disabled={!output || (!output.relativePath && !output.sourcePath)}
onClick={(event) => templateMenu.open(event.currentTarget, [{ label: "Character sheet", icon: <Image16 />,
- onSelect: () => attempt(() => onGenerateCharacterSheet?.(template!, output!.id)),
+ onSelect: () => setTemplateSourceId(output!.id),
}], { "aria-label": "Image templates", placement: "bottom-end" })}>
Template <ChevronDown14 aria-hidden="true" />
</button>
@@ -640,7 +644,11 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
onMenu={(id, x, y, inFamily) => { setContextMenu(null); setImageMenu({ id, x, y, inFamily, source: "bar" }); }} />
</section>
<Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" />
- <aside className="image-inspector" aria-label="Image node inspector">
+ {output && templateSourceId === output.id ? <CharacterSheetSettings
+ config={config} source={output} references={promptReferences} missingLabel={missingReference} 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">
{/* The selected node heads the inspector, not an "Inspector" title. */}
{/* The name is edited in place in the header, as a shot's or a clip's
is; an image-edit root has no name of its own to change. */}
@@ -693,7 +701,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
</PropSection>}
</div>
{debugEnabled && <div className="debug-prompt"><button type="button" className="secondary-button debug-prompt__toggle" aria-haspopup="dialog" onClick={() => attempt(() => setDebugPrompt(imageRoot ? imageEditDebugPrompt(compileImageEdits(config).edits) : compileImagePrompt(config).prompt))}>Debug prompt</button></div>}
- </aside>
+ </aside>}
{debugEnabled && debugPrompt !== null && <DebugPromptDialog sceneTitle={config.name} segments={[{ kind: "brief", value: debugPrompt }]} onClose={() => setDebugPrompt(null)} />}
</div>;
}
diff --git a/src/lib/characterSheet.test.ts b/src/lib/characterSheet.test.ts
index a4b1d7d..06e508f 100644
--- a/src/lib/characterSheet.test.ts
+++ b/src/lib/characterSheet.test.ts
@@ -142,6 +142,41 @@ it("rejects an empty source without queuing work", () => {
expect(queue.getSnapshot()).toHaveLength(0);
});
+it("conditions every view on prompt references and freezes the requested outfit at execution", async () => {
+ const { queue, session } = setup();
+ session.update((current) => ({ ...current, references: [{ id: "coat", name: "Red coat", kind: "image", description: "A red wool coat", relativePath: "references/coat.png", intendedUse: [], createdAt: current.createdAt,
+ refmods: [{ id: "coat-style", name: "Coat style", relativePath: "references/coat.safetensors", strength: 0.75, copies: 1 }] }] }));
+ const options = { prompt: "Soft studio lighting", clothing: "Wear @[ref:coat] with black boots" };
+ queue.enqueueCharacterSheet(session, template, "source", options);
+ options.clothing = "Changed after execution";
+ const id = queue.getSnapshot()[0].id;
+ for (let index = 0; index < 4; index++) {
+ const request = await requestAt(index);
+ expect(request.referencePaths).toEqual(["C:/Character/media/hero.png", ...(index > 0 ? [`C:/Character/cache/character-sheets/${id}/1.png`] : []), "C:/Character/references/coat.png"]);
+ expect(request.refmods).toEqual([{ path: "C:/Character/references/coat.safetensors", strength: 0.75, copies: 1 }]);
+ expect(request.prompt).toContain("Template instructions: Soft studio lighting");
+ expect(request.prompt).toContain("Clothing and accessories: Wear <Subject 2> with black boots");
+ expect(request.prompt).not.toContain("@[ref:");
+ expect(request.prompt).not.toContain("Changed after execution");
+ expect(request.prompt).toContain(`<Subject 2> is Red coat, providing appearance from <Picture ${index === 0 ? 2 : 3}>`);
+ if (index === 0) expect(request.prompt).toContain("Apply the template's clothing instructions and references to establish the outfit");
+ 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[1].imageGeneration!.references.map((reference) => reference.id)).toEqual(["coat"]);
+ expect(reopened.assets[1].imageGeneration!.prompt).toContain("black boots");
+});
+
+it("rejects missing or excessive prompt references before starting a template", () => {
+ const { queue, session } = setup();
+ expect(() => queue.enqueueCharacterSheet(session, template, "source", { prompt: "", clothing: "@[ref:missing]" })).toThrow("no longer exists");
+ session.update((current) => ({ ...current, references: Array.from({ length: 8 }, (_, index) => ({ id: `ref-${index}`, name: `Outfit ${index}`, kind: "image" as const, description: "", relativePath: `references/${index}.png`, intendedUse: [], createdAt: current.createdAt })) }));
+ expect(() => queue.enqueueCharacterSheet(session, template, "source", { prompt: "", clothing: session.getSnapshot().config.references.map((reference) => `@[ref:${reference.id}]`).join(" ") })).toThrow("at most nine");
+ expect(queue.getSnapshot()).toHaveLength(0);
+ expect(enqueueSlopfabGeneration).not.toHaveBeenCalled();
+});
+
it("does not publish a partial result when combining fails and lets the next job run", async () => {
const { queue, session } = setup();
vi.mocked(invoke).mockImplementation(async (command) => {
diff --git a/src/lib/characterSheet.ts b/src/lib/characterSheet.ts
index 6a89d80..6563e68 100644
--- a/src/lib/characterSheet.ts
+++ b/src/lib/characterSheet.ts
@@ -13,6 +13,9 @@ export const CHARACTER_SHEET_VIEWS = [
// Establish the complete outfit before asking for any other camera angle.
export const CHARACTER_SHEET_ORDER = [1, 0, 2, 3] as const;
+export interface CharacterSheetOptions { prompt: string; clothing: string }
+export const emptyCharacterSheetOptions = (): CharacterSheetOptions => ({ prompt: "", clothing: "" });
+
export function characterSheetDimensions(resolution: ProjectConfig["settings"]["resolution"]) {
// A shared height divisible by 512 makes both 1:1 and 9:16 exact on H3's
// 32px grid, and keeps the combined image below the editor's 8192px limit.
@@ -20,23 +23,26 @@ export function characterSheetDimensions(resolution: ProjectConfig["settings"]["
return CHARACTER_SHEET_VIEWS.map((_, index) => ({ width: index === 0 ? height : height * 9 / 16, height }));
}
-export function characterSheetPrompts(config: ProjectConfig, source: ProjectAsset, frontRelativePath: string): string[] {
+export function compileCharacterSheet(config: ProjectConfig, source: ProjectAsset, frontRelativePath: string, options: CharacterSheetOptions = emptyCharacterSheetOptions()) {
+ let sourceReferenceId = "character-sheet-source";
+ while (config.references.some((reference) => reference.id === sourceReferenceId)) sourceReferenceId += "-source";
const reference: ProjectReference = {
- id: "character-sheet-source", kind: "text", name: source.name,
- description: "The character in the source image. Preserve the exact identity, facial features, body proportions, skin tone, hairstyle and hair color, clothing, footwear, accessories, materials and colors. Preserve the source's visual medium and rendering style. Do not redesign or change the outfit.",
+ id: sourceReferenceId, kind: "text", name: source.name,
+ description: "The character in the source image. Preserve the exact identity, facial features, body proportions, skin tone, hairstyle and hair color. Preserve clothing, footwear, accessories, materials and colors unless the template instructions explicitly change them. Preserve the source's visual medium and rendering style.",
intendedUse: ["character"], createdAt: source.createdAt,
images: [{ id: "character-sheet-source-image", name: source.name, relativePath: source.relativePath, sourcePath: source.sourcePath }],
};
return CHARACTER_SHEET_VIEWS.map((view, index) => {
const wardrobe = index === 1
- ? "Copy every visible garment from <Picture 1> exactly. For clothing outside its crop, complete one coherent outfit for this character; this full body front view will define the outfit for all other views."
+ ? "Apply the template's clothing instructions and references to establish the outfit. Where no change is requested, copy visible garments from <Picture 1> exactly. For clothing outside its crop, complete one coherent outfit for this character; this full body front view will define the outfit for all other views."
: "<Picture 1> is the original identity reference. <Picture 2> is the full body front view of this same character and the fixed wardrobe reference. Reproduce that exact outfit from the requested camera angle. Keep identical garment types, layers, cuts, lengths, fit, seams, closures, patterns, colors, fabric, footwear, jewelry and accessories. Do not add, remove, replace, restyle or recolor any clothing. Preserve anatomical left/right placement of asymmetric details when turning the character. Infer only hidden surfaces consistently with the same garments." + (index === 0 ? " Use frontal close-up framing while retaining the exact visible upper-body clothing." : " Change the camera angle from <Picture 2> to the requested side or back view.");
const selectedReference = index === 1 ? reference : { ...reference, images: [...reference.images!, { id: "character-sheet-front", name: "Full body front wardrobe reference", relativePath: frontRelativePath }] };
- const scene = createImageScene(`Create a character reference view of @[ref:${reference.id}]. ${view.description} ${wardrobe} Keep the same clothing, appearance and every identifying detail from the source image. Use a plain light gray background, soft even studio lighting, and no text, labels, borders, additional characters or multiple views. Match the source image's visual style.`);
+ const instructions = [options.prompt.trim() && `Template instructions: ${options.prompt.trim()}`, options.clothing.trim() && `Clothing and accessories: ${options.clothing.trim()}`].filter(Boolean).join("\n");
+ const scene = createImageScene(`Create a character reference view of @[ref:${reference.id}]. ${view.description} ${wardrobe} Preserve the character's identity. Use a plain light gray background and soft even studio lighting unless the template instructions specify otherwise. Render no text, labels, borders, additional characters or multiple views. Match the source image's visual style.\n${instructions}`);
scene.style = { mode: "art", medium: "the same visual medium and rendering style as <Picture 1>", aesthetics: "", lighting: "", detail: "" };
return compileImagePrompt({
- ...config, settings: { ...config.settings, defaultLook: null }, references: [selectedReference],
+ ...config, settings: { ...config.settings, defaultLook: null }, references: [selectedReference, ...config.references],
imageScene: scene,
- }).prompt;
+ });
});
}
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 609a4a9..a103942 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -3,7 +3,7 @@ import { invoke } from "@tauri-apps/api/core";
import { createImageEditScene, createImageScene, imageScenePrompt } from "./imageScene";
import { compileImageEdits, imageEditDebugPrompt } from "./imageEditing";
import { compileImagePrompt } from "./imagePrompt";
-import { CHARACTER_SHEET_ORDER, CHARACTER_SHEET_VIEWS, characterSheetDimensions, characterSheetPrompts } from "./characterSheet";
+import { CHARACTER_SHEET_ORDER, CHARACTER_SHEET_VIEWS, characterSheetDimensions, compileCharacterSheet, type CharacterSheetOptions } from "./characterSheet";
import { completeImageDraft, imageFamilyRoot, imageGenerationSnapshot, saveImageDraft } from "./imageHistory";
import type { ImageGenerationSnapshot } from "./project";
import { outputDimensions } from "./export";
@@ -58,7 +58,7 @@ export interface WorkItem {
}
interface PendingWork {
characterSheet?: {
- prompts: string[]; sourceId: string; name: string; index: number; frontRelativePath: string;
+ views: ReturnType<typeof compileCharacterSheet>; sourceId: string; name: string; index: number;
ready?: { resolve: () => void; reject: (reason: Error) => void };
};
outputFrames?: number;
@@ -262,7 +262,7 @@ export class WorkQueue {
settings: { frames: 1, steps: request.steps, seed: request.seed, canvasWidth: width, canvasHeight: height } }];
this.publish(); this.icons.yieldToVideo(); void this.pump();
}
- enqueueCharacterSheet(session: ProjectSession, template: GeneratorTemplate, sourceId: string) {
+ enqueueCharacterSheet(session: ProjectSession, template: GeneratorTemplate, sourceId: string, options?: CharacterSheetOptions) {
if (!isTauri()) throw new Error("Character sheet generation requires the desktop app.");
if (template.mode === "animate") throw new Error("Choose a prompt generator for the character sheet.");
const current = session.getSnapshot().config;
@@ -274,16 +274,19 @@ export class WorkQueue {
slopfab: engineProviderSetting(template.paths, current.providerSettings.slopfab, template.attention, template.loras, "prompt", template.additionalSafetensors, false, template.sources) } });
const id = `character-sheet-${crypto.randomUUID()}`;
const frontRelativePath = `cache/character-sheets/${id}/1.png`;
- const prompts = characterSheetPrompts(config, source, frontRelativePath);
+ const views = compileCharacterSheet(config, source, frontRelativePath, options);
const firstView = CHARACTER_SHEET_ORDER[0];
const { width, height } = characterSheetDimensions(config.settings.resolution)[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: prompts[firstView],
+ 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), referencePaths: [projectItemPath(session.record.folderPath, source)!] };
- this.work.set(id, { id, image: true, characterSheet: { prompts, sourceId, name: `Character sheet - ${source.name}`, index: 0, frontRelativePath },
- imageGeneration: { ...imageGenerationSnapshot(config, prompts.join("\n\n"), template.id), usedSeed: request.seed },
+ seed: imageGenerationSeed(current.imageScene?.seed ?? -1),
+ 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, sourceId, name: `Character sheet - ${source.name}`, index: 0 },
+ imageGeneration: { ...imageGenerationSnapshot(config, views.map((view) => view.prompt).join("\n\n"), template.id), usedSeed: request.seed,
+ references: [...new Map(views.flatMap((view) => view.references.slice(1)).map((reference) => [reference.id, reference])).values()] },
session, sceneId: current.imageScene?.nodes[0].id ?? "image-root", config, snapshot: JSON.stringify(current.imageScene),
request, submitted: false, cancelled: false, done, finish });
this.items = [...this.items, { id, kind: "image", imageAssetId: sourceId, projectKey, folderPath: session.record.folderPath, projectName: config.name,
@@ -497,18 +500,19 @@ export class WorkQueue {
private async generateCharacterSheet(work: PendingWork) {
const sheet = work.characterSheet!;
const folderPath = work.session.record.folderPath;
- const sourcePath = work.request.referencePaths[0];
const dimensions = characterSheetDimensions(work.config.settings.resolution);
try {
- for (let index = 0; index < sheet.prompts.length; index++) {
+ for (let index = 0; index < sheet.views.length; index++) {
if (work.cancelled) return;
sheet.index = index;
const viewIndex = CHARACTER_SHEET_ORDER[index];
const { width, height } = dimensions[viewIndex];
work.submitted = false;
- work.request = { ...work.request, jobId: `${work.id}-view-${viewIndex + 1}`, prompt: sheet.prompts[viewIndex],
+ const view = sheet.views[viewIndex];
+ work.request = { ...work.request, jobId: `${work.id}-view-${viewIndex + 1}`, prompt: view.prompt,
canvasWidth: width, canvasHeight: height,
- referencePaths: [sourcePath, ...(index > 0 ? [projectItemPath(folderPath, { relativePath: sheet.frontRelativePath })!] : [])] };
+ referencePaths: view.references.flatMap((reference) => referenceImages(reference).map((image) => projectItemPath(folderPath, image)!)),
+ refmods: referenceRefmodInputs(folderPath, view.references) };
this.patch(work.id, { status: "preparing", detail: `Preparing character sheet view ${index + 1}/4` });
await resolveSlopfabPlan(work.request, work.config, folderPath);
if (work.cancelled) return;
diff --git a/src/styles/image-editor.css b/src/styles/image-editor.css
index b38fab2..e015679 100644
--- a/src/styles/image-editor.css
+++ b/src/styles/image-editor.css
@@ -101,3 +101,8 @@
/* The editable name is the inspector's heading: an h2 around the input, laid
out as the input alone would be (as .generator-panel__name). */
.image-inspector__name { flex: 1; min-width: 0; display: flex; margin: 0; font: inherit; }
+
+.image-template-settings { overflow: hidden; }
+.image-template-settings__form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
+.image-template-settings__fields { flex: 1; min-height: 0; overflow: auto; }
+.image-template-settings__footer { flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--line); }