AI media harness for planning, generating, and editing locally
TypeScript
Add character sheet resolution selection
Bitticabca6752bc4
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 1b95104..a221d3c 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 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.+- Configure a character sheet from the Image toolbar's Template menu, with reference-enabled prompts for clothing and other details and a resolution selection controlling sheet height (512–2048 px), 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.tsxindex 485913b..2d2526e 100644--- a/src/components/ImageProject.integration.test.tsx+++ b/src/components/ImageProject.integration.test.tsx@@ -45,6 +45,8 @@ it("opens template settings and executes only after configuring prompts and clotexpect(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);+ choose("Character sheet resolution", "2048 px high");+ expect(panel.getByText(/Sheet size:/)).toHaveTextContent("5504 × 2048 px");typePrompt(panel.getByRole("textbox", { name: "Character sheet prompt" }), "Soft studio lighting");const clothing = panel.getByRole("textbox", { name: "Clothing and accessories" });typePrompt(clothing, "Wear");@@ -54,7 +56,7 @@ it("opens template settings and executes only after configuring prompts and clotexpect(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]" });+ expect(generate).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ id: "test" }), "Selected", { prompt: "Soft studio lighting", clothing: "Wear @[ref:outfit]", height: 2048 });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 806d9b9..8afb834 100644--- a/src/components/workspace/CharacterSheetSettings.tsx+++ b/src/components/workspace/CharacterSheetSettings.tsx@@ -1,7 +1,7 @@import { useMemo, useState } from "react";-import { compileCharacterSheet, emptyCharacterSheetOptions, type CharacterSheetOptions } from "../../lib/characterSheet";+import { CHARACTER_SHEET_HEIGHTS, characterSheetDimensions, compileCharacterSheet, emptyCharacterSheetOptions, type CharacterSheetOptions } from "../../lib/characterSheet";import type { ProjectAsset, ProjectConfig } from "../../lib/project";-import { InfoBar, ItemHeader } from "../ui";+import { ComboBox, InfoBar, ItemHeader, PropRow } from "../ui";import { Dismiss16, Sparkle16 } from "../ui/icons";import { PromptTextField, type PromptReference } from "./PromptTextField";@@ -10,13 +10,14 @@ export function CharacterSheetSettings({ config, source, references, missingLabedisabledReason: string | null; busy: boolean;onExecute: (options: CharacterSheetOptions) => void; onClose: () => void;}) {- const [options, setOptions] = useState(emptyCharacterSheetOptions);+ const [options, setOptions] = useState<CharacterSheetOptions>(() => ({ ...emptyCharacterSheetOptions(), height: characterSheetDimensions(config.settings.resolution)[0].height }));+ const dimensions = characterSheetDimensions(config.settings.resolution, options.height);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) => {+ const update = <K extends keyof CharacterSheetOptions,>(field: K, value: CharacterSheetOptions[K]) => {setOptions((current) => ({ ...current, [field]: value })); setError(null);};return <aside className="image-inspector image-template-settings" aria-label="Character sheet settings">@@ -30,6 +31,9 @@ export function CharacterSheetSettings({ config, source, references, missingLabe<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>+ <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><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>diff --git a/src/lib/characterSheet.test.ts b/src/lib/characterSheet.test.tsindex 06e508f..36943bc 100644--- a/src/lib/characterSheet.test.ts+++ b/src/lib/characterSheet.test.ts@@ -8,7 +8,7 @@ import { createProjectConfig, parseProjectConfig, type ProjectRecord } from "./pimport { cancelSlopfabGeneration, enqueueSlopfabGeneration, resolveSlopfabPlan } from "./runtime";import { EMPTY_ENGINE_SETTINGS, type GeneratorTemplate } from "./settings";import { WorkQueue } from "./workQueue";-import { characterSheetDimensions } from "./characterSheet";+import { CHARACTER_SHEET_HEIGHTS, characterSheetDimensions } from "./characterSheet";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn() }));@@ -100,6 +100,32 @@ it.each(["416p", "768p", "1080p", "2048p", "4k"] as const)("keeps exact aspect rfor (const { width, height } of sizes) { expect(width % 32).toBe(0); expect(height % 32).toBe(0); }});+it.each(CHARACTER_SHEET_HEIGHTS)("generates all four views at the selected %s px height", async (height) => {+ const { queue, session } = setup();+ const saved = { ...result, width: height * 43 / 16, height };+ vi.mocked(invoke).mockImplementation(async (command) => command === "combine_character_sheet" ? saved : undefined);+ const options = { prompt: "", clothing: "", height };+ queue.enqueueCharacterSheet(session, template, "source", options);+ expect(queue.getSnapshot()[0].settings.canvasHeight).toBe(height);+ options.height = 512; // Queued dimensions must not follow later settings edits.+ for (let index = 0; index < 4; index++) {+ const request = await requestAt(index);+ expect(request.canvasHeight).toBe(height);+ expect(request.canvasWidth).toBe(index === 1 ? height : height * 9 / 16);+ expect(request.canvasWidth % 32).toBe(0);+ emit("framesReady", request.jobId);+ }+ await waitFor(() => expect(queue.getSnapshot()[0].status).toBe("completed"));+ expect(session.getSnapshot().config.assets.at(-1)).toMatchObject(saved);+ expect(session.getSnapshot().config.settings.resolution).toBe("768p");+});++it("rejects unsupported sheet heights before queueing generation", () => {+ const { queue, session } = setup();+ expect(() => queue.enqueueCharacterSheet(session, template, "source", { prompt: "", clothing: "", height: 8192 })).toThrow("supported character sheet height");+ expect(queue.getSnapshot()).toHaveLength(0);+});+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 6563e68..e2ae21d 100644--- a/src/lib/characterSheet.ts+++ b/src/lib/characterSheet.ts@@ -13,13 +13,15 @@ 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 CHARACTER_SHEET_HEIGHTS = [512, 1024, 1536, 2048] as const;+export interface CharacterSheetOptions { prompt: string; clothing: string; height?: number }export const emptyCharacterSheetOptions = (): CharacterSheetOptions => ({ prompt: "", clothing: "" });-export function characterSheetDimensions(resolution: ProjectConfig["settings"]["resolution"]) {+export function characterSheetDimensions(resolution: ProjectConfig["settings"]["resolution"], requestedHeight?: number) {// 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.- const height = Math.max(512, Math.min(2048, Math.round(outputDimensions(resolution, "1:1").height / 512) * 512));+ if (requestedHeight !== undefined && !CHARACTER_SHEET_HEIGHTS.some((height) => height === requestedHeight)) throw new Error("Choose a supported character sheet height.");+ const height = requestedHeight ?? Math.max(512, Math.min(2048, Math.round(outputDimensions(resolution, "1:1").height / 512) * 512));return CHARACTER_SHEET_VIEWS.map((_, index) => ({ width: index === 0 ? height : height * 9 / 16, height }));}diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.tsindex a103942..91abdaa 100644--- a/src/lib/workQueue.ts+++ b/src/lib/workQueue.ts@@ -59,6 +59,7 @@ export interface WorkItem {interface PendingWork {characterSheet?: {views: ReturnType<typeof compileCharacterSheet>; sourceId: string; name: string; index: number;+ dimensions: ReturnType<typeof characterSheetDimensions>;ready?: { resolve: () => void; reject: (reason: Error) => void };};outputFrames?: number;@@ -275,8 +276,9 @@ export class WorkQueue {const id = `character-sheet-${crypto.randomUUID()}`;const frontRelativePath = `cache/character-sheets/${id}/1.png`;const views = compileCharacterSheet(config, source, frontRelativePath, options);+ const dimensions = characterSheetDimensions(config.settings.resolution, options?.height);const firstView = CHARACTER_SHEET_ORDER[0];- const { width, height } = characterSheetDimensions(config.settings.resolution)[firstView];+ 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,@@ -284,7 +286,7 @@ export class WorkQueue {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 },+ this.work.set(id, { id, image: true, characterSheet: { views, dimensions, 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),@@ -500,7 +502,7 @@ export class WorkQueue {private async generateCharacterSheet(work: PendingWork) {const sheet = work.characterSheet!;const folderPath = work.session.record.folderPath;- const dimensions = characterSheetDimensions(work.config.settings.resolution);+ const dimensions = sheet.dimensions;try {for (let index = 0; index < sheet.views.length; index++) {if (work.cancelled) return;