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
refactor: resolve supportedModes for every video model so capability is a registry fact (#3737)
[._.]/ Adam Eivy8331051fe520
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d5ab12861e..be133e665e 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -255,3 +255,5 @@- **[issue-3730] Un-blocking a paused CoS task from the Tasks tab now resumes it on the worktree its paused run left behind, instead of starting clean.** Releasing a pause takes two things, and only one of them had moved out of the Resume dialog: the bookkeeping is now dropped by the task itself whichever path un-blocks it, but the *pointer* at the branch and worktree the paused run left on disk was still resolved inside Resume. So clicking the blocked-status icon on a paused task — or any of the five dispatch paths that revive a blocked twin (on-demand Run, pipeline advance, a Creative Director re-trigger, a manual job trigger, voice dispatch) — put the task back in the queue with nothing pointing at that work, and the next agent started from a clean checkout and redid it. The pointer is now resolved by the same transition that clears the pause, so every door resumes in place; it is resolved *before* the task becomes queueable, so no spawn can grab the task in the moment between un-blocking it and pointing it. The paused agent card is also retired the instant its task starts running again rather than waiting for the next background sweep to notice, and a pointer that can't be resolved (the branch merged, the worktree is gone) still un-blocks the task and simply starts clean, as every other resume path does.- **[issue-3736] The per-runtime video mode gates now resolve through one contract.** `wan22` and `minimax_h3` each carried a near-copy of the same five-step mode gate — resolve the requested mode, check it against the model's `supportedModes`, forbid a conditioning image in text mode, require a source in image mode — restated at *both* the route boundary (`prepareParams.js`) and the render boundary (`local.js`), four copies in all. They had already drifted: wan22 had no first/last-frame rules at all, and identical request shapes returned differently-worded errors depending on which copy caught them. Every one of those gates now calls `videoModeContractError` in `server/services/videoGen/modeContract.js`, a single `supportedModes`-driven rule table with a per-runtime row supplying only its error-code prefix and its wording; adding a runtime is now a row, not another forty lines across two files, and the module records that as a hard rule. No API change — `WAN22_*`, `MINIMAX_H3_*` and `VIDEO_CHAIN_REQUIRES_IMAGE_MODE` all keep their codes and messages, and the existing route and service suites pass unmodified. One drift closes as a side effect: an H3 request naming a gallery image that no longer resolves is now rejected at the route with `MINIMAX_H3_I2V_REQUIRES_IMAGE`, the way the wan22 lane always was, instead of being enqueued and failing later in the worker.++- **[issue-3737] Every video model now carries a resolved `supportedModes`, so capability is a registry fact instead of a hardcoded runtime list.** "Which modes does this model actually support?" had no single answer: `wan22` and `minimax_h3` entries declared `supportedModes`, `mlx_video` and `ltx2` declared nothing, and `hunyuan` carried a legacy `mode: 't2v'` field no reader ever consulted. The client's model picker read "declares nothing" as "supports everything" — so it offered FFLF on runtimes whose helper takes a single `--image` and silently drops the other keyframe, a UI claiming a capability the render path doesn't honor. `server/lib/videoModeProfiles.js` now states each runtime's modes once, as facts about its helper's argv (`mlx_video`/`ltx2` text+image+fflf+extend, `wan22` text+image, `minimax_h3` text+image+fflf — also the mode ceiling `modeContract.js` enforces, so the two can't drift — `hunyuan` text only, replacing the retired `mode: 't2v'`), and `getVideoModels()` resolves it on read — the way `listVideoModels()` already decorates `lastFrameAnchored` — so it covers the load path, the user-model mutators that bypass the load-time normalizer, and peer-synced entries in one place. Deriving on read rather than backfilling into the file (as the sibling `disclosure` / `finishModelId` facts do) is deliberate: a persisted copy reads back as a *declared* list, which is exactly what no later correction to the table could reach. An entry that declares its own list always wins, and there is no migration. `isModelAllowedForMode` lost its "no `supportedModes` ⇒ allow everything" fallback as a result. mlx_video's FFLF is declared *honestly rather than absent* — the mode does run, and the caveat rides on the existing `lastFrameAnchored: false` the client renders as "last frame is advisory". The server-side gate reads the same resolver, so `videoChainUnsupportedError` no longer waves an unresolved entry through as unconstrained while the picker hides it, and the client's two hand-rolled "can this model chain?" copies now ask `isModelAllowedForMode` instead of re-reading the field. An unknown runtime — a user-added model, or one synced from a newer peer — keeps the full base mode set rather than vanishing from every picker.diff --git a/client/src/components/videoGen/AdvancedParamsPanel.jsx b/client/src/components/videoGen/AdvancedParamsPanel.jsxindex 4480e6d2d1..63a4f6c15a 100644--- a/client/src/components/videoGen/AdvancedParamsPanel.jsx+++ b/client/src/components/videoGen/AdvancedParamsPanel.jsx@@ -48,9 +48,9 @@ export default function AdvancedParamsPanel({// and the audio flags don't apply there.const showAudioFlags = mode !== 'a2v';const showModelAudioControls = showAudioFlags && supportsVideoAudioControls(currentModel);- const showChunks = mode !== 'a2v'- && (!Array.isArray(currentModel?.supportedModes)- || currentModel.supportedModes.includes('image'));+ // Chunk chaining seeds chunk N+1 from chunk N's last frame, so it needs i2v —+ // the same predicate the picker uses, not a second reading of supportedModes.+ const showChunks = mode !== 'a2v' && isModelAllowedForMode(currentModel, 'image');// ltx2 extend conditions on the source's latent rather than a single frame,// so image strength is meaningless for it.const showImageStrength = mode === 'image' || (mode === 'extend' && currentModel?.runtime !== 'ltx2');diff --git a/client/src/components/videoGen/AdvancedParamsPanel.test.jsx b/client/src/components/videoGen/AdvancedParamsPanel.test.jsxindex ad6943d69f..e752478c40 100644--- a/client/src/components/videoGen/AdvancedParamsPanel.test.jsx+++ b/client/src/components/videoGen/AdvancedParamsPanel.test.jsx@@ -2,9 +2,13 @@ import { describe, it, expect, vi } from 'vitest';import { render, screen, fireEvent } from '@testing-library/react';import AdvancedParamsPanel from './AdvancedParamsPanel';+// Every model reaching the client carries a server-resolved `supportedModes`+// (server/lib/videoModeProfiles.js, #3737) — fixtures carry it as payloads do.+const MLX_MODES = ['text', 'image', 'fflf', 'extend'];+const baseProps = {mode: 'text',- currentModel: { steps: 30, guidance: 3.0 },+ currentModel: { steps: 30, guidance: 3.0, runtime: 'mlx_video', supportedModes: MLX_MODES },numFrames: 121, onNumFramesChange: vi.fn(),chunks: 1, onChunksChange: vi.fn(), keyframesActive: false,chunkPrompts: [], onChunkPromptChange: vi.fn(), chainingActive: false,@@ -126,12 +130,12 @@ describe('AdvancedParamsPanel', () => {});it('hides image strength for an ltx2 extend render', () => {- const { unmount } = renderPanel({ mode: 'extend', currentModel: { runtime: 'ltx2' } });+ const { unmount } = renderPanel({ mode: 'extend', currentModel: { runtime: 'ltx2', supportedModes: MLX_MODES } });fireEvent.click(toggle());expect(screen.queryByLabelText('Image Strength')).toBeNull();unmount();- renderPanel({ mode: 'extend', currentModel: { runtime: 'mlx_video' } });+ renderPanel({ mode: 'extend', currentModel: { runtime: 'mlx_video', supportedModes: MLX_MODES } });fireEvent.click(toggle());expect(screen.getByLabelText('Image Strength')).toBeTruthy();});@@ -159,7 +163,7 @@ describe('AdvancedParamsPanel', () => {});it('keeps the long-render Extend guidance for models that support Extend', () => {- renderPanel({ numFrames: 313, currentModel: { runtime: 'ltx2' } });+ renderPanel({ numFrames: 313, currentModel: { runtime: 'ltx2', supportedModes: MLX_MODES } });fireEvent.click(toggle());expect(screen.getByText(/Past 241 frames/i)).toBeInTheDocument();});diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.jsindex c5a5616483..3476e1f8df 100644--- a/client/src/hooks/useVideoGenForm.js+++ b/client/src/hooks/useVideoGenForm.js@@ -972,8 +972,10 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })|| currentModel?.runtime !== 'ltx2'|| !!icResolutionIssue(icSpec, width, height));- const modelSupportsChaining = !Array.isArray(currentModel?.supportedModes)- || currentModel.supportedModes.includes('image');+ // Chaining seeds each chunk from the previous one's last frame, so it needs+ // i2v — asked through the shared predicate so the picker, this gate and the+ // server's videoChainUnsupportedError can't answer differently.+ const modelSupportsChaining = isModelAllowedForMode(currentModel, 'image');// The single predicate for "this request really chains" — keyframes, IC// references and a2v each anchor a SINGLE clip, so the route pins them to one// chunk (KEYFRAMES_CHUNKS_CONFLICT / IC_LORA_CHUNKS_CONFLICT). Derived once sodiff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsxindex 2c8be37c30..0023f2150e 100644--- a/client/src/hooks/useVideoGenForm.test.jsx+++ b/client/src/hooks/useVideoGenForm.test.jsx@@ -15,8 +15,12 @@ const { useVideoGenForm } = await import('./useVideoGenForm.js');// legacy path that extends from an extracted last frame.// `lastFrameAnchored` is server-decorated onto every model by listVideoModels()// (from LAST_FRAME_ANCHORED_RUNTIMES) — fixtures carry it as the payload does.-const LTX2 = { id: 'ltx2-model', name: 'LTX-2.3', runtime: 'ltx2', lastFrameAnchored: true };-const MLX = { id: 'mlx-model', name: 'LTX distilled', runtime: 'mlx_video', lastFrameAnchored: false };+// `supportedModes` likewise: the registry resolves it for EVERY entry at load+// (server/lib/videoModeProfiles.js, #3737), so a model that reaches the client+// without one is not a shape the picker has to handle.+const RUNTIME_MODES = ['text', 'image', 'fflf', 'extend'];+const LTX2 = { id: 'ltx2-model', name: 'LTX-2.3', runtime: 'ltx2', lastFrameAnchored: true, supportedModes: RUNTIME_MODES };+const MLX = { id: 'mlx-model', name: 'LTX distilled', runtime: 'mlx_video', lastFrameAnchored: false, supportedModes: RUNTIME_MODES };const WAN_T2V = { id: 'wan-t2v', name: 'Wan T2V', runtime: 'wan22', supportedModes: ['text'], frameStride: 4 };const WAN_TI2V = { id: 'wan-ti2v', name: 'Wan TI2V', runtime: 'wan22', supportedModes: ['text', 'image'], frameStride: 4 };const H3 = {diff --git a/client/src/lib/videoGenParams.js b/client/src/lib/videoGenParams.jsindex 8529242491..88843bef2a 100644--- a/client/src/lib/videoGenParams.js+++ b/client/src/lib/videoGenParams.js@@ -164,17 +164,16 @@ export const icResolutionIssue = (spec, width, height) => {return `${spec.label} mode needs a resolution divisible by ${scale} (its reference encoder downscales by ${scale}); got ${width}×${height}.`;};-// Mode-compatibility predicate for the Model dropdown. a2v and the IC-LoRA-// remix modes require the ltx2 runtime (dgrauet's pipeline) — the legacy-// mlx_video pipeline has no audio-conditioned mode and no IC pipeline, and-// Wan/Hunyuan don't either. Server enforces the same rules in-// routes/videoGen.js (A2V_REQUIRES_LTX2 / IC_LORA_REQUIRES_LTX2); filtering-// client-side keeps the dropdown honest so the user can't pick a doomed model.+// The one mode-compatibility predicate — used by the Model dropdown and by+// every "can this model do i2v?" gate on the page. a2v and the IC-LoRA remix+// modes stay runtime-gated because they're ltx2 pipeline capabilities rather+// than per-entry facts (the remix ids come from the IC-LoRA weight registry);+// the server enforces the same rules in routes/videoGen.js (A2V_REQUIRES_LTX2 /+// IC_LORA_REQUIRES_LTX2). Every other mode is answered by `supportedModes`,+// which the server resolves for EVERY entry (server/lib/videoModeProfiles.js,+// #3737), so an absent list means the payload didn't come from the registry.export const isModelAllowedForMode = (model, mode) => {if (!model) return false;if (mode === 'a2v' || isIcLoraMode(mode)) return model.runtime === 'ltx2';- if (Array.isArray(model.supportedModes) && model.supportedModes.length > 0) {- return Array.isArray(model.supportedModes) && model.supportedModes.includes(mode);- }- return true;+ return Array.isArray(model.supportedModes) && model.supportedModes.includes(mode);};diff --git a/client/src/lib/videoGenParams.test.js b/client/src/lib/videoGenParams.test.jsindex d9b5b1b6a0..d604f5fd6d 100644--- a/client/src/lib/videoGenParams.test.js+++ b/client/src/lib/videoGenParams.test.js@@ -51,9 +51,20 @@ describe('isModelAllowedForMode', () => {it('rejects a null model', () => {expect(isModelAllowedForMode(null, 'text')).toBe(false);});- it('allows general runtimes for non-a2v modes', () => {- expect(isModelAllowedForMode({ runtime: 'mlx_video' }, 'text')).toBe(true);- expect(isModelAllowedForMode({ runtime: 'ltx2' }, 'image')).toBe(true);+ it('allows general runtimes for the modes their entry resolves', () => {+ // The server resolves supportedModes onto EVERY entry at load+ // (server/lib/videoModeProfiles.js) — these are the mlx_video / ltx2 rows.+ const mlx = { runtime: 'mlx_video', supportedModes: ['text', 'image', 'fflf', 'extend'] };+ const ltx2 = { runtime: 'ltx2', supportedModes: ['text', 'image', 'fflf', 'extend'] };+ expect(isModelAllowedForMode(mlx, 'text')).toBe(true);+ expect(isModelAllowedForMode(ltx2, 'image')).toBe(true);+ });+ it('rejects every mode for a model that resolved no supportedModes (#3737)', () => {+ // "Declares nothing" used to mean "supports everything", which offered FFLF+ // on runtimes that silently drop the second keyframe. Post-backfill an+ // absent list can only mean a payload that never came from the registry.+ expect(isModelAllowedForMode({ runtime: 'mlx_video' }, 'text')).toBe(false);+ expect(isModelAllowedForMode({ runtime: 'mlx_video', supportedModes: [] }, 'text')).toBe(false);});it('filters Wan models by their declared text/image capabilities', () => {const ti2v = { runtime: 'wan22', supportedModes: ['text', 'image'] };diff --git a/data.reference/media-models.json b/data.reference/media-models.jsonindex 2cb6916433..95a3f2e11a 100644--- a/data.reference/media-models.json+++ b/data.reference/media-models.json@@ -419,7 +419,6 @@"name": "HunyuanVideo (13B — fp32-only on MPS, ~4-8 hr per render)","repo": "tencent/HunyuanVideo","runtime": "hunyuan",- "mode": "t2v","steps": 30,"guidance": 6,"precision": "fp32",diff --git a/server/lib/README.md b/server/lib/README.mdindex 907ebed1ec..6cdd6f11e5 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -111,6 +111,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `mediaModels.js` | Single source of truth for image/video model metadata. || `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. || `videoFinishProfiles.js` | Draft → delivery ("Finish") relationships between video models (#3696). `VIDEO_FINISH_PROFILES` declares each fast draft entry id → `{ shippedRepo, finishModelId }`, only for pairs that share a runtime, base repo and supported modes (the same weights at a different step budget), so re-rendering the draft's seed reproduces its composition instead of re-rolling it. `applyVideoFinishProfiles(list)` is the load-time backfill (twin of migration 238) with the usual preservation guards (existing key wins, custom id skipped, forked `repo` skipped); `validateFinishProfileGraph(list)` returns the graph problems (missing / self-referencing / chained target, runtime / repo / supportedModes mismatch) and `sanitizeFinishProfiles(list)` warns + strips them at load so a typo can never surface a Finish button targeting nothing. `finishTargetForModel(model, availableModels)` resolves the delivery entry scoped to what this install can run. |+| `videoModeProfiles.js` | The shipped `supportedModes` fact per video runtime (#3737), so "which modes does this model support?" has one answer on the registry entry instead of 25+ `runtime === '…'` comparisons. `VIDEO_RUNTIME_MODES` maps each runtime to the base semantic modes its helper's argv can actually render (`mlx_video`/`ltx2` text+image+fflf+extend, `wan22` text+image, `minimax_h3` text+image+fflf — also the mode ceiling in `videoGen/modeContract.js` — `hunyuan` text only, replacing the legacy unread `mode: 't2v'` field); `VIDEO_BASE_MODES` is the fallback for an unknown (user-added or peer-synced) runtime, deliberately the full base set so a custom model doesn't vanish from every picker. `resolveVideoSupportedModes(entry)` (declared non-empty list always wins) and `applyVideoSupportedModes(list)` — the read-time decoration `mediaModels.js#getVideoModels` applies, so the derived list never lands in `data/media-models.json` where it would read back as a *declared* list no later correction could reach. a2v and the IC-LoRA remix ids are NOT enumerated here: they're ltx2 pipeline capabilities, gated by runtime (`A2V_REQUIRES_LTX2` / `IC_LORA_REQUIRES_LTX2`). || `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT` / `KIMI_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`) plus reasoning-effort helpers for the claude/codex/agy CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort` — clamps an out-of-range effort to the nearest level the target CLI accepts rather than dropping it, so a value saved against a wider ladder survives a provider switch — `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) plus codex startup-arg helpers (`CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal). || `providerVendors.js` | `PROVIDER_VENDORS` — one row per coding-agent CLI/TUI vendor (claude/codex/antigravity/opencode/grok/kimi/cursor, plus a deliberately-incomplete legacy `gemini-cli` row), consumed by every dispatch site that used to hand-roll its own vendor if-chain across ~8 branches in 5 files (#3618): `applyCommandDefaults`/`prepareCliPrompt` (re-exported from `tuiHandshake.js`/`cliProviderArgs.js`), `buildVendorCliArgs`/`buildVendorSpawnConfig` (consumed by `cliProviderArgs.js#buildCliArgs` / `agentCliSpawning.js#buildCliSpawnConfig`), `inferTuiCommand` (re-exported from `tuiHandshake.js`), and `injectTuiModelAndEffort` — the shared antigravity-validates-the-pair-vs-everyone-else `--model`/`--effort` injection used by both `tuiHandshake.js#buildTuiInvocation` and `agentTuiSpawning.js#buildTuiSpawnConfig`, replacing a second copy of that split that had already drifted once before this file existed. Doesn't rewrite any vendor's argv-building logic — that stays in `antigravity.js`/`grok.js`/`kimi.js`/`cursor.js`/`codex.js`. Dependency-light on purpose, mirroring those files. || `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier; also derives `cacheReadPer1M`/`cacheWritePer1M` from the input rate via per-family multipliers), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd(tokensIn, tokensOut, rates, cache?)` — `tokensIn` is UNCACHED input; cache tiers are priced separately via the optional 4th arg — and `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); still excludes batch/long-context tiers. |diff --git a/server/lib/index.js b/server/lib/index.jsindex e96b13b2d1..df964aa8c5 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -112,6 +112,7 @@ export * from './kimi.js';export * from './mediaModels.js';export * from './videoDisclosure.js';export * from './videoFinishProfiles.js';+export * from './videoModeProfiles.js';export * from './promptPartials.js';export * from './promptRunner.js';export * from './promptSystemStages.js';diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.jsindex 312e853140..b12c7b9d92 100644--- a/server/lib/mediaModels.js+++ b/server/lib/mediaModels.js@@ -19,6 +19,10 @@* `finishModelId` (optional, issue #3696) names the delivery model a* fast draft entry finishes into — declared in lib/videoFinishProfiles.js,* backfilled at load, and validated (invalid edges are dropped, loudly).+ * `supportedModes` (issue #3737) is resolved for EVERY entry by+ * 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* - image[]: { id, name, steps, guidance, broken? }* - textEncoders[]: { id, label, repo, localPath? }@@ -33,6 +37,7 @@ import { RUNNER_FAMILIES } from './runners.js';import { ServerError } from './errorHandler.js';import { applyVideoDisclosures } from './videoDisclosure.js';import { applyVideoFinishProfiles, sanitizeFinishProfiles } from './videoFinishProfiles.js';+import { applyVideoSupportedModes } from './videoModeProfiles.js';// fileUtils.ensureDir is async/Promise-returning; this module needs a// synchronous version because `loadMediaModels()` is called at import-time// from videoGen/imageGen modules, which can't await before exporting.@@ -259,7 +264,6 @@ const DEFAULT_REGISTRY = {name: 'HunyuanVideo (13B — fp32-only on MPS, ~4-8 hr per render)',repo: 'tencent/HunyuanVideo',runtime: 'hunyuan',- mode: 't2v',steps: 30,guidance: 6.0,precision: 'fp32',@@ -1023,10 +1027,15 @@ export const removeUserModelEntry = (id) => {const platformBroken = (broken) =>broken === true || (typeof broken === 'string' && broken === (IS_WIN ? 'windows' : 'macos'));+// `supportedModes` is resolved HERE rather than in normalizeRegistry (#3737):+// deriving on read covers the load path, the user-model mutators (which bypass+// normalizeRegistry) and peer-synced entries in one place, and keeps the derived+// list out of data/media-models.json — a persisted copy would read back as a+// *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 || []);- return list.filter((m) => !platformBroken(m.broken));+ return applyVideoSupportedModes(list.filter((m) => !platformBroken(m.broken)));};export const getDefaultVideoModelId = () => {diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.jsindex 34ff4b32ce..f14996e685 100644--- a/server/lib/mediaModels.test.js+++ b/server/lib/mediaModels.test.js@@ -107,6 +107,67 @@ describe('mediaModels registry', () => {expect(h3.termsGate.id).toBe('minimax-h3-community-license-2026-08-02');});+ // #3737: capability has to be answerable off the entry, or every consumer+ // re-derives it from `runtime` string comparisons and the two ends drift.+ describe('supportedModes resolution (#3737)', () => {+ it('resolves supportedModes for every entry this platform can run', async () => {+ const { getVideoModels } = await import('./mediaModels.js');+ for (const entry of getVideoModels()) {+ expect(Array.isArray(entry.supportedModes), entry.id).toBe(true);+ expect(entry.supportedModes.length, entry.id).toBeGreaterThan(0);+ }+ });++ it('ships a runtime table row for every runtime in the seed, on both platforms', async () => {+ 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]) {+ 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();+ const hunyuan = getVideoModels().find((m) => m.id === 'hunyuan_video');+ // Windows ships no hunyuan entry, so only assert where it's runnable.+ if (hunyuan) expect(hunyuan.supportedModes).toEqual(['text']);+ });++ it('is derived on read — never persisted back into the registry file', async () => {+ const { loadMediaModels, getVideoModels } = await import('./mediaModels.js');+ loadMediaModels();+ expect(getVideoModels().every((m) => Array.isArray(m.supportedModes))).toBe(true);+ // 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]+ .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';+ writeFileSync(registryFile, JSON.stringify({+ video: {+ macos: [], windows: [], defaultMacos: 'custom-narrow', defaultWindows: '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' },+ ],+ },+ // 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'] } },+ }));+ const { getVideoModels } = await import('./mediaModels.js');+ const byId = new Map(getVideoModels().map((m) => [m.id, m]));+ expect(byId.get('custom-narrow').supportedModes).toEqual(['text']);+ expect(byId.get('custom-bare').supportedModes).toEqual(['text', 'image', 'fflf', 'extend']);+ });+ });+it('hides models with broken === current platform', async () => {const here = process.platform === 'win32' ? 'windows' : 'macos';const elsewhere = process.platform === 'win32' ? 'macos' : 'windows';@@ -828,6 +889,12 @@ describe('user model entry mutators (#2124)', () => {const onDisk = JSON.parse(readFileSync(registryFile, 'utf-8'));const inList = [...onDisk.video.macos, ...onDisk.video.windows].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+ // picker (which no longer reads "absent" as "everything") hides it in every+ // mode until the next restart.+ expect(getVideoModels().find((m) => m.id === 'hf-test-video').supportedModes)+ .toEqual(['text', 'image', 'fflf', 'extend']);});it('adds a user image entry', async () => {diff --git a/server/lib/videoModeProfiles.js b/server/lib/videoModeProfiles.jsnew file mode 100644index 0000000000..f5a9e56afe--- /dev/null+++ b/server/lib/videoModeProfiles.js@@ -0,0 +1,82 @@+/**+ * Video mode capability — the shipped `supportedModes` fact per video runtime+ * (issue #3737), so "which modes does this model support?" is answered by the+ * registry entry rather than re-derived from `runtime` comparisons at 25+ sites.+ *+ * `applyVideoSupportedModes` is a read-time decoration, not a stored field:+ * `getVideoModels()` runs it over the platform list the same way+ * `listVideoModels()` decorates `lastFrameAnchored`. Deriving on read (rather+ * than in `normalizeRegistry`, alongside the `disclosure` / `finishModelId`+ * backfills) keeps it out of `data/media-models.json` — a persisted copy would+ * become a "declared" list that no later correction to the table below could+ * reach, on every install that ever added a model.+ *+ * Careful: `mode` here is the t2v/i2v *semantic*, not the local/grok render+ * backend `videoGen/modes.js` enumerates.+ */++// The base semantic modes a registry entry can enumerate, and the fallback for+// an unknown (user-added, or peer-synced from a newer build) runtime: we can't+// narrow it, and narrowing to text-only would drop a user's own model out of+// every picker.+//+// `a2v` and the IC-LoRA remix ids are deliberately absent: they're ltx2+// *pipeline* capabilities, gated by runtime at both boundaries+// (A2V_REQUIRES_LTX2 / IC_LORA_REQUIRES_LTX2), and the remix ids are enumerated+// from the IC-LoRA weight registry rather than per model entry.+export const VIDEO_BASE_MODES = Object.freeze(['text', 'image', 'fflf', 'extend']);++/**+ * Modes each shipped runtime can render, as facts about its helper's argv:+ *+ * - `mlx_video` — `mlx_video.generate_av` takes a single `--image` plus an+ * `--image-frame-idx`, so text / image / extend (last-frame → i2v) all run.+ * FFLF is offered but *degraded*: the helper conditions on one frame and+ * drops the other. That caveat rides on `lastFrameAnchored: false`+ * (videoGen/runtimes.js), which the client renders as "last frame is+ * advisory" — the honest shape is "the mode runs", not "the mode is absent".+ * - `ltx2` — dgrauet's KeyframeInterpolationPipeline anchors both frames and+ * has a native ExtendPipeline.+ * - `wan22` — MLX-Gen's Wan CLI is t2v or i2v depending on the checkpoint, so+ * each shipped profile narrows this itself; the pair is the widest any Wan+ * checkpoint reaches (no keyframe interpolation, no extend).+ * - `minimax_h3` — fl2va conditioning anchored at the first / last latent+ * frame: 'image' anchors one, 'fflf' anchors both. Doubles as the mode+ * ceiling in videoGen/modeContract.js.+ * - `hunyuan` — the MLX port's `hyvideo.inference` helper takes a prompt and+ * nothing else (see buildHunyuanArgs); text-to-video only. This replaces the+ * legacy `mode: 't2v'` field, which no reader ever consulted.+ */+export const VIDEO_RUNTIME_MODES = Object.freeze({+ mlx_video: Object.freeze(['text', 'image', 'fflf', 'extend']),+ ltx2: Object.freeze(['text', 'image', 'fflf', 'extend']),+ wan22: Object.freeze(['text', 'image']),+ minimax_h3: Object.freeze(['text', 'image', 'fflf']),+ hunyuan: Object.freeze(['text']),+});++/**+ * The modes one entry supports. A declared non-empty array always wins — a+ * hand-edited or peer-synced registry is the authority on its own entries. An+ * absent, non-array or empty list is "not declared", not "supports nothing":+ * an empty list would strand the entry in every picker with no way back.+ */+export const resolveVideoSupportedModes = (entry) => {+ const declared = entry?.supportedModes;+ if (Array.isArray(declared) && declared.length > 0) return declared;+ return VIDEO_RUNTIME_MODES[entry?.runtime] || VIDEO_BASE_MODES;+};++/**+ * Decorate every entry in one platform's video list with a resolved+ * `supportedModes`. Pure; never mutates the inputs, and hands out a copy rather+ * than the frozen shared table so a caller can't freeze-error on it.+ */+export const applyVideoSupportedModes = (list) => {+ if (!Array.isArray(list)) return list;+ return list.map((entry) => {+ if (!entry || typeof entry !== 'object') return entry;+ if (Array.isArray(entry.supportedModes) && entry.supportedModes.length > 0) return entry;+ return { ...entry, supportedModes: [...resolveVideoSupportedModes(entry)] };+ });+};diff --git a/server/lib/videoModeProfiles.test.js b/server/lib/videoModeProfiles.test.jsnew file mode 100644index 0000000000..5e76a5a515--- /dev/null+++ b/server/lib/videoModeProfiles.test.js@@ -0,0 +1,73 @@+import { describe, it, expect } from 'vitest';+import {+ VIDEO_BASE_MODES,+ VIDEO_RUNTIME_MODES,+ resolveVideoSupportedModes,+ applyVideoSupportedModes,+} from './videoModeProfiles.js';++describe('VIDEO_RUNTIME_MODES', () => {+ it('only enumerates base semantic modes', () => {+ for (const [runtime, modes] of Object.entries(VIDEO_RUNTIME_MODES)) {+ expect(modes.length, runtime).toBeGreaterThan(0);+ for (const mode of modes) expect(VIDEO_BASE_MODES, `${runtime}/${mode}`).toContain(mode);+ }+ });++ it('keeps hunyuan text-only (the retired `mode: t2v` fact)', () => {+ expect(VIDEO_RUNTIME_MODES.hunyuan).toEqual(['text']);+ });++ it('declares fflf on every runtime that can be handed a last frame', () => {+ // mlx_video's FFLF is degraded (one --image), NOT absent — the caveat rides+ // on lastFrameAnchored: false, so the mode still has to be offerable.+ expect(VIDEO_RUNTIME_MODES.mlx_video).toContain('fflf');+ expect(VIDEO_RUNTIME_MODES.ltx2).toContain('fflf');+ expect(VIDEO_RUNTIME_MODES.minimax_h3).toContain('fflf');+ expect(VIDEO_RUNTIME_MODES.wan22).not.toContain('fflf');+ });+});++describe('resolveVideoSupportedModes', () => {+ it('prefers a declared non-empty list over the runtime table', () => {+ expect(resolveVideoSupportedModes({ runtime: 'mlx_video', supportedModes: ['text'] })).toEqual(['text']);+ });++ it('treats an absent, non-array or empty list as "not declared"', () => {+ for (const supportedModes of [undefined, null, [], 'text']) {+ expect(resolveVideoSupportedModes({ runtime: 'hunyuan', supportedModes })).toEqual(['text']);+ }+ });++ it('falls back to the full base set for an unknown runtime', () => {+ expect(resolveVideoSupportedModes({ runtime: 'some-future-runtime' })).toEqual(VIDEO_BASE_MODES);+ expect(resolveVideoSupportedModes({})).toEqual(VIDEO_BASE_MODES);+ });+});++describe('applyVideoSupportedModes', () => {+ it('resolves a list for every entry without mutating the inputs', () => {+ const entries = [+ { id: 'a', runtime: 'hunyuan' },+ { id: 'b', runtime: 'wan22', supportedModes: ['image'] },+ { id: 'c', runtime: 'ltx2' },+ ];+ const out = applyVideoSupportedModes(entries);+ expect(out.map((e) => e.supportedModes)).toEqual([+ ['text'],+ ['image'],+ ['text', 'image', 'fflf', 'extend'],+ ]);+ expect(entries[0].supportedModes).toBeUndefined();+ });++ it('hands back a copy, never the frozen shared table', () => {+ const [entry] = applyVideoSupportedModes([{ id: 'a', runtime: 'hunyuan' }]);+ expect(entry.supportedModes).not.toBe(VIDEO_RUNTIME_MODES.hunyuan);+ });++ it('passes through non-entries and a non-array list', () => {+ expect(applyVideoSupportedModes(null)).toBeNull();+ expect(applyVideoSupportedModes([null, 'nope'])).toEqual([null, 'nope']);+ });+});diff --git a/server/services/videoGen/modeContract.js b/server/services/videoGen/modeContract.jsindex 5109d135de..c3cfda4771 100644--- a/server/services/videoGen/modeContract.js+++ b/server/services/videoGen/modeContract.js@@ -13,7 +13,8 @@* and each caller decides only what to do first: the route unlinks its staged* uploads, the render path just throws.*- * Dependency-free apart from the error leaf, which keeps it importable from+ * Dependency-free apart from the error leaf and the registry's pure per-runtime+ * mode table (`lib/videoModeProfiles.js`), which keeps it importable from* `prepareParams.js` without dragging in `local.js` — the module suites mock* `local.js` wholesale, and a mocked rule table is no rule table at all.*@@ -34,12 +35,15 @@*/import { ServerError } from '../../lib/errorHandler.js';+import { VIDEO_RUNTIME_MODES, resolveVideoSupportedModes } from '../../lib/videoModeProfiles.js';// H3's fl2va path conditions on up to two keyframes anchored at the first and// last latent frame — so text, image (first only) and FFLF (first + last) all// run, while extend / a2v / IC-remix and the ltx2 multi-keyframe array (which// pins arbitrary frame indices H3 has no anchor for) still have no equivalent.-export const MINIMAX_H3_MODES = Object.freeze(['text', 'image', 'fflf']);+// Re-exported from the registry's per-runtime table (#3737) so the ceiling and+// the backfilled `supportedModes` can't drift into two different answers.+export const MINIMAX_H3_MODES = VIDEO_RUNTIME_MODES.minimax_h3;// Message defaults, used for any rule a runtime row doesn't phrase itself. Each// takes `{ model, requestedMode, allowedModes }` so a new runtime can adopt the@@ -64,9 +68,9 @@ const VIDEO_MODE_CONTRACTS = Object.freeze({wan22: {codePrefix: 'WAN22',chainCode: 'WAN22_CHAIN_REQUIRES_IMAGE_MODE',- // No ceiling: MLX-Gen's Wan CLI takes whatever the profile declares, and an- // entry with no `supportedModes` at all declares nothing — so it renders- // nothing, which is how both wan22 boundaries have always read it.+ // No ceiling: MLX-Gen's Wan CLI takes whatever the profile declares, and+ // resolveVideoSupportedModes narrows an entry that declares nothing to the+ // wan22 row (text + image) rather than leaving it unconstrained.modeCeiling: null,// The wan22 lane rejects multi-keyframe / extend / audio / IC inputs by// runtime elsewhere (KEYFRAMES_REQUIRE_LTX2, A2V_REQUIRES_LTX2,@@ -114,10 +118,11 @@ const isPresent = (value) => (Array.isArray(value) ? value.length > 0 : Boolean(* runtime that declares no row — ltx2, mlx_video and hunyuan gate their modes* through their own helpers).*- * `supportedModes` comes off the registry entry so the picker and the API agree- * even on an install whose `data/media-models.json` was hand-edited or narrowed;- * a row's `modeCeiling` stays the ceiling, because an entry can't declare a mode- * the helper has no arguments for.+ * `supportedModes` comes off the registry entry (resolved from the runtime table+ * when the entry declares none) so the picker and the API agree even on an+ * install whose `data/media-models.json` was hand-edited or narrowed; a row's+ * `modeCeiling` stays the ceiling, because an entry can't declare a mode the+ * helper has no arguments for.** @param {object} opts* @param {object} opts.model - registry entry (`runtime`, `name`, `supportedModes`)@@ -146,10 +151,10 @@ export const videoModeContractError = ({const { codePrefix, modeCeiling, extraConditioningUnsupported } = contract;const messages = { ...DEFAULT_MESSAGES, ...contract.messages };const requestedMode = mode || (hasFirstImage ? 'image' : 'text');- const declaredModes = model?.supportedModes;- const allowedModes = Array.isArray(declaredModes)- ? (modeCeiling ? declaredModes.filter((m) => modeCeiling.includes(m)) : declaredModes)- : (modeCeiling ?? []);+ const declaredModes = resolveVideoSupportedModes(model);+ const allowedModes = modeCeiling+ ? declaredModes.filter((m) => modeCeiling.includes(m))+ : declaredModes;const ctx = { model, requestedMode, allowedModes, sourceResolved };const fail = (key, code) => new ServerError(messages[key](ctx), { status: 400, code });@@ -189,12 +194,13 @@ export const videoModeContractError = ({* needs image-to-video on any runtime. Returns a ServerError for a model that* lacks it, else null.*- * An entry with no declared `supportedModes` is permitted — unset means- * "unconstrained", not "text-only" — and both boundaries must read it that way,- * which is why this is one function rather than a rule re-typed per runtime.+ * An entry that declares no `supportedModes` resolves them from its runtime+ * (lib/videoModeProfiles.js) rather than being waved through as unconstrained,+ * so both boundaries and the client's picker read one answer — which is why this+ * is one function rather than a rule re-typed per runtime.*/export const videoChainUnsupportedError = (model) => {- if (!Array.isArray(model?.supportedModes) || model.supportedModes.includes('image')) return null;+ if (resolveVideoSupportedModes(model).includes('image')) return null;return new ServerError(`${model.name} cannot generate chunks > 1 because continuation requires image-to-video support.`,{diff --git a/server/services/videoGen/modeContract.test.js b/server/services/videoGen/modeContract.test.jsindex ee1fa945b1..d11b903d3d 100644--- a/server/services/videoGen/modeContract.test.js+++ b/server/services/videoGen/modeContract.test.js@@ -40,8 +40,12 @@ describe('videoModeContractError — wan22 codes and messages', () => {expect(err.message).toContain('Example Wan Profile does not support image-to-video');});- it('treats an entry with no declared supportedModes as declaring nothing', () => {- expect(videoModeContractError({ model: wan(undefined), mode: 'text' }))+ // #3737: an entry that declares nothing resolves its runtime's modes rather+ // than declaring nothing — otherwise the server rejects in every mode while+ // the picker (which resolves the same table) offers the model in two.+ it('resolves an entry with no declared supportedModes from its runtime', () => {+ expect(videoModeContractError({ model: wan(undefined), mode: 'text' })).toBeNull();+ expect(videoModeContractError({ model: wan(undefined), mode: 'fflf' })).toMatchObject({ code: 'WAN22_MODE_UNSUPPORTED' });});