AI media harness for planning, generating, and editing locally
TypeScript
Add higher still-image resolutions
Bittic90968923f1d
diff --git a/src-tauri/src/project/validation/values.rs b/src-tauri/src/project/validation/values.rsindex 6cf4edb..f95761b 100644--- a/src-tauri/src/project/validation/values.rs+++ b/src-tauri/src/project/validation/values.rs@@ -3,9 +3,9 @@ pub(crate) fn is_supported_aspect_ratio(value: &str) -> bool {matches!(value, "16:9" | "9:16" | "1:1" | "4:5")}-/// The same nine names `resolutionSchema` in src/lib/project.ts accepts, and no+/// The same names `resolutionSchema` in src/lib/project.ts accepts, and no/// others in either direction — this layer writes the file the frontend then-/// has to parse. The first six are the ladder a new project is created at, every+/// has to parse. The first eight include the two larger still-image sizes, every/// rung a multiple of 32 on both edges because that is what MiniMax H3/// generates at; the last three are names already on disk, kept so a project/// saved before the ladder was rebuilt still opens at the pixels it always had.@@ -14,7 +14,17 @@ pub(crate) fn is_supported_aspect_ratio(value: &str) -> bool {pub(crate) fn is_supported_resolution(value: &str) -> bool {matches!(value,- "416p" | "544p" | "640p" | "768p" | "1088p" | "1344p" | "720p" | "1080p" | "4k"+ "416p"+ | "544p"+ | "640p"+ | "768p"+ | "1088p"+ | "1344p"+ | "1536p"+ | "2048p"+ | "720p"+ | "1080p"+ | "4k")}diff --git a/src-tauri/src/tests/schema.rs b/src-tauri/src/tests/schema.rsindex 7f0d43d..218831a 100644--- a/src-tauri/src/tests/schema.rs+++ b/src-tauri/src/tests/schema.rs@@ -623,7 +623,7 @@ fn validator_accepts_every_boundary_the_frontend_schema_allows() {);}for resolution in [- "416p", "544p", "640p", "768p", "1088p", "1344p", "720p", "1080p", "4k",+ "416p", "544p", "640p", "768p", "1088p", "1344p", "1536p", "2048p", "720p", "1080p", "4k",] {let mut config = fixture();config.settings.resolution = resolution.into();diff --git a/src/components/ImageProject.integration.test.tsx b/src/components/ImageProject.integration.test.tsxindex ef6c739..224c853 100644--- a/src/components/ImageProject.integration.test.tsx+++ b/src/components/ImageProject.integration.test.tsx@@ -4,6 +4,7 @@ import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testiimport { afterEach, expect, it, vi } from "vitest";import { ProjectWorkspace } from "./ProjectWorkspace";import { PromptComposer } from "./PromptComposer";+import { choose } from "./workspace/comboTestUtils";import { createProjectConfig, parseProjectConfig, type ProjectRecord } from "../lib/project";import { executeAgentCommands } from "../lib/runtime";import { imageScenePrompt } from "../lib/imageScene";@@ -164,8 +165,13 @@ 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");+ choose("Resolution", "2720 × 1536");+ fireEvent.click(screen.getByRole("radio", { name: "Video project" }));+ expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("1376 × 768 (default)");+ fireEvent.click(screen.getByRole("radio", { name: "Image project" }));+ choose("Resolution", "3648 × 2048");fireEvent.click(screen.getByRole("button", { name: /Create project/ }));- await waitFor(() => expect(submit).toHaveBeenCalledWith(expect.objectContaining({ generationType: "image" })));+ await waitFor(() => expect(submit).toHaveBeenCalledWith(expect.objectContaining({ generationType: "image", resolution: "2048p" })));});it("opens the three-tab image workspace and saves hierarchy/inspector edits through the project session", async () => {diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsxindex 45366ce..e1219e4 100644--- a/src/components/PromptComposer.tsx+++ b/src/components/PromptComposer.tsx@@ -2,7 +2,7 @@ import { useEffect, useId, useRef, useState } from "react";import { outputDimensions } from "../lib/export";import { useShortcut } from "../lib/commands";import type { AspectRatio, CreateProjectInput, ProjectConfig, Resolution } from "../lib/project";-import { PROJECT_RESOLUTIONS } from "../lib/project";+import { IMAGE_RESOLUTIONS, PROJECT_RESOLUTIONS } from "../lib/project";import { SHOT_TAG_GROUPS } from "../lib/shot-tags";import { ComboBox, ContentDialog, InfoBar, RadioGroup } from "./ui";@@ -47,8 +47,9 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, errconst [defaultLook, setDefaultLook] = useState(project?.settings.defaultLook ?? "");const nameInput = useRef<HTMLInputElement>(null);const id = useId();- const resolutions: readonly Resolution[] = project && !PROJECT_RESOLUTIONS.some((value) => value === project.settings.resolution)- ? [...PROJECT_RESOLUTIONS, project.settings.resolution] : PROJECT_RESOLUTIONS;+ const availableResolutions: readonly Resolution[] = generationType === "image" ? IMAGE_RESOLUTIONS : PROJECT_RESOLUTIONS;+ const resolutions: readonly Resolution[] = project && !availableResolutions.includes(project.settings.resolution)+ ? [...availableResolutions, project.settings.resolution] : availableResolutions;const blocked = busy || Boolean(checkingFolder) || Boolean(folderError) || !name.trim();const close = () => { if (!busy) onClose(); };@@ -96,6 +97,7 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, errdisabled={busy}onChange={(type) => {setGenerationType(type);+ if (type === "video" && !PROJECT_RESOLUTIONS.some((value) => value === resolution)) setResolution(DEFAULT_RESOLUTION);if (!folderPath && (name === "Untitled video" || name === "Untitled image")) setName(`Untitled ${type}`);}}options={[diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsxindex c174ffa..ce4b677 100644--- a/src/components/workspace/ImageEditor.test.tsx+++ b/src/components/workspace/ImageEditor.test.tsx@@ -94,9 +94,11 @@ it("displays each generated image at its saved aspect ratio independently of futconst current = setup(initial);const frame = screen.getByLabelText("Image placement canvas").parentElement!;expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));- choose("Resolution", /^\d+ × 1344$|^1344 × \d+$|1344/);+ choose("Resolution", "2720 × 1536");+ expect(current().settings.resolution).toBe("1536p");+ choose("Resolution", "3648 × 2048");choose("Aspect ratio", "1:1");- expect(current().settings).toMatchObject({ resolution: "1344p", aspectRatio: "1:1" });+ expect(current().settings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));fireEvent.click(screen.getByRole("button", { name: "View Tall" }));expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1088 / 1920));@@ -104,7 +106,7 @@ it("displays each generated image at its saved aspect ratio independently of futexpect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));const reopened = parseProjectConfig(JSON.parse(JSON.stringify(current())));expect(reopened.assets).toEqual(initial.assets);- expect(reopened.settings).toMatchObject({ resolution: "1344p", aspectRatio: "1:1" });+ expect(reopened.settings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });});it("removes generated images through their context menu and keeps the preview and thumbnail valid", () => {diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex c6431b3..78b0597 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -7,7 +7,7 @@ import { outputDimensions } from "../../lib/export";import { compileImagePrompt } from "../../lib/imagePrompt";import { createEmptyImage, restoreGeneratedImage, saveImageDraft } from "../../lib/imageHistory";import { isTauri } from "../../lib/persistence";-import { PROJECT_RESOLUTIONS, type ProjectConfig } from "../../lib/project";+import { IMAGE_RESOLUTIONS, type ProjectConfig } from "../../lib/project";import { defaultGeneratorTemplate, loadDebugOptionsEnabled, loadGeneratorTemplateSettings, subscribeDebugOptions, subscribeGeneratorTemplates, templateNeedsDownload, type GeneratorTemplate } from "../../lib/settings";import { isWorkActive, type WorkItem } from "../../lib/workQueue";import type { ConfigUpdate } from "./TimelineView";@@ -579,7 +579,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene<PropRow label="Steps" htmlFor={rootField("steps")}><input id={rootField("steps")} className="text-field" type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></PropRow><PropRow label="Seed" htmlFor={rootField("seed")}><input id={rootField("seed")} className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} data-tooltip="-1 picks a random seed" onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></PropRow><PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={config.settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }} /></PropRow>- <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow>+ <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...IMAGE_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow></PropSection><PropSection title="Style" persistKey="image.style"><PropRow label="Mode" htmlFor={rootField("mode")}><ComboBox id={rootField("mode")} aria-label="Mode" value={scene.style.mode} options={[{ value: "photo", label: "Photo" }, { value: "art", label: "Art" }]} onChange={(value) => commit({ ...scene, style: { ...scene.style, mode: value as "photo" | "art" } })} /></PropRow>diff --git a/src/components/workspace/ImageExportView.test.tsx b/src/components/workspace/ImageExportView.test.tsxindex a818318..96763c7 100644--- a/src/components/workspace/ImageExportView.test.tsx+++ b/src/components/workspace/ImageExportView.test.tsx@@ -48,10 +48,13 @@ it("sends the chosen size, format and JPG quality, and hides quality for PNG", avi.mocked(invoke).mockResolvedValue(true);render(<ImageExportView config={withOutput({ width: 2048, height: 1152 })} folderPath="D:/Images" />);fireEvent.change(screen.getByRole("slider", { name: "JPG quality" }), { target: { value: "60" } });+ fireEvent.click(screen.getByRole("combobox", { name: "Resolution" }));+ expect(screen.getByRole("option", { name: "2720 × 1536" })).toBeInTheDocument();+ fireEvent.click(screen.getByRole("option", { name: "3648 × 2048" }));fireEvent.click(screen.getByRole("button", { name: "Export…" }));await waitFor(() => expect(invoke).toHaveBeenCalledWith("export_generated_image", {folderPath: "D:/Images", relativePath: "media/generated/out.png",- options: { format: "jpg", width: 2048, height: 1152, quality: 60 },+ options: { format: "jpg", width: 3648, height: 2048, quality: 60 },}));expect(JSON.parse(localStorage.getItem("slopus.image-export.v1")!)).toEqual({ format: "jpg", quality: 60 });fireEvent.click(screen.getByRole("combobox", { name: "Format" }));diff --git a/src/components/workspace/ImageExportView.tsx b/src/components/workspace/ImageExportView.tsxindex 78d9008..54b9364 100644--- a/src/components/workspace/ImageExportView.tsx+++ b/src/components/workspace/ImageExportView.tsx@@ -1,7 +1,7 @@import { invoke } from "@tauri-apps/api/core";import { useState } from "react";import { outputDimensions } from "../../lib/export";-import { PROJECT_RESOLUTIONS, type ProjectConfig } from "../../lib/project";+import { IMAGE_RESOLUTIONS, type ProjectConfig } from "../../lib/project";import { isTauri } from "../../lib/persistence";import { ComboBox, EmptyState, InfoBar, PropRow, PropSection, Slider, Splitter, tooltipProps, usePaneSize } from "../ui";import { Image32 } from "../ui/icons";@@ -53,12 +53,12 @@ export function ImageExportView({ config, folderPath }: { config: ProjectConfig;try { localStorage.setItem(STORAGE_KEY, JSON.stringify(next)); } catch { /* remembered for this session only */ }};- /* The image's own size first, then the ladder at the project's aspect —- the same sizes the video export offers — skipping a rung that is it. */+ /* The image's own size first, then the image ladder at the project's aspect,+ skipping a rung that matches the original. */const original = output?.width && output?.height ? { width: output.width, height: output.height } : null;const sizes = [...(original ? [{ ...original, label: `${original.width} × ${original.height} (original)` }] : []),- ...PROJECT_RESOLUTIONS.map((resolution) => outputDimensions(resolution, config.settings.aspectRatio))+ ...IMAGE_RESOLUTIONS.map((resolution) => outputDimensions(resolution, config.settings.aspectRatio)).filter((size) => !original || sizeKey(size.width, size.height) !== sizeKey(original.width, original.height)).map((size) => ({ ...size, label: `${size.width} × ${size.height}` })),];diff --git a/src/lib/export.test.ts b/src/lib/export.test.tsindex fca7be6..b0e0129 100644--- a/src/lib/export.test.ts+++ b/src/lib/export.test.ts@@ -20,7 +20,7 @@ import {type ExportSegment,type ExportSettings,} from "./export";-import { createProjectConfig, LEGACY_RESOLUTIONS, PROJECT_RESOLUTIONS, type ProjectAsset, type ProjectConfig, type TimelineClip } from "./project";+import { createProjectConfig, IMAGE_RESOLUTIONS, LEGACY_RESOLUTIONS, PROJECT_RESOLUTIONS, type ProjectAsset, type ProjectConfig, type TimelineClip } from "./project";const asset = (id: string, overrides: Partial<ProjectAsset> = {}): ProjectAsset => ({id,@@ -119,7 +119,7 @@ describe("output geometry", () => {it("keeps both edges on a multiple of 32 in every shape a project can be", () => {// The whole point of the ladder: a frame the engine cannot generate is a// frame the project would have to rescale to fill.- for (const resolution of PROJECT_RESOLUTIONS) {+ for (const resolution of IMAGE_RESOLUTIONS) {for (const ratio of ["16:9", "9:16", "1:1", "4:5"] as const) {const { width, height } = outputDimensions(resolution, ratio);expect({ resolution, ratio, width: width % 32, height: height % 32 })@@ -133,7 +133,7 @@ describe("output geometry", () => {expect(outputDimensions("768p", "9:16")).toEqual({ width: 768, height: 1376 });expect(outputDimensions("768p", "1:1")).toEqual({ width: 768, height: 768 });expect(outputDimensions("768p", "4:5")).toEqual({ width: 768, height: 960 });- for (const resolution of PROJECT_RESOLUTIONS) {+ for (const resolution of IMAGE_RESOLUTIONS) {const wide = outputDimensions(resolution, "16:9");expect(outputDimensions(resolution, "9:16")).toEqual({ width: wide.height, height: wide.width });expect(outputDimensions(resolution, "1:1")).toEqual({ width: wide.height, height: wide.height });@@ -160,7 +160,7 @@ describe("output geometry", () => {});it("never produces an odd edge, which a 4:2:0 encoder refuses", () => {- for (const resolution of [...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]) {+ for (const resolution of [...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]) {for (const ratio of ["16:9", "9:16", "1:1", "4:5"] as const) {const { width, height } = outputDimensions(resolution, ratio);expect(width % 2).toBe(0);diff --git a/src/lib/export.ts b/src/lib/export.tsindex de897f4..533db4e 100644--- a/src/lib/export.ts+++ b/src/lib/export.ts@@ -182,6 +182,8 @@ const FRAME_SIZES: Record<Resolution, Record<AspectRatio, readonly [number, numb"768p": { "16:9": [1376, 768], "9:16": [768, 1376], "1:1": [768, 768], "4:5": [768, 960] },"1088p": { "16:9": [1920, 1088], "9:16": [1088, 1920], "1:1": [1088, 1088], "4:5": [1088, 1376] },"1344p": { "16:9": [2432, 1344], "9:16": [1344, 2432], "1:1": [1344, 1344], "4:5": [1344, 1696] },+ "1536p": { "16:9": [2720, 1536], "9:16": [1536, 2720], "1:1": [1536, 1536], "4:5": [1536, 1920] },+ "2048p": { "16:9": [3648, 2048], "9:16": [2048, 3648], "1:1": [2048, 2048], "4:5": [2048, 2560] },// Not offered for a new project; see LEGACY_RESOLUTIONS in project.ts."720p": { "16:9": [1280, 720], "9:16": [720, 1280], "1:1": [720, 720], "4:5": [720, 900] },"1080p": { "16:9": [1920, 1080], "9:16": [1080, 1920], "1:1": [1080, 1080], "4:5": [1080, 1350] },diff --git a/src/lib/project.test.ts b/src/lib/project.test.tsindex d047af8..2531e10 100644--- a/src/lib/project.test.ts+++ b/src/lib/project.test.ts@@ -27,7 +27,7 @@ import {roundClipTransform,seedProjectWorkspace,LEGACY_RESOLUTIONS,- PROJECT_RESOLUTIONS,+ IMAGE_RESOLUTIONS,STORY_TRACK_ID,usableImageReferences,usableReferenceImages,@@ -736,13 +736,13 @@ describe("project schema", () => {describe("the frame sizes a project can be", () => {it("accepts exactly the ladder plus the names already on disk, and nothing else", () => {- /* `is_supported_resolution` in src-tauri/src/project/validation/values.rs spells the same nine+ /* `is_supported_resolution` in src-tauri/src/project/validation/values.rs spells the samenames. They have to agree in BOTH directions: Rust writes the settingsfile before the frontend ever parses it, so a name Rust accepts and zodrefuses is saved and then fails to open (see CLAUDE.md). */- expect(resolutionSchema.options).toEqual([...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);+ expect(resolutionSchema.options).toEqual([...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);expect(resolutionSchema.options).toEqual([- "416p", "544p", "640p", "768p", "1088p", "1344p", "720p", "1080p", "4k",+ "416p", "544p", "640p", "768p", "1088p", "1344p", "1536p", "2048p", "720p", "1080p", "4k",]);for (const rejected of ["8k", "480p", "1080P", "768", ""]) {expect(resolutionSchema.safeParse(rejected).success).toBe(false);diff --git a/src/lib/project.ts b/src/lib/project.tsindex 2c65947..4ba4e3d 100644--- a/src/lib/project.ts+++ b/src/lib/project.ts@@ -130,13 +130,16 @@ export const aspectRatioSchema = z.enum(["16:9", "9:16", "1:1", "4:5"]);* the other has never heard of. */export const PROJECT_RESOLUTIONS = ["416p", "544p", "640p", "768p", "1088p", "1344p"] as const;+/** Still images offer two larger sizes, also aligned to the 32-pixel grid. */+export const IMAGE_RESOLUTIONS = [...PROJECT_RESOLUTIONS, "1536p", "2048p"] as const;+/** Names still on disk, from before the ladder was rebuilt on multiples of 32.* They keep their exact old pixels (1080p is still 1920×1080) and they are not* offered for a new project — a project is not resized behind its owner's* back, and 1080 is not a multiple of 32. */export const LEGACY_RESOLUTIONS = ["720p", "1080p", "4k"] as const;-export const resolutionSchema = z.enum([...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);+export const resolutionSchema = z.enum([...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);export const imageGenerationSnapshotSchema = z.object({scene: imageSceneSchema,