AI media harness for planning, generating, and editing locally
TypeScript
Share H3 image and video encoders
Bittic8d409451690
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 349a43b..908f689 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -6,7 +6,7 @@ Changes since 0.4.0.- **Video references:** Create a reference from a generated Scene or Shot using its context menu. Scenes select the whole video; Shots retain the full source with their exact time range selected. Video references now support clips shorter than two seconds.- **Song variations:** Duplicate a song into a draft with the same title, lyrics, style and settings. Use Generate's dropdown to queue up to 100 variations with different seeds.-- **MiniMax H3 Image:** Six-step image generation, image references, masked edits and Zoom on CUDA or Vulkan, with downloadable transformer variants, text encoders and its dedicated image VAE.+- **MiniMax H3 Image:** Six-step image generation, image references, masked edits and Zoom on CUDA or Vulkan, with downloadable transformer variants and its dedicated image VAE. Shares the selected text encoder and tokenizer with MiniMax H3 video, reusing existing downloads.## Fixes and improvementsdiff --git a/docs/slopfab-compatibility.md b/docs/slopfab-compatibility.mdindex 909f387..11e7efa 100644--- a/docs/slopfab-compatibility.md+++ b/docs/slopfab-compatibility.md@@ -11,6 +11,13 @@ BF16, INT8 ConvRot and W4A8 transformers, Qwen3-VL-32B INT8 or NVFP4 textencoders, and the FP16 image VAE. The repository's optional Qwen3.5 promptenhancer is not an inference text encoder and is not offered by this template.+MiniMax H3 Image and H3 video use the same shared text encoder and tokenizer+selection. Existing encoder downloads are reused, and changing the selection+updates both model families, including LAN submissions. Removing image model+weights retains the shared encoder. Previously separate image encoder files+and variants migrate once into the shared Text Encoders library without+changing its selected default. The image VAE remains specific to the image model.+Plain image prompts support up to 16 ordered pictures, including the implicitsource for edits and Zoom. Masked editing uses strength 1; outpainting disablesLangevin refinement and uses a nine-pixel blend overlap. Video/audio, LoRAs,diff --git a/src/components/H3ComponentSettings.tsx b/src/components/H3ComponentSettings.tsxindex 45a1fe7..bae59c6 100644--- a/src/components/H3ComponentSettings.tsx+++ b/src/components/H3ComponentSettings.tsx@@ -27,7 +27,7 @@ export function H3ComponentSettings({ settings, desktop }: { settings: Generatorreturn <>{([false, true] as const).map((encoders) => <SettingsGroup key={String(encoders)} heading={encoders ? "Text Encoders" : "VAEs"}><SettingsCard icon={<Add20 />} header={encoders ? "Add a text encoder" : "Add a VAE"}- description={encoders ? "The default text encoder is used whenever MiniMax H3 needs one. Missing files download with generators." : "Name video and audio VAEs, then select them in your generators."}>+ description={encoders ? "The default text encoder is shared by MiniMax H3 video and MiniMax H3 Image. Missing files download with generators." : "Name video and audio VAEs, then select them in your generators."}><button type="button" className="secondary-button" onClick={() => add(encoders ? "textEncoder" : "video")}>{encoders ? "New text encoder" : "New VAE"}</button></SettingsCard><div className="settings-card-list" role="list" aria-label={encoders ? "Text Encoders" : "VAEs"}>diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex 826b383..89e3c66 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -121,6 +121,25 @@ describe("the settings screen", () => {expect(screen.queryByRole("list", { name: "LoRAs" })).toBeNull();});+ it("selects the same text encoder for H3 Image and video while keeping the image VAE", () => {+ const settings = loadGeneratorTemplateSettings();+ settings.h3Components!.templates.push({ id: "shared-test", name: "Shared test encoder", type: "textEncoder", path: "D:/shared-text", tokenizer: "D:/tokenizer", sources: [] });+ saveGeneratorTemplateSettings(settings);+ const imageVae = settings.templates.find(({ id }) => id === "minimax-h3-image")!.paths.videoVae;+ open("MiniMax H3 Image");+ fireEvent.click(screen.getByRole("button", { name: "Edit MiniMax H3 Image generator" }));+ expect(screen.getByText("Image VAE weights")).toBeTruthy();+ expect(screen.queryByText("Text encoder weights")).toBeNull();+ fireEvent.click(combo("Shared H3 text encoder"));+ fireEvent.click(screen.getByRole("option", { name: "Shared test encoder" }));+ const updated = loadGeneratorTemplateSettings();+ expect(updated.h3Components!.defaultTextEncoderId).toBe("shared-test");+ for (const id of ["minimax-h3-image", "minimax-h3-original"]) {+ expect(updated.templates.find((template) => template.id === id)!.paths).toMatchObject({ textEncoder: "D:/shared-text", tokenizer: "D:/tokenizer" });+ }+ expect(updated.templates.find(({ id }) => id === "minimax-h3-image")!.paths.videoVae).toBe(imageVae);+ });+it("creates a generator for the selected model and follows model changes when returning", () => {open("MOSS");const defaultId = loadGeneratorTemplateSettings().defaultTemplateId;diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsxindex 424003d..bab06b5 100644--- a/src/components/SettingsView.tsx+++ b/src/components/SettingsView.tsx@@ -1,3 +1,4 @@+import { isSharedH3Field } from "../lib/h3Components";import { generatorOptions } from "./generatorOptions";import { DEFAULT_VIDEO_SIGMA_SHIFT, DEFAULT_AUDIO_SIGMA_SHIFT, MIN_SIGMA_SHIFT, MAX_SIGMA_SHIFT, isSigmaShift, SAMPLER_LABELS, SCHEDULER_LABELS, type Sampler, type Scheduler } from "../lib/sampling";import { AdditionalSafetensorsEditor } from "./AdditionalSafetensorsEditor";@@ -86,7 +87,7 @@ function templateSummary(template: GeneratorTemplate): string {}const hasDownloadedWeights = (template: GeneratorTemplate) =>- Object.entries(template.sources ?? {}).some(([id, sources]) => (template.modelType !== "minimax-h3" || id === "transformer") && sources.length > 0) || Boolean(template.additionalSafetensors?.length);+ Object.entries(template.sources ?? {}).some(([id, sources]) => !isSharedH3Field(template.modelType, id) && sources.length > 0) || Boolean(template.additionalSafetensors?.length);/* --- Shared pieces ---------------------------------------------------------- */@@ -663,7 +664,12 @@ export function SettingsView({ onClose, updates, initialTab = "engine", titleBar</SettingsGroup><SettingsGroup heading="Model files">- {generatorPathFields(selectedTemplate).filter(({ id }) => selectedTemplate.modelType !== "minimax-h3" || id === "transformer").map(pathCard)}+ {generatorPathFields(selectedTemplate).filter(({ id }) => !isSharedH3Field(selectedTemplate.modelType, id)).map(pathCard)}+ {isSharedH3Field(selectedTemplate.modelType, "textEncoder") && selectedTemplate.mode !== "animate" && <SettingsCard icon={<TextFile20 />} header="Text encoder" description="Shared by MiniMax H3 video and MiniMax H3 Image. Manage files under MiniMax H3 > Text Encoders.">+ <ComboBox aria-label="Shared H3 text encoder" value={templateSettings.h3Components!.defaultTextEncoderId}+ options={templateSettings.h3Components!.templates.filter((entry) => entry.type === "textEncoder").map((entry) => ({ value: entry.id, label: entry.name }))}+ onChange={(defaultTextEncoderId) => saveGeneratorTemplateSettings({ ...templateSettings, h3Components: { ...templateSettings.h3Components!, defaultTextEncoderId } })} />+ </SettingsCard>}{selectedTemplate.modelType === "minimax-h3" && (["video", "audio"] as const).map((type) => {const key = type === "video" ? "videoVaeId" : "audioVaeId";const label = type === "video" ? "Video VAE" : "Audio VAE";diff --git a/src/lib/agentGenerators.test.ts b/src/lib/agentGenerators.test.tsindex b6c5747..3bb192c 100644--- a/src/lib/agentGenerators.test.ts+++ b/src/lib/agentGenerators.test.ts@@ -81,7 +81,7 @@ it("rejects mixed project and generator batches before any mutation", async () =expect(invoke).not.toHaveBeenCalled();});-it("keeps legacy agent dependency edits connected to the shared H3 library", async () => {+it.each(["minimax-h3-original", "minimax-h3-image"])("keeps %s agent dependency edits connected to the shared H3 library", async (id) => {const before = loadGeneratorTemplateSettings();saveGeneratorTemplateSettings(before);vi.mocked(invoke).mockImplementation(async (_command, args) => {@@ -92,11 +92,11 @@ it("keeps legacy agent dependency edits connected to the shared H3 library", asy}return next;});- await executeGeneratorCommands([{ op: "generator.set", id: "minimax-h3-original", settings: { paths: {+ await executeGeneratorCommands([{ op: "generator.set", id, settings: { paths: {videoVae: "D:/custom-video.safetensors", textEncoder: "D:/shared-text.safetensors", tokenizer: "D:/tokenizer",} } }]);const saved = loadGeneratorTemplateSettings();- expect(saved.templates.find((entry) => entry.id === "minimax-h3-original")!.paths.videoVae).toBe("D:/custom-video.safetensors");+ expect(saved.templates.find((entry) => entry.id === id)!.paths.videoVae).toBe("D:/custom-video.safetensors");expect(saved.templates.find((entry) => entry.id === "minimax-h3-references")!.paths.videoVae).toBe(before.templates.find((entry) => entry.id === "minimax-h3-references")!.paths.videoVae);- expect(saved.templates.filter((entry) => entry.modelType === "minimax-h3").every((entry) => entry.paths.textEncoder === "D:/shared-text.safetensors" && entry.paths.tokenizer === "D:/tokenizer")).toBe(true);+ expect(saved.templates.filter((entry) => ["minimax-h3", "h3_image"].includes(entry.modelType)).every((entry) => entry.paths.textEncoder === "D:/shared-text.safetensors" && entry.paths.tokenizer === "D:/tokenizer")).toBe(true);});diff --git a/src/lib/agentGenerators.ts b/src/lib/agentGenerators.tsindex 3c56ae0..dde2914 100644--- a/src/lib/agentGenerators.ts+++ b/src/lib/agentGenerators.ts@@ -1,3 +1,4 @@+import { isSharedH3Field } from "./h3Components";import { invoke } from "@tauri-apps/api/core";import { loadLoras, saveLoras, type Lora } from "./loras";import { loadGeneratorTemplateSettings, saveGeneratorTemplateSettings, type GeneratorTemplate, type GeneratorTemplateSettings } from "./settings";@@ -24,7 +25,7 @@ export async function executeGeneratorCommands(commands: GeneratorCommand[]): Prif (command.op !== "generator.add" && command.op !== "generator.set") continue;const template = next.settings.templates.find((entry) => entry.id === command.id);const paths = command.settings.paths;- if (template?.modelType !== "minimax-h3" || !paths) continue;+ if (!template || !isSharedH3Field(template.modelType, "textEncoder") || !paths) continue;if (paths.videoVae !== undefined) delete template.videoVaeId;if (paths.audioVae !== undefined) delete template.audioVaeId;const library = next.settings.h3Components;diff --git a/src/lib/h3Components.test.ts b/src/lib/h3Components.test.tsindex e914876..99ab575 100644--- a/src/lib/h3Components.test.ts+++ b/src/lib/h3Components.test.ts@@ -2,7 +2,7 @@import { beforeEach, expect, it, vi } from "vitest";import { invoke } from "@tauri-apps/api/core";import { H3_VIDEO_VAE_ID, H3_AUDIO_VAE_ID, H3_TEXT_ENCODER_ID, SOL_H3_VAE_URL } from "./h3Components";-import { engineProviderSetting, loadGeneratorTemplateSettings, minimaxOriginalTemplate, minimaxFastTemplate, mossImageTemplate, saveGeneratorTemplateSettings, templateNeedsDownload } from "./settings";+import { engineProviderSetting, loadGeneratorTemplateSettings, minimaxImageTemplate, minimaxOriginalTemplate, minimaxFastTemplate, mossImageTemplate, saveGeneratorTemplateSettings, templateNeedsDownload } from "./settings";import { downloadH3Component, downloadTemplateWeights, getWeightDownloadState, refreshDownloadedWeights, removeTemplateWeights } from "./weightDownloads";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));@@ -133,3 +133,78 @@ it("does not treat a broken VAE link as ready or reuse project-carried dependencawait downloadTemplateWeights(template.id);expect(getWeightDownloadState()?.error).toContain("Video VAE");});++it("shares the selected encoder and tokenizer with H3 Image while retaining its dedicated VAE", () => {+ const settings = loadGeneratorTemplateSettings();+ const image = settings.templates.find(({ id }) => id === "minimax-h3-image")!;+ settings.h3Components!.templates.push({ id: "shared-text", name: "Shared text", type: "textEncoder", path: "D:/shared-text", tokenizer: "D:/tokenizer", sources: [] });+ settings.h3Components!.defaultTextEncoderId = "shared-text";+ saveGeneratorTemplateSettings(settings);+ for (const id of ["minimax-h3-image", "minimax-h3-original"]) {+ const template = loadGeneratorTemplateSettings().templates.find((entry) => entry.id === id)!;+ expect(template.paths).toMatchObject({ textEncoder: "D:/shared-text", tokenizer: "D:/tokenizer" });+ }+ const provider = engineProviderSetting(image.paths, undefined, image.attention, [], "prompt", [], false, image.sources, image);+ expect(provider.options).toMatchObject({ modelType: "h3_image", textEncoder: "D:/shared-text", tokenizer: "D:/tokenizer" });+ const resolved = loadGeneratorTemplateSettings().templates.find(({ id }) => id === image.id)!;+ expect(resolved.paths.videoVae).toBe(minimaxImageTemplate().paths.videoVae);+ expect(resolved.videoVaeId).toBeUndefined();+ expect(resolved.paths.audioVae).toBe("");+});++it("reuses the video encoder download for images and retains it when removing image weights", async () => {+ await downloadTemplateWeights("minimax-h3-original");+ const encoder = loadGeneratorTemplateSettings().templates.find(({ id }) => id === "minimax-h3-original")!.paths.textEncoder;+ vi.clearAllMocks();+ await downloadTemplateWeights("minimax-h3-image");+ expect(getWeightDownloadState()?.error).toBeNull();+ expect(downloads().sort()).toEqual([minimaxImageTemplate().sources!.transformer![2].url, minimaxImageTemplate().paths.videoVae].sort());+ expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "minimax-h3-image")!.paths.textEncoder).toBe(encoder);+ await removeTemplateWeights("minimax-h3-image");+ expect([...files.values()]).toContain(encoder);+ expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "minimax-h3-original")!.paths.textEncoder).toBe(encoder);+});++it("preserves previously separate image encoders once without changing the shared selection", () => {+ const settings = loadGeneratorTemplateSettings();+ const image = minimaxImageTemplate();+ image.paths.textEncoder = "D:/previous-image-text";+ image.paths.tokenizer = "D:/previous-image-tokenizer";+ image.sources!.textEncoder![1].downloadedPath = image.paths.textEncoder;+ settings.templates = [image];+ const selected = settings.h3Components!.defaultTextEncoderId;+ localStorage.setItem("slopus.generator-templates.v1", JSON.stringify(settings));+ const migrated = loadGeneratorTemplateSettings();+ expect(migrated.h3Components!.defaultTextEncoderId).toBe(selected);+ expect(migrated.h3Components!.templates).toContainEqual(expect.objectContaining({ type: "textEncoder", path: image.paths.textEncoder, tokenizer: image.paths.tokenizer, sources: image.sources!.textEncoder }));+ expect(loadGeneratorTemplateSettings()).toEqual(migrated);+ expect(JSON.parse(localStorage.getItem("slopus.generator-templates.v1")!).h3Components).toEqual(migrated.h3Components);+});++it("requires a shared image encoder and never falls back to stale project paths", async () => {+ const settings = loadGeneratorTemplateSettings();+ settings.h3Components!.templates = [];+ settings.h3Components!.defaultTextEncoderId = "";+ settings.templates = settings.templates.filter(({ id }) => id === "minimax-h3-image").map((template) => ({ ...template,+ paths: { ...template.paths, textEncoder: "", tokenizer: "" }, sources: { ...template.sources, textEncoder: [], tokenizer: [] } }));+ saveGeneratorTemplateSettings(settings);+ const template = loadGeneratorTemplateSettings().templates[0];+ expect(templateNeedsDownload(template)).toBe(true);+ const provider = engineProviderSetting(template.paths, { enabled: true, model: null, options: { textEncoder: "D:/stale", tokenizer: "D:/stale-tokenizer" } }, template.attention, [], "prompt", [], false, template.sources, template);+ expect(provider.options.textEncoder).toBeUndefined();+ expect(provider.options.tokenizer).toBeUndefined();+ await downloadTemplateWeights(template.id);+ expect(getWeightDownloadState()?.error).toContain("Text encoder");+});++it("submits shared encoder download sources to LAN workers instead of the old image sources", () => {+ const image = minimaxImageTemplate();+ const settings = loadGeneratorTemplateSettings();+ const encoder = settings.h3Components!.templates.find(({ id }) => id === settings.h3Components!.defaultTextEncoderId)!;+ encoder.tokenizer = "https://example.com/shared-tokenizer.json";+ saveGeneratorTemplateSettings(settings);+ localStorage.setItem("slopus.generation-worker.v1", JSON.stringify({ id: "worker", name: "Worker", gpus: [] }));+ const provider = engineProviderSetting(image.paths, undefined, image.attention, [], "prompt", [], false, image.sources, image);+ expect(provider.options).toMatchObject({ textEncoder: encoder.path, tokenizer: encoder.tokenizer, videoVae: image.paths.videoVae });+ expect(JSON.parse(provider.options.workerWeightSources as string).textEncoder).toEqual(encoder.sources);+});diff --git a/src/lib/h3Components.ts b/src/lib/h3Components.tsindex cef49be..b6cff4a 100644--- a/src/lib/h3Components.ts+++ b/src/lib/h3Components.ts@@ -57,8 +57,13 @@ function normalizeComponents(value: unknown): H3Components {?? templates.find((entry) => entry.type === "textEncoder")?.id ?? "" };}+export function isSharedH3Field(modelType: string | undefined, field: string): boolean {+ return (modelType === "minimax-h3" && ["videoVae", "audioVae", "textEncoder", "tokenizer"].includes(field))+ || (modelType === "h3_image" && ["textEncoder", "tokenizer"].includes(field));+}+export function h3ComponentForField(template: GeneratorTemplate, field: EnginePathId, library: H3Components): H3ComponentTemplate | undefined {- if (template.modelType !== "minimax-h3") return undefined;+ if (!isSharedH3Field(template.modelType, field)) return undefined;const type = field === "videoVae" ? "video" : field === "audioVae" ? "audio" : field === "textEncoder" || field === "tokenizer" ? "textEncoder" : undefined;const id = field === "videoVae" ? template.videoVaeId : field === "audioVae" ? template.audioVaeId : library.defaultTextEncoderId;return library.templates.find((entry) => entry.id === id && entry.type === type);@@ -66,9 +71,10 @@ export function h3ComponentForField(template: GeneratorTemplate, field: EnginePa/** Keep resolved paths for native/worker consumers, but shared templates own them. */export function resolveH3Components(template: GeneratorTemplate, library: H3Components): GeneratorTemplate {- if (template.modelType !== "minimax-h3") return template;+ if (!isSharedH3Field(template.modelType, "textEncoder")) return template;const paths = { ...template.paths }, sources = { ...template.sources };for (const field of ["videoVae", "audioVae", "textEncoder", "tokenizer"] as const) {+ if (!isSharedH3Field(template.modelType, field)) continue;const component = h3ComponentForField(template, field, library);paths[field] = field === "tokenizer" ? component?.tokenizer ?? "" : component?.path ?? "";const tokenizerUrl = component?.tokenizerUrl ?? (isUrl(paths[field]) ? paths[field] : undefined);@@ -117,6 +123,12 @@ export function normalizeH3Library(templates: GeneratorTemplate[], value: unknow};const migratedEncoders: string[] = [];const linked = templates.map((template) => {+ if (template.modelType === "h3_image") {+ // Preserve former image-only encoder files and variants in the shared+ // library, without replacing the encoder already selected for H3 video.+ if (!template.sharedTextEncoder && (template.paths.textEncoder || template.sources?.textEncoder?.length)) migrate(template, "textEncoder");+ return { ...template, sharedTextEncoder: true };+ }if (template.modelType !== "minimax-h3") return template;const next = { ...template };for (const field of ["videoVae", "audioVae"] as const) {diff --git a/src/lib/h3Image.test.ts b/src/lib/h3Image.test.tsindex 062d4da..d71e73a 100644--- a/src/lib/h3Image.test.ts+++ b/src/lib/h3Image.test.ts@@ -1,6 +1,7 @@// @vitest-environment jsdomimport { beforeEach, expect, it } from "vitest";import { minimaxImageTemplate, loadGeneratorTemplateSettings, saveGeneratorTemplateSettings, generationStepsForTemplate, generationStepsWithLoras, generatorPathFields, engineProviderSetting, templateSupportsVideo, templateSupportsEditing, templateSamplingOptions } from "./settings";+import { resolveH3Components } from "./h3Components";import { compileImagePrompt } from "./imagePrompt";import { compileExtendImage } from "./extendImage";import { createImageEditScene } from "./imageScene";@@ -13,10 +14,10 @@ it("adds MiniMax H3 Image once without changing selected or custom generators, aconst custom = { ...minimaxImageTemplate(), id: "custom", name: "My images", paths: { ...minimaxImageTemplate().paths, transformer: "D:/model.safetensors" } };saveGeneratorTemplateSettings({ templates: [custom], defaultTemplateId: custom.id, catalogVersion: 22 });const migrated = loadGeneratorTemplateSettings();- expect(migrated.templates).toEqual([custom, minimaxImageTemplate()]);+ expect(migrated.templates).toEqual([custom, minimaxImageTemplate()].map(template => ({ ...resolveH3Components(template, migrated.h3Components!), sharedTextEncoder: true })));expect(loadGeneratorTemplateSettings()).toEqual(migrated);saveGeneratorTemplateSettings({ ...migrated, templates: [custom] });- expect(loadGeneratorTemplateSettings().templates).toEqual([custom]);+ expect(loadGeneratorTemplateSettings().templates).toEqual([{ ...resolveH3Components(custom, migrated.h3Components!), sharedTextEncoder: true }]);});it("offers image-only weights, all supported download variants and the fixed recipe", () => {diff --git a/src/lib/settings.test.ts b/src/lib/settings.test.tsindex 94c8298..e062e3f 100644--- a/src/lib/settings.test.ts+++ b/src/lib/settings.test.ts@@ -29,6 +29,12 @@ import {function generatorOwned(value: any): any {if (Array.isArray(value)) return value.map(generatorOwned);+ if (value?.modelType === "h3_image") {+ const { sharedTextEncoder: _shared, ...template } = value;+ const { textEncoder: _text, tokenizer: _tokenizer, ...paths } = template.paths;+ const { textEncoder: _sources, tokenizer: _tokenizerSources, ...sources } = template.sources ?? {};+ return { ...template, paths, sources };+ }if (!value || value.modelType !== "minimax-h3") return value;const { videoVaeId: _video, audioVaeId: _audio, ...template } = value;const { textEncoder: _text, tokenizer: _tokenizer, videoVae: _videoPath, audioVae: _audioPath, ...paths } = template.paths;diff --git a/src/lib/settings.ts b/src/lib/settings.tsindex 178d4c1..c7f4d73 100644--- a/src/lib/settings.ts+++ b/src/lib/settings.ts@@ -13,7 +13,7 @@* silently drops that path.*/import { isSigmaShift, isSampler, isScheduler, type SigmaShifts, type SamplingChoices, type Sampler, type Scheduler } from "./sampling";-import { initialH3Components, normalizeH3Library, resolveH3Components, type H3Components } from "./h3Components";+import { initialH3Components, isSharedH3Field, normalizeH3Library, resolveH3Components, type H3Components } from "./h3Components";import { generatorModel } from "./generatorModels";import { YUE2_DEFAULT_STEPS } from "./music";export { generatorModel, GENERATOR_MODELS } from "./generatorModels";@@ -105,6 +105,8 @@ export interface GeneratorTemplate extends SigmaShifts, SamplingChoices {paths: EngineSettings;videoVaeId?: string;audioVaeId?: string;+ /** Marks migration of the former image-only encoder into the H3 library. */+ sharedTextEncoder?: boolean;sources?: Partial<Record<EnginePathId, WeightSource[]>>;loras?: TemplateLora[];additionalSafetensors?: AdditionalSafetensor[];@@ -217,6 +219,7 @@ function workerWeight(value: string, sources: WeightSource[] | undefined): strinexport function templateNeedsDownload(template: GeneratorTemplate): boolean {return generatorPathFields(template).some(({ id }) => isDownloadUrl(template.paths[id])+ || (template.modelType === H3_IMAGE_MODEL_TYPE && id === "textEncoder" && !template.paths[id].trim())|| (template.modelType === MINIMAX_H3_MODEL_TYPE && (id === "videoVae" && template.videoVaeId !== undefined || id === "audioVae" && template.audioVaeId !== undefined || id === "textEncoder" && template.videoVaeId !== undefined) && !template.paths[id].trim())|| (!template.paths[id].trim() && (template.sources?.[id]?.length ?? 0) > 0))|| downloadableTemplateLoras(effectiveLoras(template.loras, [], template.modelType)).length > 0@@ -524,6 +527,7 @@ const normalizeTemplateSettings = (value: unknown, shareComponents = true): Gene...(typeof file.downloadedPath === "string" && file.downloadedPath.trim() && !isDownloadUrl(file.downloadedPath) ? { downloadedPath: file.downloadedPath } : {}) }];}) : [];return [{ id, name, modelType, defaultSteps, attention, paths, sources,+ ...(candidate.sharedTextEncoder === true ? { sharedTextEncoder: true } : {}),...(typeof candidate.videoVaeId === "string" ? { videoVaeId: candidate.videoVaeId } : {}),...(typeof candidate.audioVaeId === "string" ? { audioVaeId: candidate.audioVaeId } : {}),...(typeof candidate.editingModel === "boolean" ? { editingModel: candidate.editingModel } : {}),@@ -834,7 +838,8 @@ export function loadGeneratorTemplateSettings(): GeneratorTemplateSettings {localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(normalized));}const shared = normalizeTemplateSettings(normalized)!;- if (!normalized.h3Components) localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(shared));+ if (normalized.templates.some((template) => template.modelType === H3_IMAGE_MODEL_TYPE && !template.sharedTextEncoder)+ || JSON.stringify(normalized.h3Components) !== JSON.stringify(shared.h3Components)) localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(shared));return shared;}}@@ -934,10 +939,10 @@ export function saveEngineSettings(settings: EngineSettings): void {* already had rather than overwriting it with "". */export function engineProviderSetting(settings: EngineSettings, base?: ProviderSetting, attention = defaultGeneratorTemplate().attention, selection = defaultGeneratorTemplate().loras, mode = defaultGeneratorTemplate().mode, additionalSafetensors = defaultGeneratorTemplate().additionalSafetensors, motionCache = defaultGeneratorTemplate().motionCache ?? false, sources = defaultGeneratorTemplate().sources, shifts: SigmaShifts & SamplingChoices & { modelType?: string; editingModel?: boolean; kreaVariant?: "raw" | "turbo" } = defaultGeneratorTemplate(), sceneLoras: TemplateLora[] = []): ProviderSetting {// Resolve again at submission: a queued generator may predate a default encoder change.- if (shifts.modelType === MINIMAX_H3_MODEL_TYPE) {+ if (isSharedH3Field(shifts.modelType, "textEncoder")) {const library = loadGeneratorTemplateSettings().h3Components!;const resolved = resolveH3Components({ id: "", name: "", defaultSteps: 20, attention, ...shifts,- modelType: MINIMAX_H3_MODEL_TYPE, mode, paths: settings, sources } as GeneratorTemplate, library);+ modelType: shifts.modelType!, mode, paths: settings, sources } as GeneratorTemplate, library);// Legacy callers may supply only paths; named VAE links are resolved by the settings loader.settings = { ...settings, textEncoder: resolved.paths.textEncoder, tokenizer: resolved.paths.tokenizer,...("videoVaeId" in shifts ? { videoVae: resolved.paths.videoVae } : {}),@@ -1014,7 +1019,7 @@ export function engineProviderSetting(settings: EngineSettings, base?: ProviderSconst value = remote ? workerWeight(settings[field.id].trim(), sources?.[field.id]) : settings[field.id].trim();if (value && (remote || !isDownloadUrl(value))) options[field.id] = value;else if (isDownloadUrl(value) || [FIBO_MODEL_TYPE, KREA_MODEL_TYPE, H3_IMAGE_MODEL_TYPE].includes(shifts.modelType ?? "") && field.id === "tokenizer"- || shifts.modelType === MINIMAX_H3_MODEL_TYPE && field.id !== "transformer") delete options[field.id];+ || isSharedH3Field(shifts.modelType, field.id)) delete options[field.id];}return { enabled: base?.enabled ?? true, model: base?.model ?? null, options };}diff --git a/src/lib/weightDownloads.test.ts b/src/lib/weightDownloads.test.tsindex ebf5853..86e4e68 100644--- a/src/lib/weightDownloads.test.ts+++ b/src/lib/weightDownloads.test.ts@@ -18,7 +18,7 @@ it("downloads the three compatible H3 Image weights and makes the template readyconst template = minimaxImageTemplate();await downloadTemplateWeights(template.id);const urls = vi.mocked(invoke).mock.calls.filter(([command]) => command === "download_weight").map(([, args]) => (args as { url: string }).url);- expect(urls.sort()).toEqual([template.paths.transformer, template.sources!.textEncoder![0].url, template.paths.videoVae].sort());+ expect(urls.sort()).toEqual([template.paths.transformer, minimaxOriginalTemplate().paths.textEncoder, template.paths.videoVae].sort());const downloaded = loadGeneratorTemplateSettings().templates.find(({ id }) => id === template.id)!;expect(templateNeedsDownload(downloaded)).toBe(false);expect(downloaded.paths.audioVae).toBe("");diff --git a/src/lib/weightDownloads.ts b/src/lib/weightDownloads.tsindex b1f1f6b..5e92388 100644--- a/src/lib/weightDownloads.ts+++ b/src/lib/weightDownloads.ts@@ -8,7 +8,7 @@ import { chooseWeightSource, ENGINE_PATH_FIELDS, generatorPathFields, isDownloadtype EnginePathId, type GeneratorTemplate, type WeightGpu, type WeightSource } from "./settings";export type { WeightGpu } from "./settings";-import { h3ComponentForField, type H3ComponentTemplate } from "./h3Components";+import { isSharedH3Field, h3ComponentForField, type H3ComponentTemplate } from "./h3Components";export { chooseWeightSource };const gpuSources = (sources: WeightSource[], devices: WeightGpu[]) => sources.filter((source) =>@@ -288,7 +288,7 @@ async function runTemplateDownload(templateId: string): Promise<void> {const downloads = generatorPathFields(template).flatMap(({ id, label, required }) => {if (template.paths[id].trim() && !isDownloadUrl(template.paths[id])) return [];const sources = template.sources?.[id] ?? [];- if (!sources.length && required && template.modelType === "minimax-h3" && id !== "transformer") throw new Error(`Choose a ${label} template with a local file or download URL.`);+ if (!sources.length && required && isSharedH3Field(template.modelType, id)) throw new Error(`Choose a ${label} template with a local file or download URL.`);if (!sources.length) return [];const source = chooseDownloadSource(sources, devices ?? []);if (!source) throw new Error(`No ${ENGINE_PATH_FIELDS.find((field) => field.id === id)?.label} download matches this GPU and its memory.`);@@ -519,7 +519,7 @@ export async function removeTemplateWeights(templateId: string): Promise<void> {const template = loadGeneratorTemplateSettings().templates.find((template) => template.id === templateId);if (!template) return;const paths = [...new Set([- ...generatorPathFields(template).filter(({ id }) => template.modelType !== "minimax-h3" || id === "transformer").flatMap(({ id }) => (template.sources?.[id] ?? []).flatMap((source) => source.downloadedPath ? [source.downloadedPath] : [])),+ ...generatorPathFields(template).filter(({ id }) => !isSharedH3Field(template.modelType, id)).flatMap(({ id }) => (template.sources?.[id] ?? []).flatMap((source) => source.downloadedPath ? [source.downloadedPath] : [])),...(template.additionalSafetensors ?? []).flatMap((file) => file.downloadedPath ? [file.downloadedPath] : []),])];try {@@ -530,7 +530,7 @@ export async function removeTemplateWeights(templateId: string): Promise<void> {const restored = { ...template, paths: { ...template.paths }, sources: { ...template.sources } };restored.additionalSafetensors = template.additionalSafetensors?.map((file) => paths.includes(file.downloadedPath ?? "") ? { ...file, downloadedPath: undefined } : file);for (const { id } of generatorPathFields(template)) {- if (template.modelType === "minimax-h3" && id !== "transformer") continue;+ if (isSharedH3Field(template.modelType, id)) continue;const sources = template.sources?.[id];if (!sources?.length) continue;restored.paths[id] = (sources.find((source) => source.downloadedPath === template.paths[id]) ?? sources[0]).url;