AI media harness for planning, generating, and editing locally
TypeScript
Fix H3 Image Zoom limits
Bittif4287e402575
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex b7501fe..65b8b9a 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -10,6 +10,8 @@ Changes since 0.4.0.## Fixes and improvements+- MiniMax H3 Image Zoom width and height fields now snap typed sizes to multiples of 32, keeping the displayed values in sync with the box.+- Fixed Zoom rejecting MiniMax H3 Image outputs above the older canvas limit; aligned outputs up to 20 MP are now supported.- MiniMax H3 Image now supports character sheets, using its image prompts, reference limits and six-step generation recipe.- Updated the bundled Slopfab runtime to 0.2.0, including a higher MiniMax H3 Image canvas limit of 20 MP.- MiniMax H3 Image resolution presets scale width and height by 1.675, rounded down to the 32-pixel grid. The largest preset is 6080 × 3424, within the 20 MP limit. Switching image models keeps the same preset position.diff --git a/src-tauri/src/commands/extend_image.rs b/src-tauri/src/commands/extend_image.rsindex d65ac5d..233c718 100644--- a/src-tauri/src/commands/extend_image.rs+++ b/src-tauri/src/commands/extend_image.rs@@ -19,6 +19,10 @@ pub(crate) struct ExtendSize {// Keep aligned with the largest current preset in src/lib/export.ts (2048p).const MAX_GENERATION_EDGE: u32 = 3648;const MAX_GENERATION_PIXELS: u64 = 3648 * 2048;+// The selection workspace stays compact; prepared output can use H3 Image's+// larger canvas. Keep these limits aligned with src/lib/extendImage.ts.+const MAX_OUTPUT_EDGE: u32 = 8192;+const MAX_OUTPUT_PIXELS: u64 = 20 * 1024 * 1024;fn source_dimensions(width: u32, height: u32) -> ExtendSize {let scale = 1.0f64@@ -54,14 +58,14 @@ fn scaled_layout(|| output.height == 0|| output.width % 32 != 0|| output.height % 32 != 0- || output.width > MAX_GENERATION_EDGE- || output.height > MAX_GENERATION_EDGE- || u64::from(output.width) * u64::from(output.height) > MAX_GENERATION_PIXELS{- return Err(- "Zoom output must be aligned to 32 pixels within the maximum generation resolution."- .into(),- );+ return Err("Zoom output dimensions must be positive multiples of 32.".into());+ }+ if output.width > MAX_OUTPUT_EDGE+ || output.height > MAX_OUTPUT_EDGE+ || u64::from(output.width) * u64::from(output.height) > MAX_OUTPUT_PIXELS+ {+ return Err("Zoom output exceeds the maximum canvas size (8192 pixels per edge and 20 MP).".into());}if bounds.is_contained(workspace.width, workspace.height) {return Ok((output, ExtendBounds { x: 0, y: 0, width: output.width, height: output.height }));@@ -467,6 +471,31 @@ mod tests {eprintln!("Inspect {}", artifact_dir.join("result.png").display());}+ #[test]+ fn zoom_accepts_h3_image_output_limits_for_crops_and_extensions() {+ for bounds in [+ ExtendBounds { x: 32, y: 32, width: 64, height: 32 },+ ExtendBounds { x: -64, y: -32, width: 256, height: 160 },+ ] {+ for output in [+ ExtendSize { width: 6080, height: 3424 },+ ExtendSize { width: 4544, height: 4544 },+ ExtendSize { width: 8192, height: 2560 },+ ] {+ let (_, mapped) = scaled_layout(128, 96, bounds, output).unwrap();+ assert_eq!((mapped.width, mapped.height), (output.width, output.height));+ }+ for output in [+ ExtendSize { width: 4608, height: 4608 },+ ExtendSize { width: 8224, height: 32 },+ ] {+ assert!(scaled_layout(128, 96, bounds, output).err().unwrap().contains("maximum canvas size"));+ }+ assert!(scaled_layout(128, 96, bounds, ExtendSize { width: 6081, height: 3424 })+ .err().unwrap().contains("multiples of 32"));+ }+ }+#[test]fn extend_layout_matches_the_scaled_generation_canvas_and_allows_selected_resolution() {let bounds = ExtendBounds {@@ -510,8 +539,8 @@ mod tests {96,bounds,ExtendSize {- width: 3648,- height: 3648+ width: 4608,+ height: 4608}).is_err());diff --git a/src/components/workspace/CommittedNumberInput.tsx b/src/components/workspace/CommittedNumberInput.tsxindex b9792fe..6e2fa92 100644--- a/src/components/workspace/CommittedNumberInput.tsx+++ b/src/components/workspace/CommittedNumberInput.tsx@@ -3,11 +3,13 @@ import { useEffect, useState, type InputHTMLAttributes } from "react";/** A controlled number field that does not erase an in-progress keyboard edit.* Empty strings, a lone minus sign, and values below a minimum are legitimate* intermediate text; the parent only receives complete, valid numbers. */-export function CommittedNumberInput({ value, minimum, maximum, integer = false, onCommit, onChange: _onChange, onBlur: _onBlur, onKeyDown: _onKeyDown, ...input }: {+export function CommittedNumberInput({ value, minimum, maximum, integer = false, normalizeValue, onCommit, onChange: _onChange, onBlur: _onBlur, onKeyDown: _onKeyDown, ...input }: {value: number;minimum: number;maximum: number;integer?: boolean;+ /** Keep the field in sync when a valid value snaps to a model-specific grid. */+ normalizeValue?: (value: number) => number;onCommit: (value: number) => void;} & Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "min" | "max">) {const [draft, setDraft] = useState(String(value));@@ -27,7 +29,8 @@ export function CommittedNumberInput({ value, minimum, maximum, integer = false,setDraft(String(value));return;}- const normalized = Math.max(minimum, Math.min(maximum, integer ? Math.round(parsed) : parsed));+ const clamped = Math.max(minimum, Math.min(maximum, integer ? Math.round(parsed) : parsed));+ const normalized = normalizeValue ? normalizeValue(clamped) : clamped;setDraft(String(normalized));onCommit(normalized);};@@ -42,7 +45,11 @@ export function CommittedNumberInput({ value, minimum, maximum, integer = false,const next = event.currentTarget.value;setDraft(next);const parsed = valid(next);- if (parsed !== null) onCommit(parsed);+ if (parsed !== null) {+ const normalized = normalizeValue ? normalizeValue(parsed) : parsed;+ if (normalizeValue) setDraft(String(normalized));+ onCommit(normalized);+ }}}onBlur={finish}onKeyDown={(event) => {diff --git a/src/components/workspace/Extend.test.tsx b/src/components/workspace/Extend.test.tsxindex a10fb5b..db54a25 100644--- a/src/components/workspace/Extend.test.tsx+++ b/src/components/workspace/Extend.test.tsx@@ -56,6 +56,33 @@ it("executes an optional-prompt extension at the changed resolution without chanexpect.objectContaining({ prompt: "", bounds: { x: -104, y: -74, width: 608, height: 448 } }));});+it("snaps typed H3 Image Zoom sizes even when they round back to the current box", () => {+ vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);+ vi.spyOn(persistence, "isTauri").mockReturnValue(true);+ vi.spyOn(settings, "templateUsable").mockReturnValue(true);+ const generator = settings.createGeneratorTemplate("H3 Image", "h3_image");+ settings.saveGeneratorTemplateSettings({ templates: [generator], defaultTemplateId: generator.id });+ settings.saveActiveGeneratorId("image", generator.id);+ const config = parseProjectConfig(fixture);+ config.assets = [source]; config.imageScene!.outputAssetId = source.id;+ const execute = vi.fn();+ render(<ImageEditor config={config} folderPath="D:/Images" onChange={vi.fn()} onGenerate={vi.fn()} onCancel={vi.fn()} onGenerateExtend={execute} />);+ fireEvent.click(screen.getByRole("button", { name: "Template" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Zoom" }));+ for (const [field, value, aligned] of [["width", 609, 608], ["height", 449, 448], ["width", 625, 640]] as const) {+ const input = screen.getByLabelText(`Zoom ${field}`);+ fireEvent.change(input, { target: { value: String(value) } });+ fireEvent.blur(input);+ expect(input).toHaveValue(aligned);+ expect(input).toBeValid();+ expect(screen.getByRole("button", { name: "Move Zoom box" })).toHaveAttribute(field, String(aligned));+ }+ expect(screen.getByRole("button", { name: "Execute" })).toBeEnabled();+ fireEvent.click(screen.getByRole("button", { name: "Execute" }));+ expect(execute).toHaveBeenCalledWith(expect.objectContaining({ modelType: "h3_image" }), source.id,+ expect.objectContaining({ bounds: { x: -104, y: -74, width: 640, height: 448 } }));+});+it("moves, resizes, redraws and cancels box drags in original pixel coordinates", () => {vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);let latest: ExtendBounds = { x: -96, y: -64, width: 576, height: 448 };diff --git a/src/components/workspace/ExtendSettings.tsx b/src/components/workspace/ExtendSettings.tsxindex d6c174d..b681653 100644--- a/src/components/workspace/ExtendSettings.tsx+++ b/src/components/workspace/ExtendSettings.tsx@@ -41,6 +41,8 @@ export function ExtendSettings({ config, source, options, onChange, onResolution{(["x", "y", "width", "height"] as const).map((field) => <PropRow key={field} label={field === "x" ? "X" : field === "y" ? "Y" : field === "width" ? "Width" : "Height"} htmlFor={`extend-${field}`}tooltip={field === "x" || field === "y" ? "Drag the box or its handles, or drag outside it to draw a new box." : "Sizes use 32-pixel increments. The source is resized to fit the box at the selected generation resolution."}><SliderNumberInput id={`extend-${field}`} aria-label={`Zoom ${field}`} integer step={field === "x" || field === "y" ? 1 : EXTEND_GRID} minimum={field === "x" || field === "y" ? -8192 : EXTEND_GRID} maximum={field === "x" || field === "y" ? 8192 : EXTEND_MAX_EDGE} required disabled={busy}+ normalizeValue={template.modelType === "h3_image" && (field === "width" || field === "height")+ ? (value) => alignExtendBounds({ ...options.bounds, [field]: value }, field === "width" ? "e" : "s")[field] : undefined}value={options.bounds[field]} onCommit={(value) => {const bounds = { ...options.bounds, [field]: value };onChange({ ...options, bounds: field === "width" || field === "height" ? alignExtendBounds(bounds, field === "width" ? "e" : "s") : { ...bounds, [field]: Math.round(value) } });diff --git a/src/lib/extendWork.test.ts b/src/lib/extendWork.test.tsindex 4e5c5bd..9f2a9f9 100644--- a/src/lib/extendWork.test.ts+++ b/src/lib/extendWork.test.ts@@ -120,6 +120,22 @@ it.each([false, true])("rejects images without saved pixels (draft: %s)", (imageexpect(enqueueSlopfabGeneration).not.toHaveBeenCalled();});+it("prepares and generates an H3 Image crop above the legacy Zoom output limit", async () => {+ const { queue, session } = setup();+ session.update((config) => ({ ...config, imageSettings: { resolution: "2048p", aspectRatio: "16:9" } }));+ const bounds = { x: 32, y: 32, width: 64, height: 64 };+ const saved = { ...result, width: 4544, height: 4544 };+ vi.mocked(invoke).mockImplementation(async (command) => command === "save_extended_image" ? saved : undefined);+ queue.enqueueExtendImage(session, { ...template, modelType: "h3_image" }, "source", { ...options(), bounds });+ const request = await submitted();+ expect(request).toMatchObject({ canvasWidth: 4544, canvasHeight: 4544, steps: 6,+ imageEdit: { edits: [expect.objectContaining({ width: 4544, height: 4544, strength: 1, invertMask: false })] } });+ expect(invoke).toHaveBeenCalledWith("prepare_extend_image", { folderPath: "C:/Extend", jobId: request.jobId, sourceId: "source", bounds, output: { width: 4544, height: 4544 } });+ emit("framesReady", request.jobId);+ await waitFor(() => expect(queue.getSnapshot()[0].status).toBe("completed"));+ expect(session.getSnapshot().config.assets.at(-1)).toMatchObject(saved);+});+it("passes prompt reference images and refmods to the extension", async () => {const { queue, session } = setup();session.update((config) => ({ ...config, references: [{ id: "trees", name: "Trees", kind: "image", description: "Tall pines", relativePath: "references/trees.png", intendedUse: [], createdAt: config.createdAt,