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: provision missing MiniMax MLX files before rendering

[._.]/ Adam Eivyef85ee09dd57
diff --git a/client/src/components/videoGen/ModelWorkflowHelp.jsx b/client/src/components/videoGen/ModelWorkflowHelp.jsx
index 978cacc99c..2f1de4d80f 100644
--- a/client/src/components/videoGen/ModelWorkflowHelp.jsx
+++ b/client/src/components/videoGen/ModelWorkflowHelp.jsx
@@ -1,12 +1,20 @@
// Advice uses runtime capabilities and declared Finish edges, never a guessed
// cross-model seed relationship. Changing size does not start a generation.
-export default function ModelWorkflowHelp({ model, models = [], onResolutionChange }) {
+export default function ModelWorkflowHelp({ model, mode, models = [], onResolutionChange }) {
if (!model) return null;
const fastH3 = model.runtime === 'fastvideo' && model.fastvideoFamily === 'fasth3';
const fastMetal = model.runtime === 'fastvideo' && !fastH3;
const finish = models.find((entry) => entry.id === model.finishModelId);
return (
+ <>
+ {mode === 'image' && models.some((entry) => entry.runtime === 'fastvideo' && !entry.supportedModes?.includes('image')) && (
+ <p className="mt-2 text-xs text-gray-400" role="note">
+ Image mode lists models with image conditioning in their installed runtime. The shipped FastMetal
+ and FastH3 MLX runners support text-to-video only, so they are available in Text mode.
+ For image-to-video, choose a compatible LTX, Wan, or MiniMax H3 model listed above.
+ </p>
+ )}
<details className="mt-2 rounded-lg border border-port-border px-3 py-2 text-xs text-gray-400">
<summary className="cursor-pointer text-gray-300">Choosing a model: preview → final</summary>
<div className="mt-2 space-y-2 leading-relaxed">
@@ -45,5 +53,6 @@ export default function ModelWorkflowHelp({ model, models = [], onResolutionChan
</p>
</div>
</details>
+ </>
);
}
diff --git a/client/src/components/videoGen/ModelWorkflowHelp.test.jsx b/client/src/components/videoGen/ModelWorkflowHelp.test.jsx
new file mode 100644
index 0000000000..32bc6797c2
--- /dev/null
+++ b/client/src/components/videoGen/ModelWorkflowHelp.test.jsx
@@ -0,0 +1,15 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+import ModelWorkflowHelp from './ModelWorkflowHelp';
+
+const model = { id: 'example-i2v', runtime: 'ltx25', supportedModes: ['text', 'image'] };
+const models = [model, { id: 'example-fast', runtime: 'fastvideo', supportedModes: ['text'] }];
+
+describe('image mode model guidance', () => {
+ it('explains missing text-only choices beside the image mode picker', () => {
+ const { rerender } = render(<ModelWorkflowHelp model={model} models={models} mode="image" />);
+ expect(screen.getByRole('note')).toHaveTextContent('FastMetal and FastH3 MLX runners support text-to-video only');
+ rerender(<ModelWorkflowHelp model={model} models={models} mode="text" />);
+ expect(screen.queryByRole('note')).not.toBeInTheDocument();
+ });
+});
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index fbd2e41ef5..dc55763f07 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -1649,7 +1649,7 @@ export default function VideoGen() {
onChange={(e) => handleModelChange(e.target.value)}
loading={modelsLoading}
/>
- <ModelWorkflowHelp model={currentModel} models={visibleModels} onResolutionChange={handleResolutionChange} />
+ <ModelWorkflowHelp model={currentModel} mode={mode} models={models} onResolutionChange={handleResolutionChange} />
{remixModelFallback && (
<p className="mt-1 text-[11px] text-port-accent leading-snug" role="status">
{remixModelFallback.sourceName} {remixModelFallback.samplerLocked && remixModelFallback.negativePromptUnsupported
diff --git a/server/services/videoGen/ensureWeights.js b/server/services/videoGen/ensureWeights.js
new file mode 100644
index 0000000000..f30ba76aaf
--- /dev/null
+++ b/server/services/videoGen/ensureWeights.js
@@ -0,0 +1,43 @@
+import { readFile } from 'node:fs/promises';
+import { findCachedRepoFile, isSafeHfRepoRelativePath } from '../../lib/hfCache.js';
+import { ServerError } from '../../lib/errorHandler.js';
+import { downloadHfRepo } from '../hfDownload.js';
+
+// The MLX transformer repo has no registry file list: its index owns the shard
+// inventory. Check metadata too, since a weight-only cache badge misses it.
+const transformerFiles = ['config.json', 'quant_config.json', 'model.safetensors.index.json'];
+const targetIsCached = async ({ repo, revision, only, indexed }) => {
+ const files = indexed ? transformerFiles : only;
+ const paths = await Promise.all(files.map((file) => findCachedRepoFile(repo, file, { revision })));
+ if (paths.some((path) => !path)) return false;
+ if (!indexed) return true;
+ let index;
+ try {
+ index = JSON.parse(await readFile(paths[2], 'utf8'));
+ } catch { return false; }
+ const shards = [...new Set(Object.values(index.weight_map || {}))];
+ if (!shards.length || shards.some((file) => !isSafeHfRepoRelativePath(file))) return false;
+ return (await Promise.all(shards.map((file) => findCachedRepoFile(repo, file, { revision })))).every(Boolean);
+};
+
+// Called only for an explicit render, after input/hardware validation. Keep the
+// Python renderer offline and finish provisioning before it is spawned.
+export async function ensureMiniMaxH3Weights(model) {
+ if (model.runtime !== 'minimax_h3') return;
+ const targets = [{ repo: model.repo, revision: model.revision,
+ only: model.repoFiles || [], indexed: !model.repoFiles?.length },
+ ...(model.requiredWeights || []).map((dep) => ({ ...dep, only: dep.files || [] }))];
+ for (const target of targets) {
+ if (!target.repo || (!target.indexed && !target.only.length)
+ || target.only.some((file) => !isSafeHfRepoRelativePath(file))) {
+ throw new ServerError('MiniMax H3 has an invalid weight manifest.', { status: 500, code: 'VIDEO_MODEL_MISCONFIGURED' });
+ }
+ if (await targetIsCached(target)) continue;
+ console.log('⬇️ MiniMax H3: completing missing model files before rendering');
+ const result = await downloadHfRepo({ repo: target.repo, revision: target.revision || null, only: target.only }).promise;
+ if (!result.ok || !(await targetIsCached(target))) {
+ throw new ServerError('MiniMax H3 automatic download did not complete the required model files. Retry when the download service is available.',
+ { status: 400, code: 'MINIMAX_H3_WEIGHTS_NOT_CACHED' });
+ }
+ }
+}
diff --git a/server/services/videoGen/ensureWeights.test.js b/server/services/videoGen/ensureWeights.test.js
new file mode 100644
index 0000000000..1fada3bbfe
--- /dev/null
+++ b/server/services/videoGen/ensureWeights.test.js
@@ -0,0 +1,60 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { readFile } from 'node:fs/promises';
+import { findCachedRepoFile } from '../../lib/hfCache.js';
+import { downloadHfRepo } from '../hfDownload.js';
+import { ensureMiniMaxH3Weights } from './ensureWeights.js';
+
+vi.mock('node:fs/promises', () => ({ readFile: vi.fn() }));
+vi.mock('../../lib/hfCache.js', async (original) => ({
+ ...(await original()), findCachedRepoFile: vi.fn(),
+}));
+vi.mock('../hfDownload.js', () => ({ downloadHfRepo: vi.fn() }));
+const model = {
+ runtime: 'minimax_h3', repo: 'example/transformer', revision: 'a'.repeat(40),
+ requiredWeights: [{ repo: 'example/conditioner', revision: 'b'.repeat(40), files: ['vae/config.json', 'vae/model.safetensors'] }],
+};
+let missing;
+beforeEach(() => {
+ vi.clearAllMocks();
+ missing = new Set();
+ vi.mocked(readFile).mockResolvedValue(JSON.stringify({ weight_map: { layer: 'model-00001-of-00001.safetensors' } }));
+ vi.mocked(findCachedRepoFile).mockImplementation(async (repo, file) => missing.has(`${repo}/${file}`) ? null : `/cache/${file}`);
+ vi.mocked(downloadHfRepo).mockImplementation(({ repo }) => {
+ for (const file of missing) if (file.startsWith(`${repo}/`)) missing.delete(file);
+ return { promise: Promise.resolve({ ok: true }) };
+ });
+});
+
+describe('MiniMax render provisioning', () => {
+ it('repairs missing metadata, indexed shards and shared dependencies without a registry repoFiles list', async () => {
+ missing.add('example/transformer/quant_config.json');
+ missing.add('example/transformer/model-00001-of-00001.safetensors');
+ missing.add('example/conditioner/vae/model.safetensors');
+ await ensureMiniMaxH3Weights(model);
+ expect(downloadHfRepo.mock.calls.map(([args]) => args)).toEqual([
+ { repo: model.repo, revision: model.revision, only: [] },
+ { repo: 'example/conditioner', revision: 'b'.repeat(40), only: model.requiredWeights[0].files },
+ ]);
+ await ensureMiniMaxH3Weights(model);
+ expect(downloadHfRepo).toHaveBeenCalledTimes(2);
+ });
+
+ it('detects a missing shard even with all metadata cached', async () => {
+ missing.add('example/transformer/model-00001-of-00001.safetensors');
+ await ensureMiniMaxH3Weights(model);
+ expect(downloadHfRepo).toHaveBeenCalledTimes(1);
+ });
+
+ it('does not accept a successful downloader result when files remain missing', async () => {
+ missing.add('example/transformer/quant_config.json');
+ downloadHfRepo.mockReturnValue({ promise: Promise.resolve({ ok: true }) });
+ await expect(ensureMiniMaxH3Weights(model)).rejects.toMatchObject({ code: 'MINIMAX_H3_WEIGHTS_NOT_CACHED' });
+ expect(downloadHfRepo).toHaveBeenCalledTimes(1);
+ });
+
+ it('keeps declared selective downloads scoped', async () => {
+ missing.add('example/transformer/config.json');
+ await ensureMiniMaxH3Weights({ ...model, repoFiles: ['config.json', 'model.safetensors'] });
+ expect(downloadHfRepo).toHaveBeenCalledWith({ repo: model.repo, revision: model.revision, only: ['config.json', 'model.safetensors'] });
+ });
+});
diff --git a/server/services/videoGen/generateVideo.js b/server/services/videoGen/generateVideo.js
index bfba579530..cd57e71991 100644
--- a/server/services/videoGen/generateVideo.js
+++ b/server/services/videoGen/generateVideo.js
@@ -29,7 +29,7 @@ import { getVideoModels, getDefaultVideoModelId, getTextEncoderRepo } from '../.
import { hardwareUnavailableReason, isHardwareCompatible } from '../../lib/systemCapabilities.js';
import { resolveVideoModelSelection } from './modelSelection.js';
import { findCachedRepoFile, findCachedRepoFiles } from '../../lib/hfCache.js';
-import { downloadHfRepo } from '../hfDownload.js';
+import { ensureMiniMaxH3Weights } from './ensureWeights.js';
import { describeRenderConditioning, RENDER_INPUTS_VERSION } from './generateVideoHelpers.js';
import { readTriggerWordsByFilename, readLoraLicensesByFilename } from '../loras.js';
import { provenanceForRender } from '../../lib/assetProvenance.js';
@@ -150,38 +150,6 @@ export const listVideoModels = () => getVideoModels().map(decorateVideoModel);
export const defaultVideoModelId = (capabilities) => getDefaultVideoModelId(capabilities);
-// MiniMax's runner is intentionally offline at render time. A missing file
-// used to reach the Python child, where huggingface_hub produced a confusing
-// "outgoing traffic has been disabled" traceback. Rendering is already an
-// explicit user action, so it is the right place to finish provisioning the
-// selected model automatically (the same download path as the Video Gen
-// button), then retry the render once the cache is complete.
-const ensureMiniMaxH3Weights = async (model) => {
- if (model.runtime !== 'minimax_h3' || !model.repo || !Array.isArray(model.repoFiles) || model.repoFiles.length === 0) return;
- const missing = [];
- for (const file of model.repoFiles) {
- if (!(await findCachedRepoFile(model.repo, file, { revision: model.revision }))) missing.push(file);
- }
- if (missing.length === 0) return;
- console.log(`⬇️ MiniMax H3 render requested with ${missing.length} uncached weight file(s); downloading automatically`);
- const result = await downloadHfRepo({
- repo: model.repo,
- revision: model.revision || null,
- only: model.repoFiles,
- onEvent: (event) => {
- if (event.type === 'progress' && event.file && event.downloaded == null) {
- console.log(`⬇️ MiniMax H3: ${event.file}`);
- }
- },
- }).promise;
- if (!result.ok) {
- throw new ServerError(
- `MiniMax H3 weights could not be downloaded automatically: ${result.errorMessage || 'download failed'}. Open Video Gen to retry the download.`,
- { status: 400, code: 'MINIMAX_H3_WEIGHTS_NOT_CACHED' },
- );
- }
-};
-
export async function generateVideo({ pythonPath, prompt, negativePrompt = '', modelId, width = null, height = null, numFrames = null, fps = 24, steps, guidanceScale, seed, batchSize = 1, tiling = 'auto', disableAudio = false, sourceImagePath = null, uploadedTempPath = null, uploadedTempPaths = [], lastImagePath = null, keyframes = null, extendFromVideoPath = null, audioFilePath = null, audioStartSec = null, mode = null, imageStrength = null, i2vReferenceMode = null, loras = null, icReferencePaths = null, icStrength = null, icAttentionStrength = null, icSkipStage2 = false, textEncoderId = null, speedProfileId = null, draftDecode = null, streamingMode = null, visualConditioning = null, hidden = false, displaySleep = null, jobId: providedJobId = null }) {
uploadedTempPaths = Array.isArray(uploadedTempPaths) ? uploadedTempPaths : [];
if (!prompt?.trim()) throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });
@@ -193,7 +161,6 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
const { modelId: selectedModelId, model } = await resolveVideoModelSelection(modelId, { resolveModel: resolveVideoModel });
modelId = selectedModelId;
if (!model) throw new ServerError(`Unknown video model: ${modelId}`, { status: 400, code: 'VALIDATION_ERROR' });
- await ensureMiniMaxH3Weights(model);
validateVideoBatch({ batchSize, seed }, model);
if (!isHardwareCompatible(model.hardwareCompatibility)) {
throw new ServerError(
@@ -714,10 +681,11 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
ffprobePath: ffprobe,
}));
if (batch) args.push('--batch-seeds', JSON.stringify(batch.map((item) => item.seed)));
+ await ensureMiniMaxH3Weights(model);
} catch (err) {
job.status = 'error';
- const reason = err.message || 'Failed to build video gen args';
- console.error(`❌ Video generation buildArgs error [${jobId.slice(0, 8)}]: ${reason}`);
+ const reason = err.message || 'Failed to prepare video generation';
+ console.error(`❌ Video generation preparation error [${jobId.slice(0, 8)}]: ${reason}`);
broadcastSse(job, { type: 'error', error: reason });
videoGenEvents.emit('failed', { generationId: jobId, error: reason, failure: normalizeVideoFailure(err, { prompts: [prompt, negativePrompt] }) });
void cleanupTempFiles({ includeUploads: true, includeUntrackedAudio: true });
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index a3995b5aad..5773533ad6 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -318,7 +318,8 @@ const { mockInspectModelCache, mockFindCachedRepoFile } = vi.hoisted(() => ({
// "resident", derived from the same mocked snapshot path the tests assert on.
mockFindCachedRepoFile: vi.fn(async (_repo, filename) => join('/mock/hf/snap', filename)),
}));
-vi.mock('../../lib/hfCache.js', () => ({
+vi.mock('../../lib/hfCache.js', async (original) => ({
+ isSafeHfRepoRelativePath: (await original()).isSafeHfRepoRelativePath,
inspectModelCache: mockInspectModelCache,
findCachedRepoFile: mockFindCachedRepoFile,
// Built on the singular mock rather than stubbed independently, mirroring the
@@ -503,6 +504,10 @@ let videoGenEvents;
beforeEach(async () => {
vi.resetModules();
+ fsPromisesMock.readFile.mockReset().mockImplementation(async (path) => Buffer.from(
+ String(path).endsWith('model.safetensors.index.json')
+ ? JSON.stringify({ weight_map: { example: 'model-00001-of-00001.safetensors' } }) : '',
+ ));
// Re-import fresh copies so mock reset above applies cleanly
({ generateChainedVideo, generateVideo, extractLastFrame, stitchVideos, updateHistoryItemPrompt } = await import('./local.js'));
({ videoGenEvents } = await import('./events.js'));
diff --git a/server/services/videoGen/spawnWatch.js b/server/services/videoGen/spawnWatch.js
index 40dbb50e1e..83f58f705d 100644
--- a/server/services/videoGen/spawnWatch.js
+++ b/server/services/videoGen/spawnWatch.js
@@ -127,7 +127,7 @@ export async function spawnAndWatchVideo({
} catch (err) {
// A replacement can race a read, and cancel/close removes the directory;
// both are ordinary teardown races rather than render failures.
- if (!previewClosed) console.log(`⚠️ Video preview read skipped [${jobId.slice(0, 8)}]: ${err.message}`);
+ if (!previewClosed && err.code !== 'ENOENT') console.log(`⚠️ Video preview read skipped [${jobId.slice(0, 8)}]: ${err.message}`);
}
previewReading = false;
if (previewPending) {