Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: harden MiniMax H3 output controls

[._.]/ Adam Eivy8ac2e7e7be43
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.js
index 816326d1a3..88fc00ac77 100644
--- a/client/src/hooks/useVideoGenForm.js
+++ b/client/src/hooks/useVideoGenForm.js
@@ -164,7 +164,8 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })
}, [incomingNegativePrompt]);
// When "Continue" pipes a video's last frame here, also sync the resolution
// so the new render matches the source. Width/height get rounded to the
- // model's 64-pixel grid server-side, so off-grid sources still work.
+ // selected model's declared resolution grid server-side, so off-grid sources
+ // still work.
useEffect(() => {
const w = Number(incomingWidth);
const h = Number(incomingHeight);
@@ -531,8 +532,8 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })
// on image upload stops overriding it (same flag the remix/deep-link paths set).
// ResolutionField passes a transient 0 mid-edit and blur-snaps each edge to the
// 64..2048 bound; the preview + FFLF-budget math guard against a transient 0,
- // and the server floors both dims to a multiple of 64 (generateVideo in
- // local.js) before enforcing the per-tier pixel budget.
+ // and the server floors both dims to the selected model's declared grid
+ // (generateVideo in local.js) before enforcing the per-tier pixel budget.
const handleResolutionChange = (w, h) => {
setWidth(w); setHeight(h); sizeManuallySetRef.current = true;
};
diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsx
index 5bbae88d4d..ccdb72759e 100644
--- a/client/src/hooks/useVideoGenForm.test.jsx
+++ b/client/src/hooks/useVideoGenForm.test.jsx
@@ -29,6 +29,7 @@ const H3 = {
frameOptions: [107, 124, 141, 158], fpsOptions: [24], defaultFrames: 124,
defaultWidth: 1344, defaultHeight: 768, resolutionStep: 32,
resolutionOptions: [
+ { label: '1536x672', w: 1536, h: 672 },
{ label: '1344x768', w: 1344, h: 768 },
{ label: '768x1344', w: 768, h: 1344 },
],
@@ -286,17 +287,18 @@ describe('useVideoGenForm', () => {
expect(payload.prompt).toBe('a fox watches the rain\n\nno music, no soundtrack');
});
- it('preserves a deliberately chosen custom resolution when switching to H3', async () => {
+ it('preserves H3 native 32px-grid geometry in the submitted payload', async () => {
const { result } = render({
models: [MLX, H3],
status: { connected: true, defaultModel: MLX.id },
});
await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
- act(() => result.current.handleResolutionChange(640, 384));
act(() => result.current.handleModelChange(H3.id));
await waitFor(() => expect(result.current.modelId).toBe(H3.id));
- expect(result.current.width).toBe(640);
- expect(result.current.height).toBe(384);
+ act(() => result.current.handleResolutionChange(1536, 672));
+ expect(result.current.width).toBe(1536);
+ expect(result.current.height).toBe(672);
+ expect(result.current.buildGeneratePayload()).toMatchObject({ width: 1536, height: 672 });
});
// H3's fl2va path anchors keyframes at the first/last latent frame, so image
diff --git a/client/src/lib/videoGenParams.js b/client/src/lib/videoGenParams.js
index b050ef7857..c3030d425f 100644
--- a/client/src/lib/videoGenParams.js
+++ b/client/src/lib/videoGenParams.js
@@ -79,10 +79,10 @@ export const supportsVideoAudioControls = (model) => model?.supportsDisableAudio
// Disable audio checkbox must stay hidden.
export const supportsVideoAudioPromptControls = (model) => model?.supportsAudioPrompting !== false;
-// Per-edge bounds for video: mirrors the videoGen route (64..2048) and the
-// server's floor-to-multiple-of-64 (generateVideo in local.js). Shared by the
-// ResolutionField control and the submit-time clamp so a hand-typed / mid-edit
-// value can never POST an out-of-range or 0 dimension.
+// Per-edge bounds for video: mirrors the videoGen route (64..2048). The base
+// grid is 64px, while a model may declare a finer resolutionStep (H3 uses 32).
+// Shared by the ResolutionField control and the submit-time clamp so a
+// hand-typed / mid-edit value can never POST an out-of-range or 0 dimension.
export const VIDEO_EDGE_BOUNDS = { min: 64, max: 2048, step: 64 };
export const videoEdgeBoundsForModel = (model) => {
const step = Number(model?.resolutionStep);
diff --git a/client/src/lib/videoGenResolutions.js b/client/src/lib/videoGenResolutions.js
index fb5176be9e..0288f5897b 100644
--- a/client/src/lib/videoGenResolutions.js
+++ b/client/src/lib/videoGenResolutions.js
@@ -42,8 +42,8 @@ export const defaultResolutionForModel = (model) => {
// Pick the preset whose aspect ratio is closest to a source image's, so an I2V
// default doesn't cover-crop the subject out of a mismatched frame (the server
// resizes the source with force_original_aspect_ratio=increase,crop). Every
-// preset is already 64-aligned, so the nearest-aspect preset IS the nearest
-// 64-aligned size that matches the image — no rounding needed here. Aspect
+// preset already satisfies its model's declared resolution grid, so the
+// nearest-aspect preset needs no additional rounding here. Aspect
// error is compared in log space so a too-wide and an equally-too-tall preset
// are penalised symmetrically. Returns `{ w, h }`, or null when the inputs are
// unusable (non-positive dims / empty preset list) so the caller can no-op.
diff --git a/scripts/migrations/267-minimax-h3-native-output-controls.js b/scripts/migrations/267-minimax-h3-native-output-controls.js
index b294ac2c9a..8410744315 100644
--- a/scripts/migrations/267-minimax-h3-native-output-controls.js
+++ b/scripts/migrations/267-minimax-h3-native-output-controls.js
@@ -6,31 +6,18 @@
* - only the shipped PipeNetwork row is eligible;
* - frameOptions changes only when it is byte-for-byte the prior shipped list;
* - the native default-size pair is added only when both fields are absent;
- * - other resolution fields are added individually only when absent, so an
- * explicit custom value (including an empty options list) remains user-owned.
+ * - resolutionStep + resolutionOptions are one geometry contract and are added
+ * only when both are absent, so a partial custom contract stays user-owned.
*/
import { readMediaRegistry, writeMediaRegistry } from './_lib.js';
+import {
+ MINIMAX_H3_OUTPUT_PROFILE,
+ upgradeMiniMaxH3OutputControls,
+} from '../../server/lib/mediaModels.js';
const REL_PATH = 'data/media-models.json';
-const H3_ID = 'minimax_h3_8bit';
-const SHIPPED_REPO = 'pipenetwork/MiniMax-H3-MLX-8bit';
-const OLD_FRAME_OPTIONS = [124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
-const NEW_FRAME_OPTIONS = [107, ...OLD_FRAME_OPTIONS];
-const NATIVE_RESOLUTIONS = [
- { label: '1536x672 (21:9 H3 native)', w: 1536, h: 672 },
- { label: '1344x768 (16:9 H3 default)', w: 1344, h: 768 },
- { label: '1024x768 (4:3 H3 native)', w: 1024, h: 768 },
- { label: '768x768 (1:1 H3 native)', w: 768, h: 768 },
- { label: '768x1024 (3:4 H3 native)', w: 768, h: 1024 },
- { label: '768x1344 (9:16 H3 native)', w: 768, h: 1344 },
-];
-
-const sameValues = (left, right) => (
- Array.isArray(left)
- && left.length === right.length
- && left.every((value, index) => value === right[index])
-);
+const { id: H3_ID, shippedRepo: SHIPPED_REPO } = MINIMAX_H3_OUTPUT_PROFILE;
export default {
async up({ rootDir }) {
@@ -47,26 +34,11 @@ export default {
return;
}
- let changed = false;
- if (sameValues(entry.frameOptions, OLD_FRAME_OPTIONS)) {
- entry.frameOptions = [...NEW_FRAME_OPTIONS];
- changed = true;
- }
- if (!Object.hasOwn(entry, 'defaultWidth') && !Object.hasOwn(entry, 'defaultHeight')) {
- entry.defaultWidth = 1344;
- entry.defaultHeight = 768;
- changed = true;
- }
- if (!Object.hasOwn(entry, 'resolutionStep')) {
- entry.resolutionStep = 32;
- changed = true;
- }
- if (!Object.hasOwn(entry, 'resolutionOptions')) {
- entry.resolutionOptions = structuredClone(NATIVE_RESOLUTIONS);
- changed = true;
- }
+ const [upgraded] = upgradeMiniMaxH3OutputControls([entry]);
+ const changed = upgraded !== entry;
if (changed) {
+ Object.assign(entry, upgraded);
await writeMediaRegistry(path, config);
console.log(`📝 ${REL_PATH}: added MiniMax H3's 4-second option and native 768p canvases`);
} else {
diff --git a/scripts/migrations/267-minimax-h3-native-output-controls.test.js b/scripts/migrations/267-minimax-h3-native-output-controls.test.js
index 2d0a99accc..7ec2144d27 100644
--- a/scripts/migrations/267-minimax-h3-native-output-controls.test.js
+++ b/scripts/migrations/267-minimax-h3-native-output-controls.test.js
@@ -96,6 +96,22 @@ describe('migration 267 — MiniMax H3 native output controls', () => {
expect(readJson(path)).toEqual(registryWith(custom));
});
+ it('does not mix shipped presets with a partially customized geometry contract', async () => {
+ const customStep = { ...h3(), resolutionStep: 64 };
+ writeJson(path, registryWith(customStep));
+ await migration.up({ rootDir });
+ const withCustomStep = readJson(path).video.macos[0];
+ expect(withCustomStep.resolutionStep).toBe(64);
+ expect(withCustomStep).not.toHaveProperty('resolutionOptions');
+
+ const customOptions = { ...h3(), resolutionOptions: [] };
+ writeJson(path, registryWith(customOptions));
+ await migration.up({ rootDir });
+ const withCustomOptions = readJson(path).video.macos[0];
+ expect(withCustomOptions).not.toHaveProperty('resolutionStep');
+ expect(withCustomOptions.resolutionOptions).toEqual([]);
+ });
+
it('skips a user-repointed or deleted entry and a missing registry', async () => {
const forked = { ...h3(), repo: 'example-org/h3-fork' };
writeJson(path, registryWith(forked));
diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.js
index 90ea472a0b..d103b4462c 100644
--- a/server/lib/mediaModels.js
+++ b/server/lib/mediaModels.js
@@ -50,6 +50,60 @@ import { applyVideoSupportedModes } from './videoModeProfiles.js';
const REGISTRY_FILE = process.env.PORTOS_MEDIA_MODELS_FILE || join(PATHS.data, 'media-models.json');
const IS_WIN = process.platform === 'win32';
+// Migration 267 and the load-time normalizer share this exact shipped-profile
+// contract. The load-time half is essential because route imports can cache the
+// registry before bootstrap migrations run; a later registry edit would
+// otherwise persist that stale object over the migrated file in the same boot.
+export const MINIMAX_H3_OUTPUT_PROFILE = Object.freeze({
+ id: 'minimax_h3_8bit',
+ shippedRepo: 'pipenetwork/MiniMax-H3-MLX-8bit',
+ oldFrameOptions: Object.freeze([124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362]),
+ frameOptions: Object.freeze([107, 124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362]),
+ defaultWidth: 1344,
+ defaultHeight: 768,
+ resolutionStep: 32,
+ resolutionOptions: Object.freeze([
+ Object.freeze({ label: '1536x672 (21:9 H3 native)', w: 1536, h: 672 }),
+ Object.freeze({ label: '1344x768 (16:9 H3 default)', w: 1344, h: 768 }),
+ Object.freeze({ label: '1024x768 (4:3 H3 native)', w: 1024, h: 768 }),
+ Object.freeze({ label: '768x768 (1:1 H3 native)', w: 768, h: 768 }),
+ Object.freeze({ label: '768x1024 (3:4 H3 native)', w: 768, h: 1024 }),
+ Object.freeze({ label: '768x1344 (9:16 H3 native)', w: 768, h: 1344 }),
+ ]),
+});
+
+const sameValues = (left, right) => (
+ Array.isArray(left)
+ && left.length === right.length
+ && left.every((value, index) => value === right[index])
+);
+
+export const upgradeMiniMaxH3OutputControls = (list) => {
+ if (!Array.isArray(list)) return list;
+ const profile = MINIMAX_H3_OUTPUT_PROFILE;
+ return list.map((entry) => {
+ if (!isPlainObject(entry) || entry.id !== profile.id || entry.repo !== profile.shippedRepo) return entry;
+ let next = entry;
+ if (sameValues(next.frameOptions, profile.oldFrameOptions)) {
+ next = { ...next, frameOptions: [...profile.frameOptions] };
+ }
+ if (!Object.hasOwn(next, 'defaultWidth') && !Object.hasOwn(next, 'defaultHeight')) {
+ next = { ...next, defaultWidth: profile.defaultWidth, defaultHeight: profile.defaultHeight };
+ }
+ // The step and presets describe one geometry contract. If either side was
+ // customized, preserve the pair rather than installing presets that may be
+ // off-grid for the user's declared step (or vice versa).
+ if (!Object.hasOwn(next, 'resolutionStep') && !Object.hasOwn(next, 'resolutionOptions')) {
+ next = {
+ ...next,
+ resolutionStep: profile.resolutionStep,
+ resolutionOptions: profile.resolutionOptions.map((preset) => ({ ...preset })),
+ };
+ }
+ return next;
+ });
+};
+
const DEFAULT_REGISTRY = {
_doc: 'PortOS media model registry. Edit to add models, tune defaults, or switch the text encoder. Restart the server to apply changes.',
video: {
@@ -97,22 +151,15 @@ const DEFAULT_REGISTRY = {
// run as the default: dense attention already makes it a multi-hour
// render on current Apple Silicon.
defaultFrames: 124,
- frameOptions: [107, 124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362],
+ frameOptions: [...MINIMAX_H3_OUTPUT_PROFILE.frameOptions],
fpsOptions: [24],
// H3-Base was trained on a native 768px short edge. Its canvas resolver
// caps area at 768x1344 and rounds each edge to 32px; these are the
// exact outputs for the aspect ratios MiniMax documents.
- defaultWidth: 1344,
- defaultHeight: 768,
- resolutionStep: 32,
- resolutionOptions: [
- { label: '1536x672 (21:9 H3 native)', w: 1536, h: 672 },
- { label: '1344x768 (16:9 H3 default)', w: 1344, h: 768 },
- { label: '1024x768 (4:3 H3 native)', w: 1024, h: 768 },
- { label: '768x768 (1:1 H3 native)', w: 768, h: 768 },
- { label: '768x1024 (3:4 H3 native)', w: 768, h: 1024 },
- { label: '768x1344 (9:16 H3 native)', w: 768, h: 1344 },
- ],
+ defaultWidth: MINIMAX_H3_OUTPUT_PROFILE.defaultWidth,
+ defaultHeight: MINIMAX_H3_OUTPUT_PROFILE.defaultHeight,
+ resolutionStep: MINIMAX_H3_OUTPUT_PROFILE.resolutionStep,
+ resolutionOptions: MINIMAX_H3_OUTPUT_PROFILE.resolutionOptions.map((preset) => ({ ...preset })),
memoryGb: 128,
steps: 8,
guidance: 0,
@@ -822,7 +869,7 @@ const normalizeRegistry = (parsed) => {
// model this install deleted — or a hand-edited typo — is dropped with a
// warning instead of surfacing a Finish button targeting nothing.
const videoEntries = (entries) => sanitizeFinishProfiles(applyVideoFinishProfiles(
- applyVideoDisclosures(backfillRuntime(dropRetiredEntries(entries))),
+ applyVideoDisclosures(backfillRuntime(upgradeMiniMaxH3OutputControls(dropRetiredEntries(entries)))),
));
const macosEntries = videoEntries(macosResult.entries);
const windowsEntries = videoEntries(windowsResult.entries);
diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.js
index 5c2f47209c..95c796ec98 100644
--- a/server/lib/mediaModels.test.js
+++ b/server/lib/mediaModels.test.js
@@ -509,6 +509,61 @@ describe('mediaModels registry', () => {
});
});
+ // Like retirement, migration 267's H3 upgrade must also happen at LOAD:
+ // routes cache this registry before bootstrap migrations run, and mutators
+ // persist the cached object wholesale later in the same boot.
+ describe('MiniMax H3 output-control upgrade', () => {
+ const OLD_FRAMES = [124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
+ const shippedMacosIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))
+ .video.macos.map((entry) => entry.id);
+ const legacyH3 = (extra = {}) => ({
+ id: 'minimax_h3_8bit',
+ name: 'MiniMax H3',
+ repo: 'pipenetwork/MiniMax-H3-MLX-8bit',
+ runtime: 'minimax_h3',
+ defaultFrames: 124,
+ frameOptions: [...OLD_FRAMES],
+ steps: 8,
+ guidance: 0,
+ ...extra,
+ });
+ const writeRegistry = (entry) => writeFileSync(registryFile, JSON.stringify({
+ video: { macos: [entry], windows: [], defaultMacos: entry.id, defaultWindows: 'ltx_video' },
+ image: [],
+ textEncoders: [{ id: 't', label: 't', repo: 'r' }],
+ selectedTextEncoder: 't',
+ _shippedDefaults: { video: { macos: shippedMacosIds, windows: [] } },
+ }));
+
+ it('upgrades the cached legacy shipped row before migrations run', async () => {
+ writeRegistry(legacyH3());
+ const { loadMediaModels } = await import('./mediaModels.js');
+ const entry = loadMediaModels().video.macos[0];
+ expect(entry).toMatchObject({
+ defaultWidth: 1344,
+ defaultHeight: 768,
+ resolutionStep: 32,
+ });
+ expect(entry.frameOptions[0]).toBe(107);
+ expect(entry.resolutionOptions).toContainEqual({
+ label: '1536x672 (21:9 H3 native)', w: 1536, h: 672,
+ });
+ });
+
+ it('preserves a repointed row and a partial custom geometry contract', async () => {
+ writeRegistry(legacyH3({ repo: 'example-org/h3-fork' }));
+ let module = await import('./mediaModels.js');
+ expect(module.loadMediaModels().video.macos[0]).not.toHaveProperty('defaultWidth');
+
+ vi.resetModules();
+ writeRegistry(legacyH3({ resolutionStep: 64 }));
+ module = await import('./mediaModels.js');
+ const entry = module.loadMediaModels().video.macos[0];
+ expect(entry.resolutionStep).toBe(64);
+ expect(entry).not.toHaveProperty('resolutionOptions');
+ });
+ });
+
it('user-deleted built-in video model is NOT re-added on subsequent load', async () => {
const platformKey = process.platform === 'win32' ? 'windows' : 'macos';
const otherKey = process.platform === 'win32' ? 'macos' : 'windows';
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.js
index 50a6ab9ce5..d15aa9af88 100644
--- a/server/routes/videoGen.test.js
+++ b/server/routes/videoGen.test.js
@@ -449,8 +449,11 @@ describe('videoGen routes', () => {
termsGate: { id: 'minimax-h3-community-license-2026-08-02' },
supportedModes: ['text'],
defaultFrames: 124,
- frameOptions: [124, 141, 158],
+ frameOptions: [107, 124, 141, 158],
fpsOptions: [24],
+ defaultWidth: 1344,
+ defaultHeight: 768,
+ resolutionStep: 32,
steps: 8,
guidance: 0,
samplerLocked: true,
@@ -517,14 +520,26 @@ describe('videoGen routes', () => {
prompt: 'a fox watches the rain',
modelId: h3.id,
mode: 'text',
+ numFrames: 107,
+ fps: 24,
+ width: 1536,
+ height: 672,
});
expect(render.status).toBe(200);
// Nothing about the acceptance rides the job: the render re-resolves it
// from settings, so a withdrawal reaches work already in the queue.
expect(mediaJobQueue.enqueueJob).toHaveBeenCalledWith(expect.objectContaining({
kind: 'video',
- params: expect.not.objectContaining({ termsAcceptance: expect.anything() }),
+ params: expect.objectContaining({
+ modelId: h3.id,
+ numFrames: 107,
+ fps: 24,
+ width: 1536,
+ height: 672,
+ }),
}));
+ expect(mediaJobQueue.enqueueJob.mock.calls.at(-1)[0].params)
+ .not.toHaveProperty('termsAcceptance');
const asserted = await request(app).post('/api/video-gen/').send({
prompt: 'a fox watches the rain',
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 750df332e1..11e59c3472 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -891,6 +891,18 @@ export const DEFAULT_NUM_FRAMES = 121;
// a still regardless of how many frames carry it.
export const IC_STILL_REFERENCE_FRAMES = 9;
+const configuredVideoDimension = (value, fallback) => {
+ const configured = Number(value);
+ return Number.isFinite(configured) && configured >= 64 && configured <= 2048
+ ? configured
+ : fallback;
+};
+
+const resolveVideoDimensions = (model, width, height) => ({
+ width: width ?? configuredVideoDimension(model?.defaultWidth, 768),
+ height: height ?? configuredVideoDimension(model?.defaultHeight, 512),
+});
+
export async function generateVideo({ pythonPath, prompt, negativePrompt = '', modelId = defaultVideoModelId(), width = null, height = null, numFrames = null, fps = 24, steps, guidanceScale, seed, tiling = 'auto', disableAudio = false, sourceImagePath = null, uploadedTempPath = null, uploadedTempPaths = [], lastImagePath = null, keyframes = null, extendFromVideoPath = null, audioFilePath = null, audioStartSec = null, mode = null, imageStrength = null, loras = null, icReferencePaths = null, icStrength = null, icAttentionStrength = null, icSkipStage2 = false, hidden = false, jobId: providedJobId = null }) {
uploadedTempPaths = Array.isArray(uploadedTempPaths) ? uploadedTempPaths : [];
if (!prompt?.trim()) throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });
@@ -934,8 +946,10 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
audioStartSec,
icReferencePaths,
});
- width = width ?? model.defaultWidth ?? 768;
- height = height ?? model.defaultHeight ?? 512;
+ // Registry defaults are user-editable. Validate them at this internal-call
+ // boundary so an empty or malformed value cannot turn into a 0/NaN runner
+ // argument when the caller deliberately leaves the resolution unset.
+ ({ width, height } = resolveVideoDimensions(model, width, height));
numFrames = numFrames ?? model.defaultFrames ?? DEFAULT_NUM_FRAMES;
let wanModelPath = null;
const wanRequiredWeights = [];
@@ -1786,21 +1800,22 @@ export async function generateChainedVideo({ chunks, chunkPrompts, contextFrames
// pays the fixed per-render cost again, so the chain estimate is the
// per-chunk estimate times the chunk count — `chunks` is handed to the
// estimator rather than folding the chain into one oversized render.
- // The dimension/step defaults mirror generateVideo's own resolution (its
- // `width = 768, height = 512` parameter defaults and the samplerLocked step
- // rule); the estimator returns null on anything it can't resolve, so a drift
- // here degrades to "no estimate" rather than to a wrong number.
+ // The dimension/step defaults mirror generateVideo's model-aware resolution
+ // and samplerLocked step rule; the estimator returns null on anything it
+ // can't resolve, so malformed custom registry defaults degrade to the legacy
+ // canvas rather than producing a wrong or non-finite estimate.
// Deliberately placed AFTER `activeChain`/`jobs` are registered: it is the
// first await in this function, and a cancel arriving during the history
// read must still find the chain to stop.
const chainSteps = chainModel?.samplerLocked
? chainModel.steps
: (rest.steps ? Number(rest.steps) : chainModel?.steps);
+ const chainDimensions = resolveVideoDimensions(chainModel, rest.width, rest.height);
const chainEta = estimateRenderMs({
history: await loadHistory(),
modelId: rest.modelId || defaultVideoModelId(),
- width: rest.width ?? 768,
- height: rest.height ?? 512,
+ width: chainDimensions.width,
+ height: chainDimensions.height,
numFrames: rest.numFrames ?? chainModel?.defaultFrames ?? DEFAULT_NUM_FRAMES,
steps: chainSteps,
chunks: totalChunks,
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index 76ef2194ad..5793d839e1 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -256,6 +256,7 @@ beforeEach(async () => {
});
afterEach(() => {
+ settingsState.acceptedModelTerms = [];
vi.clearAllMocks();
});
@@ -327,6 +328,41 @@ async function runChainAndCaptureArgs(chainParams, totalChunks) {
// ─── tests ───────────────────────────────────────────────────────────────────
+describe('generateChainedVideo — model-aware ETA geometry', () => {
+ it('estimates an omitted H3 canvas at the model native default', async () => {
+ const { readJSONFile } = await import('../../lib/fileUtils.js');
+ vi.mocked(readJSONFile).mockResolvedValue([{
+ modelId: 'minimax_h3_8bit',
+ width: 1344,
+ height: 768,
+ numFrames: 124,
+ steps: 8,
+ renderMs: 10_000,
+ createdAt: '2026-01-01T00:00:00.000Z',
+ }]);
+ settingsState.acceptedModelTerms = [H3_TERMS];
+ const outerJobId = randomUUID();
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
+ let outerCompleted = false;
+ videoGenEvents.on('completed', (event) => {
+ if (event.generationId === outerJobId) outerCompleted = true;
+ });
+
+ await generateChainedVideo({
+ chunks: 2,
+ jobId: outerJobId,
+ pythonPath: '/usr/bin/python3',
+ modelId: 'minimax_h3_8bit',
+ prompt: 'test prompt',
+ mode: 'text',
+ });
+ expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('2 chunks, eta=20s (measured, n=1)'));
+ await vi.waitFor(() => expect(outerCompleted).toBe(true));
+ videoGenEvents.removeAllListeners('completed');
+ logSpy.mockRestore();
+ });
+});
+
describe('generateChainedVideo — continuation strategy (context window vs last frame)', () => {
// numFrames=25 → extendLatentFrames(25) = 3 latents = 24 new pixel frames.
//
@@ -2193,6 +2229,37 @@ describe('generateVideo — MiniMax H3 MLX contract', () => {
expect(args[args.indexOf('--height') + 1]).toBe('768');
expect(args[args.indexOf('--num-frames') + 1]).toBe('124');
});
+
+ it('falls back when user-edited model defaults are not valid dimensions', async () => {
+ const mediaModels = await import('../../lib/mediaModels.js');
+ const { spawnDetached } = await import('../../lib/detachedSpawn.js');
+ const getVideoModelsMock = vi.mocked(mediaModels.getVideoModels);
+ const catalog = getVideoModelsMock();
+ const spawnMock = vi.mocked(spawnDetached);
+ spawnMock.mockClear();
+ getVideoModelsMock.mockReturnValue(catalog.map((model) => (
+ model.id === 'minimax_h3_8bit'
+ ? { ...model, defaultWidth: '', defaultHeight: 'not-a-number' }
+ : model
+ )));
+
+ try {
+ await generateVideo({
+ jobId: 'h3-invalid-native-default',
+ modelId: 'minimax_h3_8bit',
+ prompt: 'a fox watches the rain',
+ mode: 'text',
+ });
+ } finally {
+ getVideoModelsMock.mockReturnValue(catalog);
+ }
+
+ const [, args] = spawnMock.mock.calls.find(([, childArgs]) => (
+ Array.isArray(childArgs) && childArgs.some((arg) => String(arg).endsWith('/generate_minimax_h3.py'))
+ ));
+ expect(args[args.indexOf('--width') + 1]).toBe('768');
+ expect(args[args.indexOf('--height') + 1]).toBe('512');
+ });
});
// H3's DiT is quantized, so LoRAs ride along only if the installed runner
@@ -2208,6 +2275,7 @@ describe('MiniMax H3 user LoRAs', () => {
loras: [{ filename: 'fox.safetensors', scale: 0.8 }],
});
+ beforeEach(() => { settingsState.acceptedModelTerms = [H3_TERMS]; });
afterEach(() => { h3LoraState.capable = false; h3LoraState.cached = null; });
// The model is decorated from the sync cache read, so on a capable install the