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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: select the video model catalog on an MLX/CUDA axis so Linux resolves CUDA runtimes (#4142)
[._.]/ Adam Eivy6e51a3161ec0
diff --git a/.changelog/next/fixed-issue-4142.md b/.changelog/next/fixed-issue-4142.mdnew file mode 100644index 0000000000..823aa8ec84--- /dev/null+++ b/.changelog/next/fixed-issue-4142.md@@ -0,0 +1 @@+- Video model catalog now selects on an MLX/CUDA axis instead of a macOS/Windows one, so a Linux install is served the torch+CUDA runtimes (LTX-Video, MiniMax H3 CUDA) it can actually run instead of an MLX-only list (#4142)diff --git a/data.reference/media-models.json b/data.reference/media-models.jsonindex 13cc70b4ce..e08eb21b47 100644--- a/data.reference/media-models.json+++ b/data.reference/media-models.json@@ -1,7 +1,7 @@{"_doc": "PortOS media model registry. Edit to add models, tune defaults, or switch the text encoder. Restart the server to apply changes.","video": {- "macos": [+ "mlx": [{"id": "ltx23_unified","name": "LTX-2.3 Unified Beta (~48 GB, bf16 quality ceiling)",@@ -474,7 +474,7 @@}}],- "windows": [+ "cuda": [{"id": "ltx_video","name": "LTX-Video 0.9.5 — T2V + I2V (~9.5 GB, auto-downloads)",@@ -654,8 +654,8 @@}}],- "defaultMacos": "ltx23_distilled_q4",- "defaultWindows": "ltx_video"+ "defaultMlx": "ltx23_distilled_q4",+ "defaultCuda": "ltx_video"},"image": [{diff --git a/scripts/migrations/044-hunyuan-fp32-deprecated.js b/scripts/migrations/044-hunyuan-fp32-deprecated.jsindex 5b5fd8a084..629980683e 100644--- a/scripts/migrations/044-hunyuan-fp32-deprecated.js+++ b/scripts/migrations/044-hunyuan-fp32-deprecated.js@@ -28,6 +28,7 @@import { readFile } from 'fs/promises';import { join } from 'path';import { atomicWrite } from '../../server/lib/fileUtils.js';+import { VIDEO_BUCKET_MLX, readVideoBucket } from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';@@ -56,13 +57,15 @@ export default {return;}- const macos = Array.isArray(config?.video?.macos) ? config.video.macos : null;- if (!macos) {- console.log(`⚠️ ${REL_PATH}: no video.macos[] array — skipping`);+ // Bucket key resolved canonical-first with a legacy fallback: this+ // migration predates the #4142 `macos` → `mlx` rename, so it meets either.+ const mlxEntries = readVideoBucket(config?.video, VIDEO_BUCKET_MLX);+ if (!Array.isArray(mlxEntries)) {+ console.log(`⚠️ ${REL_PATH}: no video.mlx[] array — skipping`);return;}- const entry = macos.find((m) => m?.id === 'hunyuan_video');+ const entry = mlxEntries.find((m) => m?.id === 'hunyuan_video');if (!entry) {console.log(`✅ ${REL_PATH}: no 'hunyuan_video' entry — user removed it, nothing to migrate`);return;diff --git a/scripts/migrations/233-wan-mlx-gen-models.js b/scripts/migrations/233-wan-mlx-gen-models.jsindex 16768ec824..df588acb79 100644--- a/scripts/migrations/233-wan-mlx-gen-models.js+++ b/scripts/migrations/233-wan-mlx-gen-models.js@@ -7,6 +7,7 @@import { readFile } from 'fs/promises';import { join } from 'path';import { atomicWrite } from '../../server/lib/fileUtils.js';+import { VIDEO_BUCKET_MLX, readVideoBucket } from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';const LIGHTNING_REPO = 'lightx2v/Wan2.2-Lightning';@@ -94,11 +95,13 @@ export default {} catch (err) {throw new Error(`Cannot migrate ${REL_PATH}: invalid JSON (${err.message})`, { cause: err });}- const macos = Array.isArray(config?.video?.macos) ? config.video.macos : null;- if (!macos) return;+ // Bucket key resolved canonical-first with a legacy fallback: this+ // migration predates the #4142 `macos` → `mlx` rename, so it meets either.+ const mlxEntries = readVideoBucket(config?.video, VIDEO_BUCKET_MLX);+ if (!Array.isArray(mlxEntries)) return;let changed = false;- for (const entry of macos) {+ for (const entry of mlxEntries) {const spec = UPGRADES[entry?.id];if (!spec || entry.repo !== spec.oldRepo) continue;const preserved = Object.fromEntries(USER_TUNABLE_FIELDS@@ -113,14 +116,14 @@ export default {changed = true;}- const present = new Set(macos.map((entry) => entry?.id));+ const present = new Set(mlxEntries.map((entry) => entry?.id));for (const entry of NEW_ENTRIES) {if (present.has(entry.id)) continue;- macos.push(entry);+ mlxEntries.push(entry);present.add(entry.id);changed = true;}- const shipped = config?._shippedDefaults?.video?.macos;+ const shipped = readVideoBucket(config?._shippedDefaults?.video, VIDEO_BUCKET_MLX);if (Array.isArray(shipped)) {for (const entry of NEW_ENTRIES) {if (!shipped.includes(entry.id)) { shipped.push(entry.id); changed = true; }diff --git a/scripts/migrations/237-video-model-disclosure.js b/scripts/migrations/237-video-model-disclosure.jsindex d298da145a..764121032b 100644--- a/scripts/migrations/237-video-model-disclosure.js+++ b/scripts/migrations/237-video-model-disclosure.js@@ -21,9 +21,13 @@ import { readFile } from 'fs/promises';import { join } from 'path';import { atomicWrite } from '../../server/lib/fileUtils.js';import { applyVideoDisclosures } from '../../server/lib/videoDisclosure.js';+import { LEGACY_VIDEO_BUCKET_KEYS, VIDEO_BUCKETS } from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';-const PLATFORMS = ['macos', 'windows'];+// Both the canonical (#4142) and the legacy bucket spellings: this migration+// predates the rename and can meet either shape. Only keys actually holding an+// array are touched, so listing all four is safe on both.+const BUCKET_KEYS = [...VIDEO_BUCKETS, ...Object.values(LEGACY_VIDEO_BUCKET_KEYS)];export default {async up({ rootDir }) {@@ -42,7 +46,7 @@ export default {if (!config?.video || typeof config.video !== 'object') return;let enriched = 0;- for (const platform of PLATFORMS) {+ for (const platform of BUCKET_KEYS) {const list = config.video[platform];if (!Array.isArray(list)) continue;const next = applyVideoDisclosures(list);diff --git a/scripts/migrations/238-video-finish-profiles.js b/scripts/migrations/238-video-finish-profiles.jsindex 4833bafa8f..17dc65c5f5 100644--- a/scripts/migrations/238-video-finish-profiles.js+++ b/scripts/migrations/238-video-finish-profiles.js@@ -26,9 +26,13 @@ import { readFile } from 'fs/promises';import { join } from 'path';import { atomicWrite } from '../../server/lib/fileUtils.js';import { applyVideoFinishProfiles, sanitizeFinishProfiles } from '../../server/lib/videoFinishProfiles.js';+import { LEGACY_VIDEO_BUCKET_KEYS, VIDEO_BUCKETS } from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';-const PLATFORMS = ['macos', 'windows'];+// Both the canonical (#4142) and the legacy bucket spellings: this migration+// predates the rename and can meet either shape. Only keys actually holding an+// array are touched, so listing all four is safe on both.+const BUCKET_KEYS = [...VIDEO_BUCKETS, ...Object.values(LEGACY_VIDEO_BUCKET_KEYS)];export default {async up({ rootDir }) {@@ -52,7 +56,7 @@ export default {// and a hand-edited bad edge is left for the load-time sanitizer to warn// about instead of being silently deleted from the user's file here.let linked = 0;- for (const platform of PLATFORMS) {+ for (const platform of BUCKET_KEYS) {const list = config.video[platform];if (!Array.isArray(list)) continue;const next = sanitizeFinishProfiles(applyVideoFinishProfiles(list));diff --git a/scripts/migrations/242-minimax-h3-mlx-model.js b/scripts/migrations/242-minimax-h3-mlx-model.jsindex e15a54b42b..49fc4875ba 100644--- a/scripts/migrations/242-minimax-h3-mlx-model.js+++ b/scripts/migrations/242-minimax-h3-mlx-model.js@@ -13,6 +13,11 @@ import { readFile } from 'fs/promises';import { dirname, join } from 'path';import { fileURLToPath } from 'url';import { atomicWrite } from '../../server/lib/fileUtils.js';+import {+ VIDEO_BUCKET_CUDA,+ VIDEO_BUCKET_MLX,+ readVideoBucket,+} from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';const H3_ID = 'minimax_h3_8bit';@@ -27,13 +32,13 @@ const REFERENCE_PATH = join(// migration delivered, not a live view of the catalog, so it must never be// re-read from `data.reference/media-models.json`.const SHIPPED_AT_242 = Object.freeze({- macos: Object.freeze([+ [VIDEO_BUCKET_MLX]: Object.freeze(['ltx2_unified', 'ltx23_unified', 'ltx23_distilled_q4', 'ltx23_dgrauet_q4','ltx23_dgrauet_q8', 'minimax_h3_8bit', 'wan22_ti2v_5b', 'wan22_t2v_a14b','wan22_i2v_a14b', 'wan22_t2v_a14b_lightning', 'wan22_i2v_a14b_lightning','hunyuan_video',]),- windows: Object.freeze(['ltx_video']),+ [VIDEO_BUCKET_CUDA]: Object.freeze(['ltx_video']),});const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);@@ -62,31 +67,36 @@ export default {if (raw == null) return;const config = parseJson(raw, REL_PATH);- const macos = Array.isArray(config?.video?.macos) ? config.video.macos : null;- if (!macos) return;+ // Bucket keys resolved canonical-first with a legacy fallback: this+ // migration predates the #4142 `macos`/`windows` → `mlx`/`cuda` rename, so+ // it meets either shape (an upgrading install still has the old keys; a+ // fresh one seeds the canonical ones from data.reference).+ const mlxEntries = readVideoBucket(config?.video, VIDEO_BUCKET_MLX);+ if (!Array.isArray(mlxEntries)) return;const reference = parseJson(await readFile(REFERENCE_PATH, 'utf-8'), 'data.reference/media-models.json');- const referenceMacos = Array.isArray(reference?.video?.macos) ? reference.video.macos : [];- const h3 = referenceMacos.find((entry) => entry?.id === H3_ID);+ const referenceMlx = readVideoBucket(reference?.video, VIDEO_BUCKET_MLX);+ const h3 = (Array.isArray(referenceMlx) ? referenceMlx : []).find((entry) => entry?.id === H3_ID);if (!h3) throw new Error(`Cannot migrate ${REL_PATH}: shipped ${H3_ID} reference is missing`);const shippedRoot = isObject(config._shippedDefaults) ? config._shippedDefaults : null;const shippedVideo = isObject(shippedRoot?.video) ? shippedRoot.video : null;- const shippedMacos = Array.isArray(shippedVideo?.macos) ? shippedVideo.macos : null;- const wasAlreadyShipped = shippedMacos?.includes(H3_ID) === true;- const existing = macos.find((entry) => entry?.id === H3_ID);+ const shippedMlxRaw = readVideoBucket(shippedVideo, VIDEO_BUCKET_MLX);+ const shippedMlx = Array.isArray(shippedMlxRaw) ? shippedMlxRaw : null;+ const wasAlreadyShipped = shippedMlx?.includes(H3_ID) === true;+ const existing = mlxEntries.find((entry) => entry?.id === H3_ID);let changed = false;// A recorded-but-missing id is a user deletion and stays deleted. An// existing row may be user-customized and is never overwritten.if (!existing && !wasAlreadyShipped) {- macos.push(structuredClone(h3));+ mlxEntries.push(structuredClone(h3));changed = true;}- if (shippedMacos) {- if (macos.some((entry) => entry?.id === H3_ID) && !shippedMacos.includes(H3_ID)) {- shippedMacos.push(H3_ID);+ if (shippedMlx) {+ if (mlxEntries.some((entry) => entry?.id === H3_ID) && !shippedMlx.includes(H3_ID)) {+ shippedMlx.push(H3_ID);changed = true;}} else {@@ -105,9 +115,15 @@ export default {// retroactively change what this migration claims to have delivered.const nextRoot = shippedRoot || {};const nextVideo = shippedVideo || {};- nextVideo.macos = bootstrapIds(macos, SHIPPED_AT_242.macos.map((id) => ({ id })));+ // The snapshot is written under the CANONICAL keys even when the+ // registry itself is still legacy-keyed: mediaModels.js reads either+ // spelling, and migration 270 renames the rest of the file right after.+ nextVideo[VIDEO_BUCKET_MLX] = bootstrapIds(mlxEntries, SHIPPED_AT_242[VIDEO_BUCKET_MLX].map((id) => ({ id })));if (!shippedVideo) {- nextVideo.windows = bootstrapIds(config.video.windows, SHIPPED_AT_242.windows.map((id) => ({ id })));+ nextVideo[VIDEO_BUCKET_CUDA] = bootstrapIds(+ readVideoBucket(config.video, VIDEO_BUCKET_CUDA),+ SHIPPED_AT_242[VIDEO_BUCKET_CUDA].map((id) => ({ id })),+ );}nextRoot.video = nextVideo;config._shippedDefaults = nextRoot;diff --git a/scripts/migrations/242-minimax-h3-mlx-model.test.js b/scripts/migrations/242-minimax-h3-mlx-model.test.jsindex 6d287acc77..dbc4a7f09b 100644--- a/scripts/migrations/242-minimax-h3-mlx-model.test.js+++ b/scripts/migrations/242-minimax-h3-mlx-model.test.js@@ -46,9 +46,11 @@ describe('migration 242 — MiniMax H3 MLX model', () => {runtime: 'minimax_h3',termsGate: { id: 'minimax-h3-community-license-2026-08-02' },});- expect(got._shippedDefaults.video.macos).toContain(H3_ID);- expect(got._shippedDefaults.video.macos).toContain('ltx23_unified');- expect(got._shippedDefaults.video.windows).toContain('ltx_video');+ // The snapshot it creates uses the canonical #4142 keys even though the+ // registry it read is still legacy-keyed — mediaModels.js reads either.+ expect(got._shippedDefaults.video.mlx).toContain(H3_ID);+ expect(got._shippedDefaults.video.mlx).toContain('ltx23_unified');+ expect(got._shippedDefaults.video.cuda).toContain('ltx_video');});it('adds and records H3 when a post-snapshot registry has not received it', async () => {diff --git a/scripts/migrations/244-minimax-h3-image-to-video.js b/scripts/migrations/244-minimax-h3-image-to-video.jsindex 53dc4148b5..914093ecaa 100644--- a/scripts/migrations/244-minimax-h3-image-to-video.js+++ b/scripts/migrations/244-minimax-h3-image-to-video.js@@ -45,10 +45,10 @@ const PROCESSOR_FILES = [export default {async up({ rootDir }) {- const { ok, config, entries: macos, path } = await readMediaRegistry({ rootDir });+ const { ok, config, entries: mlxEntries, path } = await readMediaRegistry({ rootDir });if (!ok) return;- const entry = macos.find((m) => m?.id === H3_ID);+ const entry = mlxEntries.find((m) => m?.id === H3_ID);if (!entry) {console.log(`✅ ${REL_PATH}: no '${H3_ID}' entry — user removed it, nothing to migrate`);return;diff --git a/scripts/migrations/244-minimax-h3-image-to-video.test.js b/scripts/migrations/244-minimax-h3-image-to-video.test.jsindex f0a48e9217..2bfe25a890 100644--- a/scripts/migrations/244-minimax-h3-image-to-video.test.js+++ b/scripts/migrations/244-minimax-h3-image-to-video.test.js@@ -76,7 +76,7 @@ describe('migration 244 — MiniMax H3 image-to-video', () => {const migrated = h3In(readJson(path));const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'))- .video.macos.find((entry) => entry.id === H3_ID);+ .video.mlx.find((entry) => entry.id === H3_ID);expect(migrated.supportedModes).toEqual(seeded.supportedModes);expect(migrated.requiredWeights[0].files.filter((f) => f.startsWith('FL2VA/processor/'))).toEqual(seeded.requiredWeights[0].files.filter((f) => f.startsWith('FL2VA/processor/')));diff --git a/scripts/migrations/247-retire-ltx2-unified.js b/scripts/migrations/247-retire-ltx2-unified.jsindex 594b833f37..84430ed018 100644--- a/scripts/migrations/247-retire-ltx2-unified.js+++ b/scripts/migrations/247-retire-ltx2-unified.js@@ -22,17 +22,19 @@* an entry a user re-pointed at a different `repo` is their model, not the* retired built-in, and survives untouched.*- * `video.defaultMacos` is repointed at `ltx23_distilled_q4` only when the+ * The MLX bucket's default (`video.defaultMlx`, or the pre-#4142+ * `defaultMacos`) is repointed at `ltx23_distilled_q4` only when the* removal actually happened and that replacement is present; otherwise* `getDefaultVideoModelId()`'s "unknown default → first available" fallback* would silently land on the 48 GB Unified Beta.*- * `_shippedDefaults.video.macos` intentionally keeps the id: it records what has+ * `_shippedDefaults.video.mlx` intentionally keeps the id: it records what has* ever been delivered to this install, nothing re-adds a model that is no longer* in `DEFAULT_REGISTRY`, and `warnDrift` ignores ids that aren't current* built-ins, so no boot warning results.*/+import { VIDEO_BUCKET_MLX, resolveVideoDefaultKey } from '../../server/lib/mediaModelBuckets.js';import { readMediaRegistry, writeMediaRegistry } from './_lib.js';export const RETIRED_ID = 'ltx2_unified';@@ -41,10 +43,10 @@ export const REPLACEMENT_ID = 'ltx23_distilled_q4';export default {async up({ rootDir }) {- const { ok, config, entries: macos, path } = await readMediaRegistry({ rootDir });+ const { ok, config, entries: mlxEntries, bucketKey, path } = await readMediaRegistry({ rootDir });if (!ok) return;- const entry = macos.find((m) => m?.id === RETIRED_ID);+ const entry = mlxEntries.find((m) => m?.id === RETIRED_ID);if (!entry) {console.log(`✅ media-models: no '${RETIRED_ID}' entry — already retired, nothing to migrate`);return;@@ -54,15 +56,22 @@ export default {return;}- config.video.macos = macos.filter((m) => m?.id !== RETIRED_ID);+ // Write back under the key the array was FOUND under (`mlx`, or the+ // pre-#4142 `macos` on a registry this install hasn't renamed yet) — writing+ // the canonical key unconditionally would leave the legacy array in place+ // and silently un-retire the model. Same for the default-model key.+ const kept = mlxEntries.filter((m) => m?.id !== RETIRED_ID);+ config.video[bucketKey] = kept;- // When the replacement was deleted too, leave defaultMacos pointing at the- // retired id and let getDefaultVideoModelId() fall back to whatever this+ // When the replacement was deleted too, leave the MLX default pointing at+ // the retired id and let getDefaultVideoModelId() fall back to whatever this// install still has, rather than naming a model that isn't there.let defaultNote = '';- if (config.video.defaultMacos === RETIRED_ID- && config.video.macos.some((m) => m?.id === REPLACEMENT_ID)) {- config.video.defaultMacos = REPLACEMENT_ID;+ const defaultKey = resolveVideoDefaultKey(config.video, VIDEO_BUCKET_MLX);+ if (defaultKey !== null+ && config.video[defaultKey] === RETIRED_ID+ && kept.some((m) => m?.id === REPLACEMENT_ID)) {+ config.video[defaultKey] = REPLACEMENT_ID;defaultNote = `; default video model → ${REPLACEMENT_ID}`;}diff --git a/scripts/migrations/247-retire-ltx2-unified.test.js b/scripts/migrations/247-retire-ltx2-unified.test.jsindex 49d628ba05..9d75cfd04a 100644--- a/scripts/migrations/247-retire-ltx2-unified.test.js+++ b/scripts/migrations/247-retire-ltx2-unified.test.js@@ -66,8 +66,8 @@ describe('migration 247 — retire LTX-2 Unified', () => {// silently diverge, so assert the seed agrees the model is gone.it('matches data.reference, which no longer ships the entry', () => {const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'));- expect(seeded.video.macos.some((entry) => entry.id === RETIRED_ID)).toBe(false);- expect(seeded.video.macos.some((entry) => entry.id === REPLACEMENT_ID)).toBe(true);+ expect(seeded.video.mlx.some((entry) => entry.id === RETIRED_ID)).toBe(false);+ expect(seeded.video.mlx.some((entry) => entry.id === REPLACEMENT_ID)).toBe(true);});it('removes the retired entry and leaves the LTX-2.3 models in place', async () => {diff --git a/scripts/migrations/267-minimax-h3-native-output-controls.js b/scripts/migrations/267-minimax-h3-native-output-controls.jsindex 8410744315..bb463619a1 100644--- a/scripts/migrations/267-minimax-h3-native-output-controls.js+++ b/scripts/migrations/267-minimax-h3-native-output-controls.js@@ -21,10 +21,10 @@ const { id: H3_ID, shippedRepo: SHIPPED_REPO } = MINIMAX_H3_OUTPUT_PROFILE;export default {async up({ rootDir }) {- const { ok, config, entries: macos, path } = await readMediaRegistry({ rootDir });+ const { ok, config, entries: mlxEntries, path } = await readMediaRegistry({ rootDir });if (!ok) return;- const entry = macos.find((model) => model?.id === H3_ID);+ const entry = mlxEntries.find((model) => model?.id === H3_ID);if (!entry) {console.log(`✅ ${REL_PATH}: no '${H3_ID}' entry — user removed it, nothing to migrate`);return;diff --git a/scripts/migrations/267-minimax-h3-native-output-controls.test.js b/scripts/migrations/267-minimax-h3-native-output-controls.test.jsindex 7ec2144d27..e6a79a37c9 100644--- a/scripts/migrations/267-minimax-h3-native-output-controls.test.js+++ b/scripts/migrations/267-minimax-h3-native-output-controls.test.js@@ -56,7 +56,7 @@ describe('migration 267 — MiniMax H3 native output controls', () => {{ label: '768x1344 (9:16 H3 native)', w: 768, h: 1344 },]);const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'))- .video.macos.find((entry) => entry.id === H3_ID);+ .video.mlx.find((entry) => entry.id === H3_ID);expect({defaultFrames: migrated.defaultFrames,frameOptions: migrated.frameOptions,diff --git a/scripts/migrations/268-minimax-h3-cuda-model.js b/scripts/migrations/268-minimax-h3-cuda-model.jsindex 165abfe0cc..2a47bb2e69 100644--- a/scripts/migrations/268-minimax-h3-cuda-model.js+++ b/scripts/migrations/268-minimax-h3-cuda-model.js@@ -1,10 +1,10 @@/**- * Add the never-before-shipped MiniMax H3 CUDA profile to existing Windows+ * Add the never-before-shipped MiniMax H3 CUDA profile to existing CUDA-bucket* registries. Fresh installs receive it from data.reference/media-models.json.*- * Same reason migration 242 exists for the macOS MLX profile: a registry whose- * `_shippedDefaults.video.windows` snapshot predates this entry has no record- * of it, and `appendNewlyShippedEntries` in mediaModels.js reads a recorded id+ * Same reason migration 242 exists for the MLX profile: a registry whose+ * `_shippedDefaults.video.cuda` snapshot (pre-#4142: `.windows`) predates this+ * entry has no record of it, and `appendNewlyShippedEntries` in mediaModels.js reads a recorded id* as "the user deleted this". That mechanism delivers the new row correctly on* its own — this migration only covers the install whose snapshot was written* by 242's legacy bootstrap, which unions the user's ids with the built-in set.@@ -19,6 +19,7 @@ import { readFile } from 'fs/promises';import { dirname, join } from 'path';import { fileURLToPath } from 'url';import { atomicWrite } from '../../server/lib/fileUtils.js';+import { VIDEO_BUCKET_CUDA, readVideoBucket } from '../../server/lib/mediaModelBuckets.js';const REL_PATH = 'data/media-models.json';const CUDA_ID = 'minimax_h3_cuda';@@ -47,26 +48,28 @@ export default {if (raw == null) return;const config = parseJson(raw, REL_PATH);- const windows = Array.isArray(config?.video?.windows) ? config.video.windows : null;- if (!windows) return;+ // Bucket key resolved canonical-first with a legacy fallback: this+ // migration predates the #4142 `windows` → `cuda` rename, so it meets either.+ const cudaEntries = readVideoBucket(config?.video, VIDEO_BUCKET_CUDA);+ if (!Array.isArray(cudaEntries)) return;const reference = parseJson(await readFile(REFERENCE_PATH, 'utf-8'), 'data.reference/media-models.json');- const referenceWindows = Array.isArray(reference?.video?.windows) ? reference.video.windows : [];- const cuda = referenceWindows.find((entry) => entry?.id === CUDA_ID);+ const referenceCuda = readVideoBucket(reference?.video, VIDEO_BUCKET_CUDA);+ const cuda = (Array.isArray(referenceCuda) ? referenceCuda : []).find((entry) => entry?.id === CUDA_ID);if (!cuda) throw new Error(`Cannot migrate ${REL_PATH}: shipped ${CUDA_ID} reference is missing`);- const shippedWindows = isObject(config._shippedDefaults?.video)- && Array.isArray(config._shippedDefaults.video.windows)- ? config._shippedDefaults.video.windows+ const shippedCudaRaw = isObject(config._shippedDefaults?.video)+ ? readVideoBucket(config._shippedDefaults.video, VIDEO_BUCKET_CUDA): null;- const wasAlreadyShipped = shippedWindows?.includes(CUDA_ID) === true;- const existing = windows.find((entry) => entry?.id === CUDA_ID);+ const shippedCuda = Array.isArray(shippedCudaRaw) ? shippedCudaRaw : null;+ const wasAlreadyShipped = shippedCuda?.includes(CUDA_ID) === true;+ const existing = cudaEntries.find((entry) => entry?.id === CUDA_ID);let changed = false;// A recorded-but-missing id is a user deletion and stays deleted. An// existing row may be user-customized and is never overwritten.if (!existing && !wasAlreadyShipped) {- windows.push(structuredClone(cuda));+ cudaEntries.push(structuredClone(cuda));changed = true;}@@ -74,8 +77,8 @@ export default {// a deliberate deletion. A registry with no snapshot key at all is left// alone — 242 owns creating it, and writing a partial one here would make// every historically deleted default look new on the next load.- if (shippedWindows && windows.some((entry) => entry?.id === CUDA_ID) && !wasAlreadyShipped) {- shippedWindows.push(CUDA_ID);+ if (shippedCuda && cudaEntries.some((entry) => entry?.id === CUDA_ID) && !wasAlreadyShipped) {+ shippedCuda.push(CUDA_ID);changed = true;}diff --git a/scripts/migrations/268-minimax-h3-cuda-model.test.js b/scripts/migrations/268-minimax-h3-cuda-model.test.jsindex 35241da96b..9b40345b16 100644--- a/scripts/migrations/268-minimax-h3-cuda-model.test.js+++ b/scripts/migrations/268-minimax-h3-cuda-model.test.js@@ -101,12 +101,31 @@ describe('migration 268 — MiniMax H3 CUDA model', () => {writeJson(path, legacyRegistry());await migration242.up({ rootDir });const afterMlx = readJson(path);- expect(afterMlx._shippedDefaults.video.windows).not.toContain(CUDA_ID);+ // 242 writes the snapshot under the canonical #4142 keys.+ expect(afterMlx._shippedDefaults.video.cuda).not.toContain(CUDA_ID);await migration.up({ rootDir });const got = readJson(path);expect(got.video.windows.some((entry) => entry.id === CUDA_ID)).toBe(true);- expect(got._shippedDefaults.video.windows).toContain(CUDA_ID);+ expect(got._shippedDefaults.video.cuda).toContain(CUDA_ID);+ });++ // A fresh install seeds data/media-models.json from the canonical-keyed+ // data.reference copy BEFORE any migration runs, so this family has to read+ // the post-#4142 spelling as readily as the legacy one it was written against.+ it('reads the canonical mlx/cuda bucket keys too', async () => {+ const { video, ...rest } = legacyRegistry();+ writeJson(path, {+ ...rest,+ video: { mlx: video.macos, cuda: video.windows, defaultMlx: video.defaultMacos, defaultCuda: video.defaultWindows },+ _shippedDefaults: { video: { mlx: [], cuda: ['ltx_video'] } },+ });+ await migration.up({ rootDir });++ const got = readJson(path);+ expect(got.video.cuda.some((entry) => entry.id === CUDA_ID)).toBe(true);+ expect(got.video.windows).toBeUndefined();+ expect(got._shippedDefaults.video.cuda).toContain(CUDA_ID);});it('does nothing when the registry file is absent', async () => {diff --git a/scripts/migrations/270-video-registry-mlx-cuda-buckets.js b/scripts/migrations/270-video-registry-mlx-cuda-buckets.jsnew file mode 100644index 0000000000..b650b188e1--- /dev/null+++ b/scripts/migrations/270-video-registry-mlx-cuda-buckets.js@@ -0,0 +1,48 @@+/**+ * Rename the video registry's two buckets from `macos` / `windows` to `mlx` /+ * `cuda` (issue #4142), along with `defaultMacos` / `defaultWindows` and the+ * `_shippedDefaults.video` snapshot arrays.+ *+ * The OS names were never the real axis. What separates the two lists is the+ * runtime family each entry needs — Apple MLX vs plain torch+CUDA — and reading+ * the OS off the key meant a Linux install was served the MLX list, none of+ * which runs there, while the two CUDA entries that would run sat in an+ * unreachable `windows` list.+ *+ * This is a pure rename: every value moves untouched, nothing is added, dropped,+ * or re-ordered within a bucket. It exists only so a registry a user hand-edits+ * ends up with a single spelling per bucket. It is NOT the compatibility+ * mechanism — `server/lib/mediaModelBuckets.js` resolves either spelling on+ * every read, so an install that never runs this migration (or a peer still on+ * an older release writing the file back) keeps working.+ *+ * `data.reference/media-models.json` ships the canonical keys, so a fresh+ * install has nothing to do here.+ */++import { canonicalizeVideoBuckets } from '../../server/lib/mediaModelBuckets.js';+import { readMediaRegistryConfig, writeMediaRegistry } from './_lib.js';++const REL_PATH = 'data/media-models.json';++export default {+ async up({ rootDir }) {+ const { ok, config, path } = await readMediaRegistryConfig({ rootDir });+ if (!ok) return;++ const video = canonicalizeVideoBuckets(config.video);+ // `_shippedDefaults.video` holds only the two id arrays — no default-model+ // keys — so the default-key half of the rename must not run against it.+ const shipped = canonicalizeVideoBuckets(config._shippedDefaults?.video, { defaultKeys: false });+ if (!video.changed && !shipped.changed) {+ console.log(`✅ ${REL_PATH}: video buckets already keyed mlx/cuda, nothing to migrate`);+ return;+ }++ if (video.changed) config.video = video.video;+ if (shipped.changed) config._shippedDefaults.video = shipped.video;++ await writeMediaRegistry(path, config);+ console.log(`📝 ${REL_PATH}: renamed the video buckets macos/windows → mlx/cuda`);+ },+};diff --git a/scripts/migrations/270-video-registry-mlx-cuda-buckets.test.js b/scripts/migrations/270-video-registry-mlx-cuda-buckets.test.jsnew file mode 100644index 0000000000..6c14dcadac--- /dev/null+++ b/scripts/migrations/270-video-registry-mlx-cuda-buckets.test.js@@ -0,0 +1,107 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';+import migration from './270-video-registry-mlx-cuda-buckets.js';++const writeJson = (path, value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++const legacyRegistry = () => ({+ _doc: 'PortOS media model registry.',+ video: {+ macos: [{ id: 'ltx23_distilled_q4', name: 'My tuned default', steps: 17 }],+ windows: [{ id: 'ltx_video', name: 'LTX' }],+ defaultMacos: 'ltx23_distilled_q4',+ defaultWindows: 'ltx_video',+ },+ image: [{ id: 'my-image', name: 'My image model' }],+ textEncoders: [{ id: 't', label: 't', repo: 'r' }],+ selectedTextEncoder: 't',+ _shippedDefaults: {+ video: { macos: ['ltx23_distilled_q4'], windows: ['ltx_video'] },+ image: { list: ['my-image'] },+ },+});++describe('migration 270 — video registry mlx/cuda buckets', () => {+ let rootDir;+ let path;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-270-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ path = join(rootDir, 'data', 'media-models.json');+ });++ afterEach(() => rmSync(rootDir, { recursive: true, force: true }));++ it('renames both buckets, both defaults, and the shipped snapshot', async () => {+ const before = legacyRegistry();+ writeJson(path, before);+ await migration.up({ rootDir });++ const got = readJson(path);+ expect(Object.keys(got.video).sort()).toEqual(['cuda', 'defaultCuda', 'defaultMlx', 'mlx']);+ expect(got.video.mlx).toEqual(before.video.macos);+ expect(got.video.cuda).toEqual(before.video.windows);+ expect(got.video.defaultMlx).toBe('ltx23_distilled_q4');+ expect(got.video.defaultCuda).toBe('ltx_video');+ expect(got._shippedDefaults.video).toEqual({ mlx: ['ltx23_distilled_q4'], cuda: ['ltx_video'] });+ });++ it('touches nothing else in the file', async () => {+ const before = legacyRegistry();+ writeJson(path, before);+ await migration.up({ rootDir });++ const got = readJson(path);+ expect(got._doc).toBe(before._doc);+ expect(got.image).toEqual(before.image);+ expect(got.textEncoders).toEqual(before.textEncoders);+ expect(got.selectedTextEncoder).toBe(before.selectedTextEncoder);+ expect(got._shippedDefaults.image).toEqual(before._shippedDefaults.image);+ });++ it('is a no-op on an already-canonical registry', async () => {+ writeJson(path, legacyRegistry());+ await migration.up({ rootDir });+ const once = readFileSync(path, 'utf-8');++ await migration.up({ rootDir });+ expect(readFileSync(path, 'utf-8')).toBe(once);+ });++ it('renames the video section even when there is no shipped snapshot yet', async () => {+ const { _shippedDefaults: _omit, ...noSnapshot } = legacyRegistry();+ writeJson(path, noSnapshot);+ await migration.up({ rootDir });++ const got = readJson(path);+ expect(got.video.mlx).toHaveLength(1);+ expect(got._shippedDefaults).toBeUndefined();+ });++ // Half-migrated shapes are reachable: mediaModels.js canonicalizes on load,+ // and migration 242 writes a canonical snapshot onto a legacy-keyed registry.+ it('finishes a partially renamed registry without duplicating a bucket', async () => {+ const config = legacyRegistry();+ config._shippedDefaults.video = { mlx: ['ltx23_distilled_q4'], cuda: ['ltx_video'] };+ writeJson(path, config);+ await migration.up({ rootDir });++ const got = readJson(path);+ expect(Object.keys(got.video).sort()).toEqual(['cuda', 'defaultCuda', 'defaultMlx', 'mlx']);+ expect(got._shippedDefaults.video).toEqual({ mlx: ['ltx23_distilled_q4'], cuda: ['ltx_video'] });+ });++ it('does nothing when the registry file is absent', async () => {+ await expect(migration.up({ rootDir })).resolves.toBeUndefined();+ });++ it('leaves an unparseable registry alone', async () => {+ writeFileSync(path, '{ not json');+ await expect(migration.up({ rootDir })).resolves.toBeUndefined();+ expect(readFileSync(path, 'utf-8')).toBe('{ not json');+ });+});diff --git a/scripts/migrations/_lib.js b/scripts/migrations/_lib.jsindex 5188eec0d8..9caaa07cc9 100644--- a/scripts/migrations/_lib.js+++ b/scripts/migrations/_lib.js@@ -15,7 +15,7 @@* a new `data/providers.json` entry repeats (149, 152, 185, 195, 201, 231).* 6. Media-model-registry migrations — `readMediaRegistry` /* `writeMediaRegistry` collapse the strict-read → absent/unreadable skip →- * platform-array guard shell shared by every migration that patches+ * bucket-array guard shell shared by every migration that patches* `data/media-models.json` (244, 247, …).** The runner (`scripts/run-migrations.js`) explicitly skips `_`-prefixed@@ -27,6 +27,7 @@ import { join } from 'path';import { pathToFileURL } from 'url';import { createHash } from 'crypto';import { atomicWrite, readJSONFileStrict } from '../../server/lib/fileUtils.js';+import { VIDEO_BUCKET_MLX, resolveVideoBucketKey } from '../../server/lib/mediaModelBuckets.js';// ---- monolithic → per-record split-migration family ----//@@ -543,21 +544,15 @@ export async function writeLayoutsDoc(path, doc) {const MEDIA_MODELS_REL_PATH = 'data/media-models.json';/**- * Read `data/media-models.json` for a registry-patching migration. Collapses- * the preamble every such migration repeats (244, 247, …): resolve the path,- * strict-read it, and pull out one platform's entry array.+ * Read `data/media-models.json` whole, for a migration that patches something+ * other than one bucket's entry array (270 renames the bucket keys themselves).** `readJSONFileStrict`'s `ok` flag is what separates "never written" (fresh* install — the seed in `data.reference/` already carries the change) from* "unreadable or corrupt", where rewriting the file would destroy a registry we* couldn't read. Both are skips, but only one of them is a warning.- *- * Returns `{ ok: false }` when the caller should do nothing, or- * `{ ok: true, config, entries, path }` — mutate `config` in place, then persist- * with `writeMediaRegistry(path, config)`. `platform` selects which- * `config.video.<platform>` array lands in `entries`.*/-export async function readMediaRegistry({ rootDir, platform = 'macos' } = {}) {+export async function readMediaRegistryConfig({ rootDir } = {}) {const path = join(rootDir, MEDIA_MODELS_REL_PATH);const { ok, value: config } = await readJSONFileStrict(path, null);if (!ok) {@@ -568,12 +563,37 @@ export async function readMediaRegistry({ rootDir, platform = 'macos' } = {}) {console.log(`📄 ${MEDIA_MODELS_REL_PATH} not present — skipping (fresh install seeds from data.reference)`);return { ok: false };}- const entries = config?.video?.[platform];+ return { ok: true, config, path };+}++/**+ * Read `data/media-models.json` for a registry-patching migration. Collapses+ * the preamble every such migration repeats (244, 247, …):+ * `readMediaRegistryConfig` above, plus pulling out one bucket's entry array.+ *+ * Returns `{ ok: false }` when the caller should do nothing, or+ * `{ ok: true, config, entries, bucketKey, path }` — mutate `config` in place,+ * then persist with `writeMediaRegistry(path, config)`. `bucket` selects which+ * video bucket lands in `entries`; `bucketKey` is the key it was actually found+ * under, which a caller that REPLACES the whole array must write back to.+ *+ * The bucket key is resolved canonical-first with a fallback to the pre-#4142+ * `macos` / `windows` spelling (see server/lib/mediaModelBuckets.js). Every+ * member of this family predates the rename and can therefore meet either+ * shape: an install upgrading from an older release still has the legacy keys+ * when they run, while a fresh install seeds `data/media-models.json` from the+ * canonical-keyed `data.reference/` copy before any migration runs.+ */+export async function readMediaRegistry({ rootDir, bucket = VIDEO_BUCKET_MLX } = {}) {+ const { ok, config, path } = await readMediaRegistryConfig({ rootDir });+ if (!ok) return { ok: false };+ const bucketKey = resolveVideoBucketKey(config?.video, bucket);+ const entries = bucketKey === null ? undefined : config.video[bucketKey];if (!Array.isArray(entries)) {- console.log(`⚠️ ${MEDIA_MODELS_REL_PATH}: no video.${platform}[] array — skipping`);+ console.log(`⚠️ ${MEDIA_MODELS_REL_PATH}: no video.${bucket}[] array — skipping`);return { ok: false };}- return { ok: true, config, entries, path };+ return { ok: true, config, entries, bucketKey, path };}/** Persist a media-model registry with the canonical trailing-newline shape. */diff --git a/scripts/setup-image-video.sh b/scripts/setup-image-video.shindex 7b0849cba4..d582647391 100755--- a/scripts/setup-image-video.sh+++ b/scripts/setup-image-video.sh@@ -439,14 +439,9 @@ if [[ "$INSTALL_MINIMAX_H3_CUDA" == "1" ]]; thenecho "❌ MiniMax H3 CUDA needs an NVIDIA GPU. On Apple Silicon use INSTALL_MINIMAX_H3=1 (the MLX port) instead." >&2exit 1fi- # The venv provisions fine on Linux, but PortOS only surfaces this model on- # Windows: the catalog picks video.windows[] vs video.macos[] off IS_WIN, so- # a Linux install is served the macOS/MLX list and would never see the row.- # Warn rather than refuse — the install is harmless and ready for the day- # that axis widens (tracked in #4142).- if ! is_windows; then- echo "⚠️ MiniMax H3 CUDA is only surfaced in Video Gen on Windows today; this venv will install but no model row will appear." >&2- fi+ # Windows and Linux both reach this model: since #4142 the catalog picks+ # video.cuda[] vs video.mlx[] on `process.platform === 'darwin'`, so a Linux+ # install is served the same CUDA list a Windows one is.# diffusers is pinned to a git commit until a release carries the MiniMax-H3# integration (see the note in requirements-minimax-h3-cuda.txt), so pip needs# git to build that wheel. Say so up front rather than failing several minutesdiff --git a/server/lib/README.md b/server/lib/README.mdindex 46465093f5..1f02fa52c9 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -112,6 +112,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `promptStageCallSites.generated.json` | Generated `stageKey -> [server source paths]` index of every prompt stage `server/` names by literal key (plus interpolated-prefix stages like `pipeline-panel-${id}`). Regenerate with `node scripts/generate-prompt-stage-call-sites.js`; `scripts/generate-prompt-stage-call-sites.test.js` fails on drift. Never hand-edit. || `promptTemplate.js` | Mustache-flavored, dot-notation-aware prompt template engine. || `promptPartials.js` | Mustache-style partial expansion. |+| `mediaModelBuckets.js` | Names and resolves the video registry's two model buckets (#4142). The split is by RUNTIME FAMILY — `mlx` (Apple MLX runtimes) vs `cuda` (plain torch+CUDA, which runs on Windows *and* Linux) — not by operating system, which is why `activeVideoBucket()` keys on `process.platform === 'darwin'` instead of on "is this Windows". `readVideoBucket` / `readVideoDefault` / `matchesVideoBucket` resolve the canonical key first and fall back to the pre-#4142 `macos` / `windows` / `defaultMacos` / `defaultWindows` spellings, so any registry written by an older install still loads untouched; `canonicalizeVideoBuckets` performs the one-time rename (migration 270 and the load-time twin in `mediaModels.js`). Kept separate from `mediaModels.js` so `scripts/migrations/` can share the alias resolution without importing the registry loader, which seeds `data/` as a side effect. || `mediaModels.js` | Single source of truth for image/video model metadata. Entry fields are documented in the module docblock — note `repoFiles[]`, which narrows a model's own repo to an explicit file list for an aggregate repo that holds far more than the runner loads (MiniMax H3 CUDA). || `videoContinuity.js` | How chunk N+1 of a chained video render is conditioned on chunk N. `resolveContextFrames(requested)` normalizes the tail-window size (absent → `DEFAULT_CONTEXT_FRAMES` = 22 ≈ 1s @ 24fps; an explicit `0` is preserved as "last frame only", NOT collapsed into the default) and clamps to `MIN_CONTEXT_FRAMES`..`MAX_CONTEXT_FRAMES`. `resolveContinuityStrategy({model, contextFrames})` picks `'window'` (LTX-2 `extend_from_video` conditioned on the prior chunk's last N frames — motion, not just a pose) or `'frame'` (extract the last frame, run i2v), degrading to `'frame'` on any runtime outside `CONTEXT_WINDOW_RUNTIMES` rather than rejecting. `extendLatentFrames` / `extendedPixelFrames` convert across the VAE's `LATENT_FRAME_STRIDE` (8 pixel frames per latent), `contextPrefixFrames({totalFrames, extendLatents})` measures how much of an extend render is echoed context to trim back off before stitching (0 = leave it alone), and `tailWindowStartFrame` gives the cut index for the window itself. Pure — importable from `prepareParams.js` without dragging in `local.js`. Mirrored for the picker in `client/src/lib/videoGenParams.js`, pinned by `videoContinuity.parity.test.js`. || `videoDisclosure.js` | Video Gen provenance/licensing + backend policy-scope facts (#3674). `VIDEO_MODEL_DISCLOSURES` maps each shipped video model id to `{ shippedRepo, disclosure }` (model card URL, weights license, runtime license, pinned-snapshot download size in decimal GB, review date) — every value checked against a primary upstream source, and any fact that could not be established is OMITTED so the UI renders "Unknown" instead of guessing. `applyVideoDisclosures(list)` is the load-time backfill (twin of migration 237) with the same preservation guards: an existing `disclosure` key wins, a custom id is skipped, and a `repo` pointed at a fork keeps Unknown. `VIDEO_BACKEND_DISCLOSURES` / `videoBackendDisclosure(id)` state where inference runs (`execution: local or hosted`) and whose policy applies — execution facts only, never a restrictiveness ranking. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 157d679642..6f60698f86 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -116,6 +116,7 @@ export * from './sseDownload.js';export * from './sseHeaders.js';export * from './installLogger.js';export * from './kimi.js';+export * from './mediaModelBuckets.js';export * from './mediaModels.js';export * from './videoContinuity.js';export * from './videoDisclosure.js';diff --git a/server/lib/mediaModelBuckets.js b/server/lib/mediaModelBuckets.jsnew file mode 100644index 0000000000..09f4badb7e--- /dev/null+++ b/server/lib/mediaModelBuckets.js@@ -0,0 +1,152 @@+/**+ * Video-registry bucket naming and platform selection (issue #4142).+ *+ * The video registry has always held exactly two lists of models, and they were+ * originally keyed `macos` and `windows`. That naming was never the real axis:+ * what separates the two lists is the RUNTIME FAMILY each entry needs — Apple's+ * MLX stack (`mlx_video`, `ltx2`, `ltx25`, `wan22`, `hunyuan`, `minimax_h3`) on+ * one side, plain torch + CUDA (`ltx_video` via scripts/generate_win.py,+ * `minimax_h3_cuda` via diffusers) on the other. Reading the OS off the key+ * meant a Linux install was served the MLX list, every entry of which is+ * unrunnable there, while the two CUDA entries that would run perfectly sat in+ * an unreachable `windows` list.+ *+ * So the canonical keys are `mlx` / `cuda` (and `defaultMlx` / `defaultCuda`),+ * and the selector is "is this a Mac?" rather than "is this Windows?".+ *+ * The legacy keys stay readable forever. PortOS is distributed software: other+ * installs upgrade on their own schedule, and `data/media-models.json` is a+ * hand-editable user file. `resolveVideoBucketKey` prefers the canonical key and+ * falls back to the legacy alias, so a registry written by any older version+ * keeps resolving with no rewrite required. Migration 270 renames the keys in+ * place for installs that already persisted one, purely so hand-editors see a+ * single spelling.+ *+ * Kept in its own module (rather than inside `mediaModels.js`) because the+ * migration family under `scripts/migrations/` needs the same alias resolution+ * and must not import the registry loader, which seeds `data/` as a side effect.+ */++export const VIDEO_BUCKET_MLX = 'mlx';+export const VIDEO_BUCKET_CUDA = 'cuda';+export const VIDEO_BUCKETS = Object.freeze([VIDEO_BUCKET_MLX, VIDEO_BUCKET_CUDA]);++/** Pre-#4142 on-disk key for each bucket's entry array. Read-only aliases. */+export const LEGACY_VIDEO_BUCKET_KEYS = Object.freeze({+ [VIDEO_BUCKET_MLX]: 'macos',+ [VIDEO_BUCKET_CUDA]: 'windows',+});++/** Canonical key naming each bucket's default model id. */+export const VIDEO_DEFAULT_KEYS = Object.freeze({+ [VIDEO_BUCKET_MLX]: 'defaultMlx',+ [VIDEO_BUCKET_CUDA]: 'defaultCuda',+});++/** Pre-#4142 on-disk key for each bucket's default model id. */+export const LEGACY_VIDEO_DEFAULT_KEYS = Object.freeze({+ [VIDEO_BUCKET_MLX]: 'defaultMacos',+ [VIDEO_BUCKET_CUDA]: 'defaultWindows',+});++/** Every legacy key a normalized `video` object must not carry forward. */+export const LEGACY_VIDEO_KEYS = Object.freeze([+ ...Object.values(LEGACY_VIDEO_BUCKET_KEYS),+ ...Object.values(LEGACY_VIDEO_DEFAULT_KEYS),+]);++/**+ * Which bucket this machine can actually run. macOS gets MLX; every other+ * platform (Windows AND Linux) gets the torch+CUDA list — the entries there are+ * plain PyTorch pipelines whose venvs provision identically on both.+ *+ * Read at call time, not at module load, so a test can redefine+ * `process.platform` and so a single import is not pinned to the first platform+ * it saw.+ */+export const activeVideoBucket = () => (+ process.platform === 'darwin' ? VIDEO_BUCKET_MLX : VIDEO_BUCKET_CUDA+);++/** The bucket this machine cannot run. */+export const otherVideoBucket = (bucket) => (+ bucket === VIDEO_BUCKET_MLX ? VIDEO_BUCKET_CUDA : VIDEO_BUCKET_MLX+);++const hasKey = (obj, key) => (+ obj !== null && typeof obj === 'object' && Object.hasOwn(obj, key)+);++/**+ * The key `video` (or `_shippedDefaults.video`) actually stores `bucket` under:+ * the canonical name when present, else the legacy alias, else `null`.+ *+ * Keyed on key PRESENCE, not on the value being usable — a canonical key+ * holding junk (`{ mlx: "ltx" }`) must NOT silently fall through to a stale+ * legacy array. Callers apply their own shape coercion to the value.+ */+export const resolveVideoBucketKey = (video, bucket) => {+ if (hasKey(video, bucket)) return bucket;+ const legacy = LEGACY_VIDEO_BUCKET_KEYS[bucket];+ if (legacy && hasKey(video, legacy)) return legacy;+ return null;+};++/** The raw value stored for `bucket`, canonical key preferred. */+export const readVideoBucket = (video, bucket) => {+ const key = resolveVideoBucketKey(video, bucket);+ return key === null ? undefined : video[key];+};++/** As `resolveVideoBucketKey`, for the bucket's default-model-id key. */+export const resolveVideoDefaultKey = (video, bucket) => {+ const canonical = VIDEO_DEFAULT_KEYS[bucket];+ if (canonical && hasKey(video, canonical)) return canonical;+ const legacy = LEGACY_VIDEO_DEFAULT_KEYS[bucket];+ if (legacy && hasKey(video, legacy)) return legacy;+ return null;+};++/** The raw default model id stored for `bucket`, canonical key preferred. */+export const readVideoDefault = (video, bucket) => {+ const key = resolveVideoDefaultKey(video, bucket);+ return key === null ? undefined : video[key];+};++/**+ * Does a per-entry `broken` string name this bucket? Entries persisted before+ * the rename spell it `"macos"` / `"windows"`, so both spellings count.+ */+export const matchesVideoBucket = (value, bucket) => (+ typeof value === 'string' && (value === bucket || value === LEGACY_VIDEO_BUCKET_KEYS[bucket])+);++/**+ * Rewrite a `video`-shaped object's legacy keys to their canonical names,+ * returning `{ video, changed }`. A canonical key that is already present wins+ * and its legacy twin is dropped, so the result never carries two spellings of+ * the same list. Values are moved untouched — this renames, it never rebuilds.+ *+ * `defaultKeys: false` handles `_shippedDefaults.video`, which holds only the+ * two id arrays and no default-model keys.+ */+export const canonicalizeVideoBuckets = (video, { defaultKeys = true } = {}) => {+ if (video === null || typeof video !== 'object' || Array.isArray(video)) {+ return { video, changed: false };+ }+ const pairs = [+ ...VIDEO_BUCKETS.map((bucket) => [bucket, LEGACY_VIDEO_BUCKET_KEYS[bucket]]),+ ...(defaultKeys+ ? VIDEO_BUCKETS.map((bucket) => [VIDEO_DEFAULT_KEYS[bucket], LEGACY_VIDEO_DEFAULT_KEYS[bucket]])+ : []),+ ];+ let changed = false;+ const next = { ...video };+ for (const [canonical, legacy] of pairs) {+ if (!Object.hasOwn(next, legacy)) continue;+ if (!Object.hasOwn(next, canonical)) next[canonical] = next[legacy];+ delete next[legacy];+ changed = true;+ }+ return { video: next, changed };+};diff --git a/server/lib/mediaModelBuckets.test.js b/server/lib/mediaModelBuckets.test.jsnew file mode 100644index 0000000000..e0fd993f70--- /dev/null+++ b/server/lib/mediaModelBuckets.test.js@@ -0,0 +1,142 @@+import { describe, it, expect, afterEach } from 'vitest';+import {+ LEGACY_VIDEO_KEYS,+ VIDEO_BUCKET_CUDA,+ VIDEO_BUCKET_MLX,+ activeVideoBucket,+ canonicalizeVideoBuckets,+ matchesVideoBucket,+ otherVideoBucket,+ readVideoBucket,+ readVideoDefault,+ resolveVideoBucketKey,+ resolveVideoDefaultKey,+} from './mediaModelBuckets.js';+import { pinPlatform } from './testHelper.js';++let restorePlatform = () => {};+const asPlatform = (value) => { restorePlatform = pinPlatform(value); };++describe('activeVideoBucket', () => {+ afterEach(() => restorePlatform());++ it('gives darwin the MLX bucket', () => {+ asPlatform('darwin');+ expect(activeVideoBucket()).toBe(VIDEO_BUCKET_MLX);+ });++ // The #4142 bug: selecting on `IS_WIN` sent linux down the macOS branch, so a+ // Linux install was served a list of MLX runtimes it cannot execute.+ it.each(['win32', 'linux', 'freebsd'])('gives %s the CUDA bucket', (platform) => {+ asPlatform(platform);+ expect(activeVideoBucket()).toBe(VIDEO_BUCKET_CUDA);+ });++ it('reads the platform per call rather than pinning it at import', () => {+ asPlatform('darwin');+ expect(activeVideoBucket()).toBe(VIDEO_BUCKET_MLX);+ asPlatform('linux');+ expect(activeVideoBucket()).toBe(VIDEO_BUCKET_CUDA);+ });++ it('otherVideoBucket is the opposite of whatever it is handed', () => {+ expect(otherVideoBucket(VIDEO_BUCKET_MLX)).toBe(VIDEO_BUCKET_CUDA);+ expect(otherVideoBucket(VIDEO_BUCKET_CUDA)).toBe(VIDEO_BUCKET_MLX);+ });+});++describe('bucket key resolution', () => {+ it('prefers the canonical key', () => {+ const video = { mlx: ['new'], macos: ['old'] };+ expect(resolveVideoBucketKey(video, VIDEO_BUCKET_MLX)).toBe('mlx');+ expect(readVideoBucket(video, VIDEO_BUCKET_MLX)).toEqual(['new']);+ });++ it('falls back to the pre-#4142 alias', () => {+ const video = { macos: ['old'], windows: ['oldwin'] };+ expect(resolveVideoBucketKey(video, VIDEO_BUCKET_MLX)).toBe('macos');+ expect(resolveVideoBucketKey(video, VIDEO_BUCKET_CUDA)).toBe('windows');+ expect(readVideoBucket(video, VIDEO_BUCKET_CUDA)).toEqual(['oldwin']);+ });++ // Sentinel discipline: a canonical key that is PRESENT but holds junk must not+ // silently resolve to a stale legacy array — the caller's own shape coercion+ // has to see the junk and fall back to the defaults, exactly as it did before+ // the alias existed.+ it('does not fall through when the canonical key is present but unusable', () => {+ const video = { mlx: 'ltx', macos: ['old'] };+ expect(resolveVideoBucketKey(video, VIDEO_BUCKET_MLX)).toBe('mlx');+ expect(readVideoBucket(video, VIDEO_BUCKET_MLX)).toBe('ltx');+ });++ it('distinguishes an explicitly empty bucket from an absent one', () => {+ expect(readVideoBucket({ mlx: [] }, VIDEO_BUCKET_MLX)).toEqual([]);+ expect(readVideoBucket({}, VIDEO_BUCKET_MLX)).toBeUndefined();+ expect(resolveVideoBucketKey({}, VIDEO_BUCKET_MLX)).toBeNull();+ });++ it('tolerates a missing or non-object video section', () => {+ for (const video of [undefined, null, 'nope', ['a']]) {+ expect(resolveVideoBucketKey(video, VIDEO_BUCKET_MLX)).toBeNull();+ expect(readVideoBucket(video, VIDEO_BUCKET_MLX)).toBeUndefined();+ }+ });++ it('resolves the default-model key canonical-first', () => {+ expect(resolveVideoDefaultKey({ defaultMlx: 'a', defaultMacos: 'b' }, VIDEO_BUCKET_MLX)).toBe('defaultMlx');+ expect(readVideoDefault({ defaultMacos: 'b' }, VIDEO_BUCKET_MLX)).toBe('b');+ expect(readVideoDefault({ defaultWindows: 'c' }, VIDEO_BUCKET_CUDA)).toBe('c');+ expect(readVideoDefault({}, VIDEO_BUCKET_CUDA)).toBeUndefined();+ });+});++describe('matchesVideoBucket', () => {+ it('accepts both spellings of the bucket a `broken` flag names', () => {+ expect(matchesVideoBucket('mlx', VIDEO_BUCKET_MLX)).toBe(true);+ expect(matchesVideoBucket('macos', VIDEO_BUCKET_MLX)).toBe(true);+ expect(matchesVideoBucket('cuda', VIDEO_BUCKET_CUDA)).toBe(true);+ expect(matchesVideoBucket('windows', VIDEO_BUCKET_CUDA)).toBe(true);+ });++ it('rejects the other bucket and non-strings', () => {+ expect(matchesVideoBucket('windows', VIDEO_BUCKET_MLX)).toBe(false);+ expect(matchesVideoBucket('macos', VIDEO_BUCKET_CUDA)).toBe(false);+ expect(matchesVideoBucket(true, VIDEO_BUCKET_MLX)).toBe(false);+ expect(matchesVideoBucket(undefined, VIDEO_BUCKET_MLX)).toBe(false);+ });+});++describe('canonicalizeVideoBuckets', () => {+ it('renames every legacy key and leaves nothing behind', () => {+ const { video, changed } = canonicalizeVideoBuckets({+ macos: ['a'], windows: ['b'], defaultMacos: 'a', defaultWindows: 'b', selectedFoo: 1,+ });+ expect(changed).toBe(true);+ expect(video).toEqual({ mlx: ['a'], cuda: ['b'], defaultMlx: 'a', defaultCuda: 'b', selectedFoo: 1 });+ expect(LEGACY_VIDEO_KEYS.some((key) => key in video)).toBe(false);+ });++ it('keeps the canonical value and drops the legacy twin when both exist', () => {+ const { video } = canonicalizeVideoBuckets({ mlx: ['new'], macos: ['old'] });+ expect(video).toEqual({ mlx: ['new'] });+ });++ it('reports no change for an already-canonical object', () => {+ const input = { mlx: ['a'], cuda: ['b'], defaultMlx: 'a', defaultCuda: 'b' };+ expect(canonicalizeVideoBuckets(input)).toEqual({ video: input, changed: false });+ });++ it('skips the default-model keys when told to', () => {+ const { video } = canonicalizeVideoBuckets(+ { macos: ['a'], windows: ['b'], defaultMacos: 'a' },+ { defaultKeys: false },+ );+ expect(video).toEqual({ mlx: ['a'], cuda: ['b'], defaultMacos: 'a' });+ });++ it('passes non-objects through untouched', () => {+ for (const input of [undefined, null, 'x', ['a']]) {+ expect(canonicalizeVideoBuckets(input)).toEqual({ video: input, changed: false });+ }+ });+});diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.jsindex a705d986f5..7c40cbaceb 100644--- a/server/lib/mediaModels.js+++ b/server/lib/mediaModels.js@@ -8,7 +8,11 @@* cached at boot — there's no hot-reload).** Schema (see seed defaults below for the full picture):- * - video.macos[], video.windows[]: { id, name, repo?, steps, guidance, broken?, disclosure? }+ * - video.mlx[], video.cuda[]: { id, name, repo?, steps, guidance, broken?, disclosure? }+ * The two buckets split on RUNTIME FAMILY, not operating system: `mlx`+ * holds the Apple-MLX runtimes, `cuda` the plain torch+CUDA ones (which+ * run on Windows AND Linux). They were keyed `macos` / `windows` before+ * issue #4142; both spellings still load — see lib/mediaModelBuckets.js.* Models may also declare `defaultWidth` / `defaultHeight`,* `resolutionStep`, and `resolutionOptions[]` when their native canvas* differs from the shared Video Gen presets.@@ -42,7 +46,8 @@* getVideoModels() from lib/videoModeProfiles.js's per-runtime table when* the entry doesn't declare its own, so no consumer has to treat "absent"* as "supports everything". A declared list always wins.- * - video.defaultMacos / video.defaultWindows: id of the default model+ * - video.defaultMlx / video.defaultCuda: id of the default model+ * (legacy `defaultMacos` / `defaultWindows` still read)* - image[]: { id, name, steps, guidance, broken? }* - textEncoders[]: { id, label, repo, localPath? }* - selectedTextEncoder: id of the active text encoder@@ -52,6 +57,16 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';import { join, dirname } from 'path';import { PATHS, expandHome } from './fileUtils.js';import { isPlainObject } from './objects.js';+import {+ LEGACY_VIDEO_KEYS,+ VIDEO_BUCKETS,+ VIDEO_DEFAULT_KEYS,+ activeVideoBucket,+ matchesVideoBucket,+ readVideoBucket,+ readVideoDefault,+ resolveVideoBucketKey,+} from './mediaModelBuckets.js';import { RUNNER_FAMILIES } from './runners.js';import { ServerError } from './errorHandler.js';import { applyVideoDisclosures } from './videoDisclosure.js';@@ -64,7 +79,6 @@ import { applyVideoSupportedModes } from './videoModeProfiles.js';// Allow tests + non-standard deployments to point at a different file// without monkey-patching PATHS. Defaults to data/media-models.json.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@@ -223,7 +237,7 @@ const DEFAULT_REGISTRY = {// `applyVideoFinishProfiles` attaches the shipped draft → delivery// `finishModelId` edges (lib/videoFinishProfiles.js) the same way, so the// Finish relationship is declared in one place instead of inline here.- macos: applyVideoFinishProfiles(applyVideoDisclosures([+ mlx: applyVideoFinishProfiles(applyVideoDisclosures([// notapalindrome's mlx-video-with-audio runtime — single PyPI package,// T2V/I2V only, FFLF degrades to last-frame conditioning (one --image arg).// LTX-2 Unified (the older 42 GB model) was retired in favour of 2.3 —@@ -446,10 +460,10 @@ const DEFAULT_REGISTRY = {deprecated: true,},])),- windows: applyVideoFinishProfiles(applyVideoDisclosures([+ cuda: applyVideoFinishProfiles(applyVideoDisclosures([{ id: 'ltx_video', name: 'LTX-Video 0.9.5 — T2V + I2V (~9.5 GB, auto-downloads)', runtime: 'mlx_video', steps: 25, guidance: 3.0 },// MiniMax H3 on NVIDIA, through diffusers' MiniMaxH3ModularPipeline —- // the same joint video+audio model the macOS list runs on MLX, so it+ // the same joint video+audio model the MLX list runs on Apple Silicon, so it// shares H3's canvas grid, its fixed 24 fps, its locked CFG-distilled// sampler and the same license gate. Generation is cache-only: PortOS// owns the explicit file-list download (see MINIMAX_H3_CUDA_REPO_FILES —@@ -483,8 +497,8 @@ const DEFAULT_REGISTRY = {supportsDisableAudio: false,},])),- defaultMacos: 'ltx23_distilled_q4',- defaultWindows: 'ltx_video',+ defaultMlx: 'ltx23_distilled_q4',+ defaultCuda: 'ltx_video',},image: [// mflux runner — MLX-only, Flux 1 (dev/schnell). `runner` defaults to 'mflux'.@@ -688,9 +702,9 @@ const seedIfMissing = () => {// Merge user-edited registry over DEFAULT_REGISTRY so missing top-level keys// (e.g. someone deletes `video` or saves `{}`) don't blow up consumers that-// assume `reg.video.macos`. We also coerce array-shaped fields back to the+// assume `reg.video.mlx`. We also coerce array-shaped fields back to the// defaults when the user's JSON is parseable but wrong-shape (e.g.-// `image: {}` or `video.macos: "ltx"`) — otherwise getImageModels /+// `image: {}` or `video.mlx: "ltx"`) — otherwise getImageModels /// getVideoModels / buildAppModels would throw at module import-time and// take down server startup. If a user supplies a real array, that's their// list, full stop — we don't deep-merge entries.@@ -864,7 +878,7 @@ const backfillRuntime = (list) => {// edit. Without this the migration's deletion is undone by the same boot that// applied it.//-// `replacement` repoints a `defaultMacos`/`defaultWindows` that named the+// `replacement` repoints a `defaultMlx`/`defaultCuda` that named the// retired model. getDefaultVideoModelId() would otherwise fall back to the// first available entry, which is not necessarily the intended successor.//@@ -907,7 +921,7 @@ const resolveRetiredDefault = (configuredId, entries) => {return entries.some((entry) => entry?.id === replacement) ? replacement : configuredId;};-// Build the initial shippedIds set for one platform on first encounter+// Build the initial shippedIds set for one bucket on first encounter// (no _shippedDefaults field yet).//// Pre-snapshot bootstrap: existing installs without _shippedDefaults can't@@ -923,7 +937,7 @@ const resolveRetiredDefault = (configuredId, entries) => {// built-ins can delete media-models.json and restart to re-seed from scratch,// or add the entries manually.//-// When the platform key is absent from their registry (e.g. the whole `video`+// When the bucket key is absent from their registry (e.g. the whole `video`// section is missing), we return an empty set so the defaults are treated as// genuinely new and get added as on a fresh install.const bootstrapShippedIds = (userList, defaultList) => {@@ -941,33 +955,28 @@ const normalizeRegistry = (parsed) => {// _shippedDefaults tracks which built-in ids have ever been delivered// to this install, so we can distinguish "user deleted it" from "genuinely- // new in this release". Tracked separately for video (per-platform) and- // image (single list — image entries cover both platforms).+ // new in this release". Tracked separately for video (per-bucket) and+ // image (single list — image entries cover both buckets).const shippedVideo = isPlainObject(safe._shippedDefaults?.video) ? safe._shippedDefaults.video : null;const isVideoBootstrap = shippedVideo === null;- const shippedMacosIds = isVideoBootstrap- ? bootstrapShippedIds(safeVideo.macos, DEFAULT_REGISTRY.video.macos)- : new Set(arrayOrDefault(shippedVideo.macos, []));- const shippedWindowsIds = isVideoBootstrap- ? bootstrapShippedIds(safeVideo.windows, DEFAULT_REGISTRY.video.windows)- : new Set(arrayOrDefault(shippedVideo.windows, []));+ // Every read goes through readVideoBucket / readVideoDefault so a registry+ // still keyed `macos` / `windows` (any install written before #4142) resolves+ // exactly as it did before. The OUTPUT below is canonical-only.+ const shippedIdsFor = (bucket) => (isVideoBootstrap+ ? bootstrapShippedIds(readVideoBucket(safeVideo, bucket), DEFAULT_REGISTRY.video[bucket])+ : new Set(arrayOrDefault(readVideoBucket(shippedVideo, bucket), [])));- const macosResult = appendNewlyShippedEntries(- safeVideo.macos,- DEFAULT_REGISTRY.video.macos,- shippedMacosIds,- );- const windowsResult = appendNewlyShippedEntries(- safeVideo.windows,- DEFAULT_REGISTRY.video.windows,- shippedWindowsIds,- );+ const shippedIds = Object.fromEntries(VIDEO_BUCKETS.map((b) => [b, shippedIdsFor(b)]));+ const bucketResults = Object.fromEntries(VIDEO_BUCKETS.map((bucket) => [bucket, appendNewlyShippedEntries(+ readVideoBucket(safeVideo, bucket),+ DEFAULT_REGISTRY.video[bucket],+ shippedIds[bucket],+ )]));- const updatedShippedVideo = {- macos: [...shippedMacosIds, ...macosResult.newlyShipped],- windows: [...shippedWindowsIds, ...windowsResult.newlyShipped],- };+ const updatedShippedVideo = Object.fromEntries(VIDEO_BUCKETS.map((bucket) => [+ bucket, [...shippedIds[bucket], ...bucketResults[bucket].newlyShipped],+ ]));// Image upgrade path. Same shape as video, single list. The flux2 upgrade// (upgradeImageEntries) runs first so legacy `broken: 'macos'` entries get@@ -1013,8 +1022,17 @@ const normalizeRegistry = (parsed) => {const videoEntries = (entries) => sanitizeFinishProfiles(applyVideoFinishProfiles(applyVideoDisclosures(backfillRuntime(upgradeMiniMaxH3OutputControls(dropRetiredEntries(entries)))),));- const macosEntries = videoEntries(macosResult.entries);- const windowsEntries = videoEntries(windowsResult.entries);+ const normalizedBuckets = Object.fromEntries(+ VIDEO_BUCKETS.map((bucket) => [bucket, videoEntries(bucketResults[bucket].entries)]),+ );++ // Spread the user's own `video` keys but NOT the legacy bucket spellings: the+ // canonical keys below already carry those lists, and leaving both on the+ // object would persist two spellings of the same bucket into a file users+ // hand-edit — a later edit to the stale copy would silently do nothing.+ const carriedVideo = Object.fromEntries(+ Object.entries(safeVideo).filter(([key]) => !LEGACY_VIDEO_KEYS.includes(key)),+ );return {...DEFAULT_REGISTRY,@@ -1023,15 +1041,15 @@ const normalizeRegistry = (parsed) => {textEncoders: arrayOrDefault(safe.textEncoders, DEFAULT_REGISTRY.textEncoders),video: {...DEFAULT_REGISTRY.video,- ...safeVideo,- macos: macosEntries,- windows: windowsEntries,- defaultMacos: resolveRetiredDefault(- safeVideo.defaultMacos ?? DEFAULT_REGISTRY.video.defaultMacos, macosEntries,- ),- defaultWindows: resolveRetiredDefault(- safeVideo.defaultWindows ?? DEFAULT_REGISTRY.video.defaultWindows, windowsEntries,- ),+ ...carriedVideo,+ ...normalizedBuckets,+ ...Object.fromEntries(VIDEO_BUCKETS.map((bucket) => [+ VIDEO_DEFAULT_KEYS[bucket],+ resolveRetiredDefault(+ readVideoDefault(safeVideo, bucket) ?? DEFAULT_REGISTRY.video[VIDEO_DEFAULT_KEYS[bucket]],+ normalizedBuckets[bucket],+ ),+ ])),},_shippedDefaults: {...(safe._shippedDefaults || {}),@@ -1060,21 +1078,20 @@ const normalizeRegistry = (parsed) => {// re-add and delete the entry again from the UI. We surface it anyway// because the silent-skipping behaviour was the original bug.//-// `kind` is either 'image' (single list at `_shippedDefaults.image.list`)-// or 'video' (per-platform arrays at `_shippedDefaults.video.macos` /-// `_shippedDefaults.video.windows`).-const warnDrift = (kind, platform, shippedIds, defaultIds, presentIds) => {+// `where` and `shippedKey` are the two on-disk paths the warning quotes, and+// both are resolved by the CALLER rather than assembled here: image keeps its+// ids at `_shippedDefaults.image.list` while video keeps them at+// `_shippedDefaults.video.{mlx,cuda}`, and either half of a pre-#4142 registry+// may still be spelled `macos` / `windows` (migration 242 can write a canonical+// snapshot onto a legacy-keyed `video`). A copy-paste out of this warning has to+// land on a key that actually exists in the user's file.+const warnDrift = ({ where, shippedKey }, shippedIds, defaultIds, presentIds) => {const shippedSet = new Set(shippedIds || []);const defaultSet = new Set(defaultIds || []);const presentSet = new Set(presentIds || []);for (const id of shippedSet) {if (!defaultSet.has(id)) continue; // not a current built-in; ignoreif (presentSet.has(id)) continue; // present — no drift- // shippedIds for image lives at `_shippedDefaults.image.list`; for video- // it's `_shippedDefaults.video.{macos,windows}` directly. Surface the- // accurate key so a copy-paste from the warning lands in the right place.- const where = platform ? `${kind}.${platform}` : kind;- const shippedKey = platform ? `_shippedDefaults.${kind}.${platform}` : `_shippedDefaults.${kind}.list`;console.log(`⚠️ media-models drift: built-in "${id}" was shipped but is missing from ${where}[] — if the deletion is intentional this warning will repeat each boot (no silence-without-restore path exists); to restore, either re-add the entry manually or delete ${shippedKey} entirely to re-bootstrap`);}};@@ -1105,33 +1122,36 @@ export const loadMediaModels = () => {const sd = parsed._shippedDefaults;if (isPlainObject(sd.image) && Array.isArray(parsed.image)) {warnDrift(- 'image',- null,+ { where: 'image', shippedKey: '_shippedDefaults.image.list' },Array.isArray(sd.image.list) ? sd.image.list : [],DEFAULT_REGISTRY.image.map((m) => m.id),parsed.image.map((m) => m?.id).filter((id) => typeof id === 'string'),);}- // Only the CURRENT platform's video list is worth warning about. The- // pickers, downloads, and every edit path read one platform's array+ // Only the CURRENT machine's video bucket is worth warning about. The+ // pickers, downloads, and every edit path read one bucket's array// (`getVideoModels`), so drift in the other one is invisible and// unactionable here — and because the warning has no silence-without-- // restore path, a Windows box would print the macOS rows on every single+ // restore path, a CUDA box would print the MLX rows on every single// boot forever with nothing the user can usefully do about them. The- // machine that actually runs that platform still gets the warning.- const driftPlatform = IS_WIN ? 'windows' : 'macos';+ // machine that actually runs that bucket still gets the warning.+ const driftBucket = activeVideoBucket();+ const shippedDrift = readVideoBucket(sd.video, driftBucket);+ const presentDrift = readVideoBucket(parsed.video, driftBucket);if (isPlainObject(sd.video) &&isPlainObject(parsed.video) &&- Array.isArray(sd.video[driftPlatform]) &&- Array.isArray(parsed.video[driftPlatform])+ Array.isArray(shippedDrift) &&+ Array.isArray(presentDrift)) {warnDrift(- 'video',- driftPlatform,- sd.video[driftPlatform],- DEFAULT_REGISTRY.video[driftPlatform].map((m) => m.id),- parsed.video[driftPlatform].map((m) => m?.id).filter((id) => typeof id === 'string'),+ {+ where: `video.${resolveVideoBucketKey(parsed.video, driftBucket)}`,+ shippedKey: `_shippedDefaults.video.${resolveVideoBucketKey(sd.video, driftBucket)}`,+ },+ shippedDrift,+ DEFAULT_REGISTRY.video[driftBucket].map((m) => m.id),+ presentDrift.map((m) => m?.id).filter((id) => typeof id === 'string'),);}}@@ -1148,10 +1168,20 @@ export const loadMediaModels = () => {: null;const normalizedVideo = cached._shippedDefaults.video;const normalizedImage = cached._shippedDefaults.image;+ // A pre-#4142 bucket spelling still on disk counts as a change: the+ // normalized object is canonical-only, so the file has to be rewritten once+ // or the two spellings diverge the next time anything edits the registry.+ // (Migration 270 performs the same rename; this is its load-time twin, for+ // the same reason applyVideoDisclosures mirrors migration 237.)+ const carriesLegacyKeys = (obj) => isPlainObject(obj)+ && LEGACY_VIDEO_KEYS.some((key) => Object.hasOwn(obj, key));const videoChanged =parsedShippedVideo === null ||- normalizedVideo.macos.length !== (parsedShippedVideo.macos?.length ?? 0) ||- normalizedVideo.windows.length !== (parsedShippedVideo.windows?.length ?? 0);+ carriesLegacyKeys(parsed.video) ||+ carriesLegacyKeys(parsedShippedVideo) ||+ VIDEO_BUCKETS.some((bucket) => (+ normalizedVideo[bucket].length !== (readVideoBucket(parsedShippedVideo, bucket)?.length ?? 0)+ ));const imageChanged =parsedShippedImage === null ||normalizedImage.list.length !== (parsedShippedImage.list?.length ?? 0);@@ -1192,15 +1222,17 @@ const persistRegistry = (reg) => {export const isUserModelEntry = (entry) => entry?.source === 'user';// Locate a model entry by id, returning `{ entry, list, listKey, idx }` or null.-// Scans the CURRENT platform's video list + the image list — NOT the other-// platform's video list. The other platform's rows aren't visible to+// Scans the CURRENT machine's video bucket + the image list — NOT the other+// bucket's video list. The other bucket's rows aren't visible to// getVideoModels()/the render path on this install, and scanning both would-// make patch/remove ambiguous when a shared media-models.json (macOS+Windows-// peer) legitimately holds the same custom id in both platform lists — a-// remove(id) meant for the Windows row would hit the macOS row first. `listKey`-// ('macos' | 'windows' | 'image') lets the mutators rebuild just that list.+// make patch/remove ambiguous when a shared media-models.json (an MLX box and a+// CUDA box syncing as peers) legitimately holds the same custom id in both+// buckets — a remove(id) meant for the CUDA row would hit the MLX row first.+// `listKey` ('mlx' | 'cuda' | 'image') lets the mutators rebuild just that list.+// The registry passed in is always post-normalizeRegistry, so its bucket keys+// are canonical.const findModelLocation = (reg, id) => {- const videoKey = IS_WIN ? 'windows' : 'macos';+ const videoKey = activeVideoBucket();const lists = [[videoKey, reg.video?.[videoKey]],['image', reg.image],@@ -1222,7 +1254,7 @@ const withList = (reg, listKey, nextList) =>: { ...reg, video: { ...reg.video, [listKey]: nextList } };// Add a user model entry to the registry. `kind` selects the target list:-// 'video' → the current platform's video list; 'image' → the image list.+// 'video' → the current machine's video bucket; 'image' → the image list.// Throws on a duplicate id (a repo already added). Persists + hot-reloads.export const addUserModelEntry = (entry, { kind }) => {if (!entry || typeof entry.id !== 'string') {@@ -1232,13 +1264,13 @@ export const addUserModelEntry = (entry, { kind }) => {throw new ServerError(`Unknown model kind "${kind}" — expected "image" or "video".`, { status: 400, code: 'BAD_MODEL_KIND' });}const reg = loadMediaModels();- const listKey = kind === 'video' ? (IS_WIN ? 'windows' : 'macos') : 'image';+ const listKey = kind === 'video' ? activeVideoBucket() : 'image';// Conflict-check against the ACTIVE-on-this-install lists — the current- // platform's video list + the image list — via findModelLocation (which+ // machine's video bucket + the image list — via findModelLocation (which// scopes to exactly those). This rejects a collision between the current// video list and the image list (both mutable through the same :id-only// PATCH/DELETE, so a dup would make one row unaddressable), while still- // allowing the same custom video id to be added on the OTHER platform's list+ // allowing the same custom video id to be added on the OTHER bucket's list// of a shared media-models.json (that list isn't scanned, so no false 409).if (findModelLocation(reg, entry.id)) {throw new ServerError(@@ -1306,8 +1338,11 @@ export const removeUserModelEntry = (id) => {return { ok: true, id };};+// `broken` is either `true` (broken everywhere) or the name of the ONE bucket+// it's broken on. Pre-#4142 entries spell that name `macos` / `windows`, so+// matchesVideoBucket accepts both spellings for the active bucket.const platformBroken = (broken) =>- broken === true || (typeof broken === 'string' && broken === (IS_WIN ? 'windows' : 'macos'));+ broken === true || matchesVideoBucket(broken, activeVideoBucket());// `supportedModes` is resolved HERE rather than in normalizeRegistry (#3737):// deriving on read covers the load path, the user-model mutators (which bypass@@ -1316,30 +1351,31 @@ const platformBroken = (broken) =>// *declared* list that no later correction to VIDEO_RUNTIME_MODES could reach.export const getVideoModels = () => {const reg = loadMediaModels();- const list = IS_WIN ? (reg.video.windows || []) : (reg.video.macos || []);+ const list = readVideoBucket(reg.video, activeVideoBucket()) || [];return applyVideoSupportedModes(list.filter((m) => !platformBroken(m.broken)));};export const getDefaultVideoModelId = () => {const reg = loadMediaModels();- // Note: defaultMacos / defaultWindows may legitimately point at a model+ // Note: defaultMlx / defaultCuda may legitimately point at a model// flagged `deprecated: true` — the dgrauet (non-deprecated) runtime// requires an opt-in venv (`INSTALL_LTX2=1 bash scripts/setup-image-video.sh`),// so the shipped default must stay on a model that works out of the box.// The UI dropdowns surface dgrauet at the top via the `Legacy` optgroup// pattern; user-driven migration > auto-rolling forward.- const configuredId = IS_WIN ? reg.video.defaultWindows : reg.video.defaultMacos;- // Validate against the platform's available (non-broken) list — a typo or- // a model marked broken on this platform would otherwise surface as+ const bucket = activeVideoBucket();+ const configuredId = readVideoDefault(reg.video, bucket);+ // Validate against the bucket's available (non-broken) list — a typo or+ // a model marked broken on this bucket would otherwise surface as// "Unknown video model" the first time the UI tries to use the default.const available = getVideoModels();if (available.some((m) => m.id === configuredId)) return configuredId;const fallback = available[0]?.id;if (fallback) {- console.log(`⚠️ Unknown default video model "${configuredId}" for ${IS_WIN ? 'windows' : 'macos'}; falling back to "${fallback}"`);+ console.log(`⚠️ Unknown default video model "${configuredId}" for ${bucket}; falling back to "${fallback}"`);return fallback;}- console.log(`⚠️ Unknown default video model "${configuredId}" for ${IS_WIN ? 'windows' : 'macos'}; no available models to fall back to`);+ console.log(`⚠️ Unknown default video model "${configuredId}" for ${bucket}; no available models to fall back to`);return configuredId;};diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.jsindex 1983ab07dd..c43ce51d9b 100644--- a/server/lib/mediaModels.test.js+++ b/server/lib/mediaModels.test.js@@ -3,6 +3,7 @@ import { existsSync, mkdtempSync, rmSync, writeFileSync, readFileSync } from 'fsimport { tmpdir, homedir } from 'os';import { dirname, join } from 'path';import { fileURLToPath } from 'url';+import { pinPlatform } from './testHelper.js';const __dirname_self = dirname(fileURLToPath(import.meta.url));const SAMPLE_REGISTRY_PATH = join(__dirname_self, '..', '..', 'data.reference', 'media-models.json');@@ -59,7 +60,7 @@ describe('mediaModels registry', () => {it('ships LTX-2.5 MLX Q8 as a sibling runtime of the 2.3 dgrauet pin', async () => {const { loadMediaModels } = await import('./mediaModels.js');- const ltx25 = loadMediaModels().video.macos.find((model) => model.id === 'ltx25_mlx_q8');+ const ltx25 = loadMediaModels().video.mlx.find((model) => model.id === 'ltx25_mlx_q8');expect(ltx25).toMatchObject({runtime: 'ltx25',repo: 'MrMofer/ltx-2.5-mlx-q8',@@ -74,7 +75,7 @@ describe('mediaModels registry', () => {const { loadMediaModels } = await import('./mediaModels.js');// H3 is an Apple-silicon MLX runtime, so inspect the shipped macOS catalog// directly instead of the current platform's filtered model list.- const h3 = loadMediaModels().video.macos.find((model) => model.id === 'minimax_h3_8bit');+ const h3 = loadMediaModels().video.mlx.find((model) => model.id === 'minimax_h3_8bit');expect(h3).toMatchObject({runtime: 'minimax_h3',repo: 'pipenetwork/MiniMax-H3-MLX-8bit',@@ -133,11 +134,11 @@ describe('mediaModels registry', () => {expect(h3.termsGate.id).toBe('minimax-h3-community-license-2026-08-02');});- it('ships MiniMax H3 CUDA as the Windows/NVIDIA H3 profile', async () => {+ it('ships MiniMax H3 CUDA as the NVIDIA H3 profile', async () => {const { loadMediaModels } = await import('./mediaModels.js');- // The CUDA entry is Windows-list-only, so inspect the shipped catalog+ // The CUDA entry is CUDA-bucket-only, so inspect the shipped catalog// directly rather than the current platform's filtered list.- const h3 = loadMediaModels().video.windows.find((model) => model.id === 'minimax_h3_cuda');+ const h3 = loadMediaModels().video.cuda.find((model) => model.id === 'minimax_h3_cuda');expect(h3).toMatchObject({runtime: 'minimax_h3_cuda',repo: 'MiniMaxAI/MiniMax-H3',@@ -152,7 +153,7 @@ describe('mediaModels registry', () => {});// Same canvas contract as the MLX profile — it's the checkpoint's, not the// runner's — so these must not drift apart.- const mlx = loadMediaModels().video.macos.find((model) => model.id === 'minimax_h3_8bit');+ const mlx = loadMediaModels().video.mlx.find((model) => model.id === 'minimax_h3_8bit');expect(h3.defaultWidth).toBe(mlx.defaultWidth);expect(h3.defaultHeight).toBe(mlx.defaultHeight);expect(h3.resolutionStep).toBe(mlx.resolutionStep);@@ -170,7 +171,7 @@ describe('mediaModels registry', () => {it('pins an explicit file list for MiniMax H3 CUDA rather than a repo snapshot', async () => {const { loadMediaModels } = await import('./mediaModels.js');- const h3 = loadMediaModels().video.windows.find((model) => model.id === 'minimax_h3_cuda');+ const h3 = loadMediaModels().video.cuda.find((model) => model.id === 'minimax_h3_cuda');// `MiniMaxAI/MiniMax-H3` is ~498 GB: it carries the diffusers layout, the// `transformer_ref/` partition for the ref2va workflow PortOS doesn't// expose, AND the original non-diffusers FL2VA/ + Ref2VA/ layouts the MLX@@ -220,16 +221,16 @@ describe('mediaModels registry', () => {const { VIDEO_RUNTIME_MODES } = await import('./videoModeProfiles.js');const { loadMediaModels } = await import('./mediaModels.js');const { video } = loadMediaModels();- for (const entry of [...video.macos, ...video.windows]) {+ for (const entry of [...video.mlx, ...video.cuda]) {expect(Object.keys(VIDEO_RUNTIME_MODES), entry.id).toContain(entry.runtime);}});it('retires the hunyuan legacy `mode: t2v` field for a text-only contract', async () => {const { loadMediaModels, getVideoModels } = await import('./mediaModels.js');- expect(loadMediaModels().video.macos.find((m) => m.id === 'hunyuan_video').mode).toBeUndefined();+ expect(loadMediaModels().video.mlx.find((m) => m.id === 'hunyuan_video').mode).toBeUndefined();const hunyuan = getVideoModels().find((m) => m.id === 'hunyuan_video');- // Windows ships no hunyuan entry, so only assert where it's runnable.+ // The CUDA bucket ships no hunyuan entry, so only assert where it's runnable.if (hunyuan) expect(hunyuan.supportedModes).toEqual(['text']);});@@ -240,16 +241,16 @@ describe('mediaModels registry', () => {// A persisted copy would read back as a *declared* list, freezing this// install's built-ins against any later correction to VIDEO_RUNTIME_MODES.const onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));- const mlx = [...onDisk.video.macos, ...onDisk.video.windows]+ const mlx = [...onDisk.video.mlx, ...onDisk.video.cuda].find((m) => m.runtime === 'mlx_video');expect(mlx.supportedModes).toBeUndefined();});it('keeps a user entry that declares its own list, and resolves one that does not', async () => {- const platform = process.platform === 'win32' ? 'windows' : 'macos';+ const platform = process.platform === 'darwin' ? 'mlx' : 'cuda';writeFileSync(registryFile, JSON.stringify({video: {- macos: [], windows: [], defaultMacos: 'custom-narrow', defaultWindows: 'custom-narrow',+ mlx: [], cuda: [], defaultMlx: 'custom-narrow', defaultCuda: 'custom-narrow',[platform]: [{ id: 'custom-narrow', name: 'Custom', runtime: 'mlx_video', supportedModes: ['text'], source: 'user' },{ id: 'custom-bare', name: 'Bare', runtime: 'mlx_video', source: 'user' },@@ -257,7 +258,7 @@ describe('mediaModels registry', () => {},// Non-empty so the deletion-survives-upgrade union doesn't re-append// the built-ins over the two entries under test.- _shippedDefaults: { video: { macos: ['custom-narrow', 'custom-bare'], windows: ['custom-narrow', 'custom-bare'] } },+ _shippedDefaults: { video: { mlx: ['custom-narrow', 'custom-bare'], cuda: ['custom-narrow', 'custom-bare'] } },}));const { getVideoModels } = await import('./mediaModels.js');const byId = new Map(getVideoModels().map((m) => [m.id, m]));@@ -267,10 +268,10 @@ describe('mediaModels registry', () => {});it('hides models with broken === current platform', async () => {- const here = process.platform === 'win32' ? 'windows' : 'macos';- const elsewhere = process.platform === 'win32' ? 'macos' : 'windows';+ const here = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const elsewhere = process.platform === 'darwin' ? 'cuda' : 'mlx';writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'works', name: 'Works' },{ id: 'broken-here', name: 'Broken Here', broken: here },@@ -288,7 +289,7 @@ describe('mediaModels registry', () => {it('expandHome resolves ~/ correctly without dropping the home dir', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [],textEncoders: [{ id: 'tilde-only', label: 't', repo: 'r1', localPath: '~' },@@ -315,7 +316,7 @@ describe('mediaModels registry', () => {it('getTextEncoderRepo prefers existing localPath over repo', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [],textEncoders: [{ id: 'has-local', label: 'L', repo: 'org/repo', localPath: tmpDir },@@ -328,7 +329,7 @@ describe('mediaModels registry', () => {it('getTextEncoderRepo falls back to repo when localPath does not exist', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [],textEncoders: [{ id: 't', label: 't', repo: 'org/repo', localPath: '/definitely/not/existing/12345' }],selectedTextEncoder: 't',@@ -375,8 +376,8 @@ describe('mediaModels registry', () => {const { loadMediaModels, getVideoModels, getDefaultVideoModelId } = await import('./mediaModels.js');const reg = loadMediaModels();expect(reg.video).toBeDefined();- expect(Array.isArray(reg.video.macos)).toBe(true);- expect(Array.isArray(reg.video.windows)).toBe(true);+ expect(Array.isArray(reg.video.mlx)).toBe(true);+ expect(Array.isArray(reg.video.cuda)).toBe(true);expect(getVideoModels().length).toBeGreaterThan(0);expect(typeof getDefaultVideoModelId()).toBe('string');});@@ -386,15 +387,15 @@ describe('mediaModels registry', () => {// arrays — without coercion, getImageModels()/getVideoModels() throw at// module import-time.writeFileSync(registryFile, JSON.stringify({- video: { macos: 'ltx', windows: { id: 'oops' } },+ video: { mlx: 'ltx', cuda: { id: 'oops' } },image: {},textEncoders: 'gemma',selectedTextEncoder: 'gemma-bf16',}));const { loadMediaModels, getVideoModels, getImageModels } = await import('./mediaModels.js');const reg = loadMediaModels();- expect(Array.isArray(reg.video.macos)).toBe(true);- expect(Array.isArray(reg.video.windows)).toBe(true);+ expect(Array.isArray(reg.video.mlx)).toBe(true);+ expect(Array.isArray(reg.video.cuda)).toBe(true);expect(Array.isArray(reg.image)).toBe(true);expect(Array.isArray(reg.textEncoders)).toBe(true);expect(() => getVideoModels()).not.toThrow();@@ -405,24 +406,24 @@ describe('mediaModels registry', () => {writeFileSync(registryFile, JSON.stringify({}));const { loadMediaModels } = await import('./mediaModels.js');const reg = loadMediaModels();- expect(reg.video.defaultMacos).toBeDefined();+ expect(reg.video.defaultMlx).toBeDefined();expect(reg.textEncoders.length).toBeGreaterThan(0);});it('getDefaultVideoModelId falls back to first available when configured id is unknown', async () => {- const platformKey = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = process.platform === 'win32' ? 'macos' : 'windows';+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';writeFileSync(registryFile, JSON.stringify({video: {- macos: [],- windows: [],+ mlx: [],+ cuda: [],[platformKey]: [{ id: 'real-model', name: 'Real' },{ id: 'other', name: 'Other' },],[otherKey]: [],- defaultMacos: 'nonexistent-typo',- defaultWindows: 'nonexistent-typo',+ defaultMlx: 'nonexistent-typo',+ defaultCuda: 'nonexistent-typo',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],@@ -437,7 +438,7 @@ describe('mediaModels registry', () => {it('getTextEncoderRepo falls back when entry has no repo string', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [],textEncoders: [{ id: 't', label: 't' }], // no repo fieldselectedTextEncoder: 't',@@ -464,20 +465,20 @@ describe('mediaModels registry', () => {});it('getDefaultVideoModelId skips broken-on-platform models when falling back', async () => {- const platformKey = process.platform === 'win32' ? 'windows' : 'macos';- const here = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = process.platform === 'win32' ? 'macos' : 'windows';+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const here = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';writeFileSync(registryFile, JSON.stringify({video: {- macos: [],- windows: [],+ mlx: [],+ cuda: [],[platformKey]: [{ id: 'broken-here', name: 'Broken', broken: here },{ id: 'works', name: 'Works' },],[otherKey]: [],- defaultMacos: 'broken-here',- defaultWindows: 'broken-here',+ defaultMlx: 'broken-here',+ defaultCuda: 'broken-here',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],@@ -497,20 +498,20 @@ describe('mediaModels registry', () => {const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels } = await import('./mediaModels.js');const reg = loadMediaModels();- // All built-in macos models should be present+ // All built-in MLX models should be presentconst { DEFAULT_VIDEO_MODEL_IDS } = await import('./mediaModels.js').then(async (m) => {// We don't export the ids directly, so read them from the registry itselfconst r = m.loadMediaModels();- return { DEFAULT_VIDEO_MODEL_IDS: r.video.macos.map((e) => e.id) };+ return { DEFAULT_VIDEO_MODEL_IDS: r.video.mlx.map((e) => e.id) };});for (const id of DEFAULT_VIDEO_MODEL_IDS) {- expect(reg.video.macos.some((e) => e.id === id)).toBe(true);+ expect(reg.video.mlx.some((e) => e.id === id)).toBe(true);}// _shippedDefaults should be populated- expect(reg._shippedDefaults?.video?.macos?.length).toBeGreaterThan(0);+ expect(reg._shippedDefaults?.video?.mlx?.length).toBeGreaterThan(0);// Disk should now contain _shippedDefaultsconst onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));- expect(onDisk._shippedDefaults?.video?.macos?.length).toBeGreaterThan(0);+ expect(onDisk._shippedDefaults?.video?.mlx?.length).toBeGreaterThan(0);logSpy.mockRestore();});@@ -525,17 +526,17 @@ describe('mediaModels registry', () => {// _shippedDefaults claims every current built-in so appendNewlyShippedEntries// adds nothing — these cases are about what the load REMOVES, and an// "everything else is new" fixture would bury it under a dozen appends.- const shippedMacosIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))- .video.macos.map((e) => e.id).concat(RETIRED_ID);+ const shippedMlxIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))+ .video.mlx.map((e) => e.id).concat(RETIRED_ID);- const writeRegistry = (macos, defaultMacos = 'ltx23_distilled_q4') => writeFileSync(+ const writeRegistry = (mlx, defaultMlx = 'ltx23_distilled_q4') => writeFileSync(registryFile,JSON.stringify({- video: { macos, windows: [], defaultMacos, defaultWindows: 'ltx_video' },+ video: { mlx, cuda: [], defaultMlx, defaultCuda: 'ltx_video' },image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',- _shippedDefaults: { video: { macos: shippedMacosIds, windows: [] } },+ _shippedDefaults: { video: { mlx: shippedMlxIds, cuda: [] } },}),);const retiredEntry = (repo = SHIPPED_REPO) => ({@@ -547,7 +548,7 @@ describe('mediaModels registry', () => {writeRegistry([retiredEntry(), survivor]);const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels } = await import('./mediaModels.js');- expect(loadMediaModels().video.macos.map((e) => e.id)).toEqual(['ltx23_distilled_q4']);+ expect(loadMediaModels().video.mlx.map((e) => e.id)).toEqual(['ltx23_distilled_q4']);logSpy.mockRestore();});@@ -556,7 +557,7 @@ describe('mediaModels registry', () => {writeRegistry([retiredEntry('example-org/ltx2-fork'), survivor]);const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels } = await import('./mediaModels.js');- expect(loadMediaModels().video.macos.map((e) => e.id)).toContain(RETIRED_ID);+ expect(loadMediaModels().video.mlx.map((e) => e.id)).toContain(RETIRED_ID);logSpy.mockRestore();});@@ -564,7 +565,7 @@ describe('mediaModels registry', () => {writeRegistry([retiredEntry(), survivor], RETIRED_ID);const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels, getDefaultVideoModelId } = await import('./mediaModels.js');- expect(loadMediaModels().video.defaultMacos).toBe('ltx23_distilled_q4');+ expect(loadMediaModels().video.defaultMlx).toBe('ltx23_distilled_q4');if (process.platform !== 'win32') expect(getDefaultVideoModelId()).toBe('ltx23_distilled_q4');logSpy.mockRestore();});@@ -573,7 +574,7 @@ describe('mediaModels registry', () => {writeRegistry([retiredEntry('example-org/ltx2-fork'), survivor], RETIRED_ID);const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels } = await import('./mediaModels.js');- expect(loadMediaModels().video.defaultMacos).toBe(RETIRED_ID);+ expect(loadMediaModels().video.defaultMlx).toBe(RETIRED_ID);logSpy.mockRestore();});@@ -583,7 +584,7 @@ describe('mediaModels registry', () => {const { loadMediaModels } = await import('./mediaModels.js');// Nothing left to name — getDefaultVideoModelId's "unknown default →// first available" warning is the honest outcome.- expect(loadMediaModels().video.defaultMacos).toBe(RETIRED_ID);+ expect(loadMediaModels().video.defaultMlx).toBe(RETIRED_ID);logSpy.mockRestore();});@@ -591,7 +592,7 @@ describe('mediaModels registry', () => {writeRegistry([survivor]);const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels } = await import('./mediaModels.js');- expect(loadMediaModels().video.macos.some((e) => e.id === RETIRED_ID)).toBe(false);+ expect(loadMediaModels().video.mlx.some((e) => e.id === RETIRED_ID)).toBe(false);logSpy.mockRestore();});});@@ -601,8 +602,8 @@ describe('mediaModels registry', () => {// 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 shippedMlxIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))+ .video.mlx.map((entry) => entry.id);const legacyH3 = (extra = {}) => ({id: 'minimax_h3_8bit',name: 'MiniMax H3',@@ -615,17 +616,17 @@ describe('mediaModels registry', () => {...extra,});const writeRegistry = (entry) => writeFileSync(registryFile, JSON.stringify({- video: { macos: [entry], windows: [], defaultMacos: entry.id, defaultWindows: 'ltx_video' },+ video: { mlx: [entry], cuda: [], defaultMlx: entry.id, defaultCuda: 'ltx_video' },image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',- _shippedDefaults: { video: { macos: shippedMacosIds, windows: [] } },+ _shippedDefaults: { video: { mlx: shippedMlxIds, cuda: [] } },}));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];+ const entry = loadMediaModels().video.mlx[0];expect(entry).toMatchObject({defaultWidth: 1344,defaultHeight: 768,@@ -640,45 +641,45 @@ describe('mediaModels registry', () => {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');+ expect(module.loadMediaModels().video.mlx[0]).not.toHaveProperty('defaultWidth');vi.resetModules();writeRegistry(legacyH3({ resolutionStep: 64 }));module = await import('./mediaModels.js');- const entry = module.loadMediaModels().video.macos[0];+ const entry = module.loadMediaModels().video.mlx[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';+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';// Simulate a registry that already has _shippedDefaults (post-bootstrap)// but is missing one model the user deleted. The id MUST still be a current// built-in — a retired one would pass this assertion for the wrong reason// (nothing re-adds a model that left DEFAULT_REGISTRY).const deletedId = 'ltx23_dgrauet_q8';- const remainingMacos = [+ const remainingMlx = [{ id: 'ltx23_unified', name: 'LTX-2.3 Unified Beta (~48 GB)', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_distilled_q4', name: 'LTX-2.3 Distilled Q4 (~22 GB)', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_dgrauet_q4', name: 'LTX-2.3 dgrauet Q4', runtime: 'ltx2', steps: 8, guidance: 3.0 },];- const shippedMacosIds = [deletedId, ...remainingMacos.map((e) => e.id)];+ const shippedMlxIds = [deletedId, ...remainingMlx.map((e) => e.id)];writeFileSync(registryFile, JSON.stringify({video: {- [platformKey]: platformKey === 'macos' ? remainingMacos : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],+ [platformKey]: platformKey === 'mlx' ? remainingMlx : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],[otherKey]: [],- defaultMacos: 'ltx23_distilled_q4',- defaultWindows: 'ltx_video',+ defaultMlx: 'ltx23_distilled_q4',+ defaultCuda: 'ltx_video',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {video: {- macos: shippedMacosIds,- windows: ['ltx_video'],+ mlx: shippedMlxIds,+ cuda: ['ltx_video'],},},}));@@ -686,38 +687,38 @@ describe('mediaModels registry', () => {const { loadMediaModels } = await import('./mediaModels.js');const reg = loadMediaModels();// The deleted model must NOT be back- expect(reg.video.macos.some((e) => e.id === deletedId)).toBe(false);+ expect(reg.video.mlx.some((e) => e.id === deletedId)).toBe(false);// The shipped id must still be tracked- expect(reg._shippedDefaults.video.macos).toContain(deletedId);+ expect(reg._shippedDefaults.video.mlx).toContain(deletedId);logSpy.mockRestore();});it('new built-in id not in _shippedDefaults is added AND recorded', async () => {- const platformKey = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = process.platform === 'win32' ? 'macos' : 'windows';+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';// Simulate a registry that pre-dates a newly-shipped model: _shippedDefaults// exists but does NOT include 'ltx23_dgrauet_q8' (as if it shipped later).- const existingMacos = [+ const existingMlx = [{ id: 'ltx23_unified', name: 'LTX-2.3 Unified', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_distilled_q4', name: 'LTX-2.3 Q4', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_dgrauet_q4', name: 'LTX-2.3 dgrauet Q4', runtime: 'ltx2', steps: 8, guidance: 3.0 },];// _shippedDefaults does NOT include ltx23_dgrauet_q8- const shippedMacosIds = existingMacos.map((e) => e.id);+ const shippedMlxIds = existingMlx.map((e) => e.id);writeFileSync(registryFile, JSON.stringify({video: {- [platformKey]: platformKey === 'macos' ? existingMacos : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],+ [platformKey]: platformKey === 'mlx' ? existingMlx : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],[otherKey]: [],- defaultMacos: 'ltx23_distilled_q4',- defaultWindows: 'ltx_video',+ defaultMlx: 'ltx23_distilled_q4',+ defaultCuda: 'ltx_video',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {video: {- macos: shippedMacosIds,- windows: ['ltx_video'],+ mlx: shippedMlxIds,+ cuda: ['ltx_video'],},},}));@@ -726,14 +727,14 @@ describe('mediaModels registry', () => {const reg = loadMediaModels();// ltx23_dgrauet_q8 is a current DEFAULT_REGISTRY entry not yet shipped →// should be added to the user's list- expect(reg.video.macos.some((e) => e.id === 'ltx23_dgrauet_q8')).toBe(true);- expect(reg.video.macos.some((e) => e.id === 'minimax_h3_8bit')).toBe(true);+ expect(reg.video.mlx.some((e) => e.id === 'ltx23_dgrauet_q8')).toBe(true);+ expect(reg.video.mlx.some((e) => e.id === 'minimax_h3_8bit')).toBe(true);// And should now be recorded in _shippedDefaults- expect(reg._shippedDefaults.video.macos).toContain('ltx23_dgrauet_q8');- expect(reg._shippedDefaults.video.macos).toContain('minimax_h3_8bit');+ expect(reg._shippedDefaults.video.mlx).toContain('ltx23_dgrauet_q8');+ expect(reg._shippedDefaults.video.mlx).toContain('minimax_h3_8bit');// Persisted to diskconst onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));- expect(onDisk._shippedDefaults.video.macos).toContain('ltx23_dgrauet_q8');+ expect(onDisk._shippedDefaults.video.mlx).toContain('ltx23_dgrauet_q8');logSpy.mockRestore();});@@ -773,7 +774,7 @@ describe('mediaModels registry', () => {// Simulate an install that stored qwen-image-edit before the editOnly flag// existed — the entry lacks the field entirely.writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'qwen-image-edit', name: 'Qwen-Image-Edit', runner: 'qwen', repo: 'Qwen/Qwen-Image-Edit', pipelineClass: 'QwenImageEditPipeline', steps: 30, guidance: 4 },],@@ -787,7 +788,7 @@ describe('mediaModels registry', () => {it('preserves an explicit editOnly: false user override', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'qwen-image-edit', name: 'Qwen-Image-Edit', runner: 'qwen', repo: 'Qwen/Qwen-Image-Edit', pipelineClass: 'QwenImageEditPipeline', steps: 30, guidance: 4, editOnly: false },],@@ -812,7 +813,7 @@ describe('mediaModels registry', () => {it('backfills kvRepo onto a pre-flag flux2-klein-9b-bf16 entry (no migration needed)', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'flux2-klein-9b-bf16', name: 'Flux 2 Klein 9B (bf16)', runner: 'flux2', quantization: 'none', repo: 'black-forest-labs/FLUX.2-klein-9B', steps: 20, guidance: 3.5 },],@@ -826,7 +827,7 @@ describe('mediaModels registry', () => {it('preserves an explicit kvRepo user override (including empty-string clear)', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'flux2-klein-9b-bf16', name: 'Flux 2 Klein 9B (bf16)', runner: 'flux2', quantization: 'none', repo: 'black-forest-labs/FLUX.2-klein-9B', steps: 20, guidance: 3.5, kvRepo: '' },],@@ -840,7 +841,7 @@ describe('mediaModels registry', () => {it('does NOT inject kvRepo when repo points at a fork (fork-preservation, mirrors migration 064)', async () => {writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'flux2-klein-9b-bf16', name: 'Flux 2 Klein 9B (bf16)', runner: 'flux2', quantization: 'none', repo: 'my-fork/FLUX.2-klein-9B', steps: 20, guidance: 3.5 },],@@ -856,14 +857,14 @@ describe('mediaModels registry', () => {// Simulate a pre-z-image registry: only flux2 and Flux 1 entries, no// _shippedDefaults.image at all.writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'dev', name: 'Flux 1 Dev', steps: 20, guidance: 3.5 },{ id: 'schnell', name: 'Flux 1 Schnell', steps: 4, guidance: 0 },],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',- _shippedDefaults: { video: { macos: [], windows: [] } }, // image key missing+ _shippedDefaults: { video: { mlx: [], cuda: [] } }, // image key missing}));const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});const { loadMediaModels, getImageModels } = await import('./mediaModels.js');@@ -886,7 +887,7 @@ describe('mediaModels registry', () => {// _shippedDefaults.image already records z-image-turbo-bf16, but the user// has removed it from their image list.writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'dev', name: 'Flux 1 Dev', steps: 20, guidance: 3.5 },// z-image-turbo-bf16 deliberately absent@@ -894,7 +895,7 @@ describe('mediaModels registry', () => {textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {- video: { macos: [], windows: [] },+ video: { mlx: [], cuda: [] },image: { list: ['dev', 'z-image-turbo-bf16', 'flux2-klein-4b', 'flux2-klein-9b', 'flux2-klein-4b-int8', 'schnell', 'z-image-turbo-quant'] },},}));@@ -909,31 +910,31 @@ describe('mediaModels registry', () => {});it('user deletes a model that was newly added; deletion survives next load', async () => {- const platformKey = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = process.platform === 'win32' ? 'macos' : 'windows';+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';// _shippedDefaults includes ltx23_dgrauet_q8 (it was added in a prior// load), but the user has now removed it from their video list.- const userMacos = [+ const userMlx = [{ id: 'ltx23_unified', name: 'LTX-2.3 Unified', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_distilled_q4', name: 'LTX-2.3 Q4', runtime: 'mlx_video', steps: 25, guidance: 3.0 },{ id: 'ltx23_dgrauet_q4', name: 'LTX-2.3 dgrauet Q4', runtime: 'ltx2', steps: 8, guidance: 3.0 },// ltx23_dgrauet_q8 intentionally absent];- const shippedMacosIds = [...userMacos.map((e) => e.id), 'ltx23_dgrauet_q8'];+ const shippedMlxIds = [...userMlx.map((e) => e.id), 'ltx23_dgrauet_q8'];writeFileSync(registryFile, JSON.stringify({video: {- [platformKey]: platformKey === 'macos' ? userMacos : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],+ [platformKey]: platformKey === 'mlx' ? userMlx : [{ id: 'ltx_video', name: 'LTX', runtime: 'mlx_video', steps: 25, guidance: 3.0 }],[otherKey]: [],- defaultMacos: 'ltx23_distilled_q4',- defaultWindows: 'ltx_video',+ defaultMlx: 'ltx23_distilled_q4',+ defaultCuda: 'ltx_video',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {video: {- macos: shippedMacosIds,- windows: ['ltx_video'],+ mlx: shippedMlxIds,+ cuda: ['ltx_video'],},},}));@@ -941,9 +942,9 @@ describe('mediaModels registry', () => {const { loadMediaModels } = await import('./mediaModels.js');const reg = loadMediaModels();// Deletion must be respected — model NOT re-added- expect(reg.video.macos.some((e) => e.id === 'ltx23_dgrauet_q8')).toBe(false);+ expect(reg.video.mlx.some((e) => e.id === 'ltx23_dgrauet_q8')).toBe(false);// The id stays in _shippedDefaults so future loads also honour the deletion- expect(reg._shippedDefaults.video.macos).toContain('ltx23_dgrauet_q8');+ expect(reg._shippedDefaults.video.mlx).toContain('ltx23_dgrauet_q8');logSpy.mockRestore();});@@ -958,7 +959,7 @@ describe('mediaModels registry', () => {// image[] array doesn't have it (and it IS a current DEFAULT_REGISTRY// entry, so this is true drift — not a legitimate deletion).writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'dev', name: 'Flux 1 Dev' },// 'z-image-turbo-bf16' deliberately missing@@ -966,7 +967,7 @@ describe('mediaModels registry', () => {textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {- video: { macos: [], windows: [] },+ video: { mlx: [], cuda: [] },image: { list: ['dev', 'z-image-turbo-bf16'] },},}));@@ -986,12 +987,12 @@ describe('mediaModels registry', () => {// that we removed from DEFAULT_REGISTRY) — that's not drift, it's normal// upgrade churn. The warning must skip it.writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'dev', name: 'Flux 1 Dev' }],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {- video: { macos: [], windows: [] },+ video: { mlx: [], cuda: [] },image: { list: ['dev', 'ancient-removed-model'] },},}));@@ -1005,14 +1006,14 @@ describe('mediaModels registry', () => {logSpy.mockRestore();});- it('drift warning fires for video.macos as well as image', async () => {- const platformKey = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = process.platform === 'win32' ? 'macos' : 'windows';+ it('drift warning fires for the video bucket as well as image', async () => {+ const platformKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = process.platform === 'darwin' ? 'cuda' : 'mlx';// _shippedDefaults claims ltx23_dgrauet_q4 was shipped (and it IS still- // in DEFAULT_REGISTRY.video.macos), but the user's macos list doesn't+ // in DEFAULT_REGISTRY.video.mlx), but the user's mlx list doesn't// have it.const driftedId = 'ltx23_dgrauet_q4';- const userPlatformList = platformKey === 'macos' ? [+ const userPlatformList = platformKey === 'mlx' ? [{ id: 'ltx23_unified', name: 'LTX-2.3 Unified', runtime: 'mlx_video', steps: 25, guidance: 3.0 },// ltx23_dgrauet_q4 deliberately absent (drift)] : [@@ -1022,16 +1023,16 @@ describe('mediaModels registry', () => {video: {[platformKey]: userPlatformList,[otherKey]: [],- defaultMacos: 'ltx23_unified',- defaultWindows: 'ltx_video',+ defaultMlx: 'ltx23_unified',+ defaultCuda: 'ltx_video',},image: [],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {video: {- macos: platformKey === 'macos' ? ['ltx23_unified', driftedId] : [],- windows: platformKey === 'windows' ? ['ltx_video'] : [],+ mlx: platformKey === 'mlx' ? ['ltx23_unified', driftedId] : [],+ cuda: platformKey === 'cuda' ? ['ltx_video'] : [],},image: { list: [] },},@@ -1042,10 +1043,10 @@ describe('mediaModels registry', () => {const driftCalls = logSpy.mock.calls.map((args) => args.join(' ')).filter((line) => line.includes('media-models drift'));- // Only assert on macos to avoid platform divergence in CI — the macos+ // Only assert on mlx to avoid platform divergence in CI — the MLX// built-in list is the populated one for both test runs.- if (platformKey === 'macos') {- expect(driftCalls.some((c) => c.includes(driftedId) && c.includes('video.macos'))).toBe(true);+ if (platformKey === 'mlx') {+ expect(driftCalls.some((c) => c.includes(driftedId) && c.includes('video.mlx'))).toBe(true);}logSpy.mockRestore();});@@ -1078,12 +1079,12 @@ describe('mediaModels registry', () => {// NOT cause normalizeRegistry to silently re-add the missing built-in.// Auto-recovery would defeat real deletions.writeFileSync(registryFile, JSON.stringify({- video: { macos: [], windows: [], defaultMacos: 'x', defaultWindows: 'x' },+ video: { mlx: [], cuda: [], defaultMlx: 'x', defaultCuda: 'x' },image: [{ id: 'dev', name: 'Flux 1 Dev' }],textEncoders: [{ id: 't', label: 't', repo: 'r' }],selectedTextEncoder: 't',_shippedDefaults: {- video: { macos: [], windows: [] },+ video: { mlx: [], cuda: [] },image: { list: ['dev', 'z-image-turbo-bf16'] },},}));@@ -1121,7 +1122,7 @@ describe('user model entry mutators (#2124)', () => {expect(getVideoModels().some((m) => m.id === 'hf-test-video')).toBe(true);// And it's persisted to disk.const onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));- const inList = [...onDisk.video.macos, ...onDisk.video.windows].some((m) => m.id === 'hf-test-video');+ const inList = [...onDisk.video.mlx, ...onDisk.video.cuda].some((m) => m.id === 'hf-test-video');expect(inList).toBe(true);// The mutators bypass normalizeRegistry, so the mode backfill has to run// here too — otherwise the new model carries no supportedModes and the@@ -1154,11 +1155,11 @@ describe('user model entry mutators (#2124)', () => {it('conflict-checks only the target platform list, not every list', async () => {// A video id present ONLY on the OTHER platform's list must remain addable- // on the current platform (shared media-models.json across macOS+Windows).+ // in the current bucket (shared media-models.json across an MLX and a CUDA box).const { loadMediaModels } = await import('./mediaModels.js');const reg = loadMediaModels();- const currentKey = process.platform === 'win32' ? 'windows' : 'macos';- const otherKey = currentKey === 'macos' ? 'windows' : 'macos';+ const currentKey = process.platform === 'darwin' ? 'mlx' : 'cuda';+ const otherKey = currentKey === 'mlx' ? 'cuda' : 'mlx';reg.video[otherKey] = [...(reg.video[otherKey] || []), { ...videoEntry }];writeFileSync(registryFile, JSON.stringify(reg, null, 2) + '\n');vi.resetModules();@@ -1197,3 +1198,122 @@ describe('user model entry mutators (#2124)', () => {expect(reloaded).not.toBe(first); // fresh object after bust});});++// Issue #4142. The catalog used to select `IS_WIN ? video.windows : video.macos`,+// which handed a Linux install the MLX list — every entry on it unrunnable there —+// while the two torch+CUDA entries that DO run on Linux sat in an unreachable+// `windows` list. The axis is the runtime family, so the selector is "is this a+// Mac?" and the buckets are named for what they hold.+describe('video bucket selection is an MLX/CUDA axis, not an OS one', () => {+ let restorePlatform = () => {};+ const asPlatform = (value) => { restorePlatform = pinPlatform(value); };+ afterEach(() => restorePlatform());++ const MLX_ONLY = { id: 'mlx-only', name: 'MLX only', runtime: 'mlx_video', steps: 25, guidance: 3.0 };+ const CUDA_ONLY = { id: 'cuda-only', name: 'CUDA only', runtime: 'minimax_h3_cuda', steps: 8, guidance: 0 };++ // Canonical (post-#4142) and legacy (any registry written before it) spellings+ // of the same two-bucket registry. Both must resolve identically on every+ // platform — the legacy read aliases are the whole compatibility story for+ // installs that upgrade on their own schedule.+ // _shippedDefaults claims every current built-in so appendNewlyShippedEntries+ // adds nothing and each bucket holds exactly the one probe entry.+ const seed = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'));+ const shippedMlx = [...seed.video.mlx.map((m) => m.id), MLX_ONLY.id];+ const shippedCuda = [...seed.video.cuda.map((m) => m.id), CUDA_ONLY.id];+ const shippedImage = seed.image.map((m) => m.id);++ const CANONICAL = {+ video: { mlx: [MLX_ONLY], cuda: [CUDA_ONLY], defaultMlx: MLX_ONLY.id, defaultCuda: CUDA_ONLY.id },+ image: [],+ textEncoders: [{ id: 't', label: 't', repo: 'r' }],+ selectedTextEncoder: 't',+ _shippedDefaults: { video: { mlx: shippedMlx, cuda: shippedCuda }, image: { list: shippedImage } },+ };+ const LEGACY = {+ ...CANONICAL,+ video: { macos: [MLX_ONLY], windows: [CUDA_ONLY], defaultMacos: MLX_ONLY.id, defaultWindows: CUDA_ONLY.id },+ _shippedDefaults: { video: { macos: shippedMlx, windows: shippedCuda }, image: { list: shippedImage } },+ };++ const resolveOn = async (platform, registry) => {+ writeFileSync(registryFile, JSON.stringify(registry));+ asPlatform(platform);+ const { getVideoModels, getDefaultVideoModelId } = await import('./mediaModels.js');+ return { ids: getVideoModels().map((m) => m.id), defaultId: getDefaultVideoModelId() };+ };++ for (const [shape, registry] of [['canonical mlx/cuda keys', CANONICAL], ['legacy macos/windows keys', LEGACY]]) {+ describe(shape, () => {+ it('serves the MLX list on darwin', async () => {+ expect(await resolveOn('darwin', registry)).toEqual({ ids: [MLX_ONLY.id], defaultId: MLX_ONLY.id });+ });++ it('serves the CUDA list on win32', async () => {+ expect(await resolveOn('win32', registry)).toEqual({ ids: [CUDA_ONLY.id], defaultId: CUDA_ONLY.id });+ });++ // The bug: linux used to fall through to the macOS/MLX branch.+ it('serves the CUDA list on linux', async () => {+ expect(await resolveOn('linux', registry)).toEqual({ ids: [CUDA_ONLY.id], defaultId: CUDA_ONLY.id });+ });+ });+ }++ it('normalizes a legacy-keyed registry to the canonical keys on disk', async () => {+ writeFileSync(registryFile, JSON.stringify(LEGACY));+ const { loadMediaModels } = await import('./mediaModels.js');+ loadMediaModels();+ const onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));+ // Exactly one spelling survives — two would let a hand-edit land on the+ // copy nothing reads.+ expect(Object.keys(onDisk.video).sort()).toEqual(['cuda', 'defaultCuda', 'defaultMlx', 'mlx']);+ expect(onDisk.video.mlx.map((m) => m.id)).toEqual([MLX_ONLY.id]);+ expect(onDisk.video.cuda.map((m) => m.id)).toEqual([CUDA_ONLY.id]);+ expect(onDisk.video.defaultMlx).toBe(MLX_ONLY.id);+ expect(onDisk.video.defaultCuda).toBe(CUDA_ONLY.id);+ expect(Object.keys(onDisk._shippedDefaults.video).sort()).toEqual(['cuda', 'mlx']);+ });++ it('hides an entry whose legacy per-bucket `broken` flag names the active bucket', async () => {+ writeFileSync(registryFile, JSON.stringify({+ ...LEGACY,+ video: { ...LEGACY.video, windows: [{ ...CUDA_ONLY, broken: 'windows' }] },+ }));+ asPlatform('linux');+ const { getVideoModels } = await import('./mediaModels.js');+ expect(getVideoModels()).toEqual([]);+ });++ // The warning tells the user which key to edit, so it has to quote the+ // spelling THEIR file uses — and the two halves can legitimately disagree+ // (migration 242 writes a canonical snapshot onto a legacy-keyed video).+ it('names the on-disk key each half of a mixed-spelling registry actually uses', async () => {+ const driftedId = seed.video.mlx[0].id;+ writeFileSync(registryFile, JSON.stringify({+ ...LEGACY,+ video: { ...LEGACY.video, macos: [MLX_ONLY] },+ _shippedDefaults: { video: { mlx: [...shippedMlx, driftedId], windows: shippedCuda }, image: { list: shippedImage } },+ }));+ asPlatform('darwin');+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});+ const { loadMediaModels } = await import('./mediaModels.js');+ loadMediaModels();+ const drift = logSpy.mock.calls.map((args) => args.join(' '))+ .filter((line) => line.includes('media-models drift') && line.includes(driftedId));+ logSpy.mockRestore();+ expect(drift).toHaveLength(1);+ expect(drift[0]).toContain('missing from video.macos[]');+ expect(drift[0]).toContain('delete _shippedDefaults.video.mlx');+ });++ it('adds a user video entry to the bucket this machine actually runs', async () => {+ writeFileSync(registryFile, JSON.stringify(CANONICAL));+ asPlatform('linux');+ const { addUserModelEntry, loadMediaModels } = await import('./mediaModels.js');+ addUserModelEntry({ id: 'user-cuda', name: 'User', repo: 'example/user', source: 'user' }, { kind: 'video' });+ const reg = loadMediaModels();+ expect(reg.video.cuda.map((m) => m.id)).toContain('user-cuda');+ expect(reg.video.mlx.map((m) => m.id)).not.toContain('user-cuda');+ });+});diff --git a/server/services/videoGen/runtimes.js b/server/services/videoGen/runtimes.jsindex b4235d0763..5bd6d1caa8 100644--- a/server/services/videoGen/runtimes.js+++ b/server/services/videoGen/runtimes.js@@ -60,13 +60,11 @@ export const MINIMAX_H3_ENCODER_SHIM_DIR = join(homedir(), '.portos', 'minimax-h// pinned source checkout, so this runtime is a plain pip venv with no revision// to verify and no source package to keep clean.//-// SHIPPED FOR WINDOWS. The venv itself is not win32-specific (which is why the-// interpreter is resolved by venv layout below rather than assumed), but the-// model catalog's platform axis is a macOS/Windows binary —-// `getVideoModels()` is `IS_WIN ? video.windows : video.macos` — so a Linux-// install is served the macOS/MLX list and cannot select this runtime's model-// however well the venv provisions. Widening that axis is tracked in #4142;-// until then, do not advertise Linux support here or in the installer.+// SHIPPED FOR WINDOWS AND LINUX. The venv is not win32-specific (which is why+// the interpreter is resolved by venv layout below rather than assumed), and+// since #4142 neither is the catalog: `getVideoModels()` selects `video.cuda`+// on every non-Darwin platform, so a Linux install sees this runtime's model+// row exactly as a Windows one does.export const MINIMAX_H3_CUDA_REPO_DIR = join(homedir(), '.portos', 'minimax-h3-cuda');export const MINIMAX_H3_CUDA_VENV_PYTHON = process.platform === 'win32'? join(MINIMAX_H3_CUDA_REPO_DIR, '.venv', 'Scripts', 'python.exe')