Skip to content

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

refactor: resolve the video form's hosted render lane once (#12402)

[._.]/ Adam Eivy732748f3d8a3
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.js
index a1cdedf074..31d59b42fa 100644
--- a/client/src/hooks/useVideoGenForm.js
+++ b/client/src/hooks/useVideoGenForm.js
@@ -645,19 +645,23 @@ export function useVideoGenForm({
// Hoisted above the reference-mode derivation below, which needs it: the grok
// lane reads only prompt/dims/source-image/duration, so its image_to_video
// always anchors and the promise has to collapse to the default there.
- const isGrok = grokEnabled && backend === 'grok';
+ // Each hosted lane stays gated on its own *Enabled flag, so a persisted
+ // backend that is no longer configured resolves to null (the local lane).
+ const hostedLane = ({ grok: grokEnabled, fal: falEnabled, reactor: reactorEnabled, runway: runwayEnabled })[backend]
+ ? backend : null;
+ const isGrok = hostedLane === 'grok';
// fal.ai's queue REST API is usability-gated on a configured API key
// (`falEnabled`, mirrored from the server's isVideoModeUsable check), not a
// toggle — same short-circuit shape as grok: only prompt/dims/source-image
// and a duration reach the provider.
- const isFal = falEnabled && backend === 'fal';
+ const isFal = hostedLane === 'fal';
// reactor.inc fast-h3 is likewise usability-gated on a configured API key
// (`reactorEnabled`) — same short-circuit shape as fal, plus native
// clip-to-clip chaining via continue_from_clip_id.
- const isReactor = reactorEnabled && backend === 'reactor';
+ const isReactor = hostedLane === 'reactor';
// Runway is usability-gated the same way, and renders image-to-video only.
- const isRunway = runwayEnabled && backend === 'runway';
- const referenceModeApplies = mode === 'image' && !isGrok && !isFal && !isReactor && !isRunway;
+ const isRunway = hostedLane === 'runway';
+ const referenceModeApplies = mode === 'image' && !hostedLane;
// The strength the render will actually use, for the slider readout — an
// untouched slider under Inspire still resolves to the contract's low default
// rather than the pipeline's 1.0, and the panel must say so.
@@ -1333,7 +1337,7 @@ export function useVideoGenForm({
// Snapshot the current validated state into a wire payload. The submit flow
// stays pure so all three backend contracts can be tested independently.
const submissionState = {
- isGrok, grokDuration, isFal, falDuration, falModelId, falResolution, falGenerateAudio,
+ hostedLane, isGrok, grokDuration, isFal, falDuration, falModelId, falResolution, falGenerateAudio,
isReactor, reactorClipId, reactorSeconds, reactorSeed, reactorAspect, remoteSubmissionFields,
isRunway, runwayModelId, runwayDuration, runwayResolution,
displaySleepEnabled,
@@ -1352,7 +1356,7 @@ export function useVideoGenForm({
return {
// Backend + mode
- backend, isGrok, isFal, isReactor, isRunway, handleBackendChange,
+ backend, hostedLane, isGrok, isFal, isReactor, isRunway, handleBackendChange,
grokDuration, setGrokDuration,
falDuration, setFalDuration,
falModelId, setFalModelId,
diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsx
index 9d54098aea..701ecb40f3 100644
--- a/client/src/hooks/useVideoGenForm.test.jsx
+++ b/client/src/hooks/useVideoGenForm.test.jsx
@@ -942,6 +942,19 @@ describe('useVideoGenForm', () => {
expect(result.current.modelId).toBe(LTX2.id);
});
+ it('resolves a stored hosted backend whose key is no longer configured to the local lane', async () => {
+ const { result, rerender } = render({ grokEnabled: false });
+ const props = { models: MODELS, modelContext: MODEL_CONTEXT, availableLoras: [], grokEnabled: false };
+ rerender({ ...props, runwayEnabled: true });
+ act(() => result.current.handleBackendChange('runway'));
+ expect(result.current.hostedLane).toBe('runway');
+
+ rerender({ ...props, runwayEnabled: false });
+ expect(result.current.backend).toBe('runway');
+ expect(result.current.hostedLane).toBeNull();
+ expect(result.current.isRunway).toBe(false);
+ });
+
it('applyFinish is inert without a record or a delivery model — it never starts a render', async () => {
const { result } = render();
await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
diff --git a/client/src/hooks/useVideoGenSubmitFlow.test.jsx b/client/src/hooks/useVideoGenSubmitFlow.test.jsx
index 80674f1041..c70102c38a 100644
--- a/client/src/hooks/useVideoGenSubmitFlow.test.jsx
+++ b/client/src/hooks/useVideoGenSubmitFlow.test.jsx
@@ -9,7 +9,7 @@ const submissionState = (prompt) => ({
disableAudio: false,
icModeActive: false,
icReferenceImageFiles: [],
- isGrok: false,
+ hostedLane: null,
keyframes: [],
keyframesActive: false,
mode: 'text',
@@ -60,7 +60,7 @@ it('submits batch size and seed zero only to a capable, unchained local runtime'
const state = { ...submissionState('Example shot'), currentModel: { supportsWarmBatch: true }, batchSize: 3, seed: 0 };
const { result, rerender } = renderHook(({ value }) => useVideoGenSubmitFlow(value), { initialProps: { value: state } });
expect(result.current.buildGeneratePayload()).toMatchObject({ batchSize: 3, seed: 0 });
- for (const overrides of [{ currentModel: {} }, { chainingActive: true, chunks: 2 }, { isGrok: true }, { remoteSubmissionFields: { mediaProviderPeerId: 'peer' } }]) {
+ for (const overrides of [{ currentModel: {} }, { chainingActive: true, chunks: 2 }, { hostedLane: 'grok' }, { remoteSubmissionFields: { mediaProviderPeerId: 'peer' } }]) {
rerender({ value: { ...state, ...overrides } });
expect(result.current.buildGeneratePayload()).not.toHaveProperty('batchSize');
}
diff --git a/client/src/lib/videoGenSubmission.js b/client/src/lib/videoGenSubmission.js
index 080b4523bd..d1b476a69c 100644
--- a/client/src/lib/videoGenSubmission.js
+++ b/client/src/lib/videoGenSubmission.js
@@ -322,9 +322,17 @@ const liveBeats = (chainingActive, chunkPrompts, chunks, withEnvelope) => (
: []
);
+// Keyed by the form's resolved `hostedLane` (null = local or federated).
+const HOSTED_VIDEO_SUBMISSIONS = {
+ grok: grokVideoSubmission,
+ fal: falVideoSubmission,
+ reactor: reactorVideoSubmission,
+ runway: runwayVideoSubmission,
+};
+
export function buildVideoGenSubmission(args) {
const {
- isGrok, isFal, isReactor, isRunway, remoteSubmissionFields,
+ hostedLane, remoteSubmissionFields,
prompt, negativePrompt, stylePreset, selectedUniverse,
currentModel, disableAudio, noMusic, chainingActive, chunks, chunkPrompts,
} = args;
@@ -334,12 +342,9 @@ export function buildVideoGenSubmission(args) {
});
const shared = { ...args, composed };
- const isLocal = !isGrok && !isFal && !isReactor && !isRunway && !remoteSubmissionFields;
+ const isLocal = !hostedLane && !remoteSubmissionFields;
const additions = videoPromptAdditions({ ...args, isLocal });
- const payload = isGrok ? grokVideoSubmission(shared)
- : isFal ? falVideoSubmission(shared)
- : isReactor ? reactorVideoSubmission(shared)
- : isRunway ? runwayVideoSubmission(shared)
+ const payload = hostedLane ? HOSTED_VIDEO_SUBMISSIONS[hostedLane](shared)
: remoteSubmissionFields ? remoteVideoSubmission(shared)
: localVideoSubmission(args, {
composed,
diff --git a/client/src/lib/videoGenSubmission.test.js b/client/src/lib/videoGenSubmission.test.js
index 82d5f77c0f..87c08358a4 100644
--- a/client/src/lib/videoGenSubmission.test.js
+++ b/client/src/lib/videoGenSubmission.test.js
@@ -7,7 +7,7 @@ import { buildVideoGenSubmission } from './videoGenSubmission.js';
// default). Every other field the local payload needs is filled with the
// minimal values that keep the shared prompt/mode helpers from throwing.
const baseArgs = (overrides = {}) => ({
- isGrok: false, isFal: false, isReactor: false, remoteSubmissionFields: null,
+ hostedLane: null, remoteSubmissionFields: null,
prompt: 'a fox running through a forest',
negativePrompt: '',
width: 768, height: 512, mode: 'text',
@@ -59,7 +59,7 @@ describe('buildVideoGenSubmission — block streaming request (#6499)', () => {
describe('buildVideoGenSubmission — fal options (#9232)', () => {
it('carries selected resolution and provider audio only to the fal backend', () => {
const options = { falResolution: '4k', falGenerateAudio: true };
- expect(buildVideoGenSubmission(baseArgs({ isFal: true, ...options })))
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'fal', ...options })))
.toMatchObject({ backend: 'fal', falResolution: '4k', falGenerateAudio: true });
const local = buildVideoGenSubmission(baseArgs(options));
expect(local).not.toHaveProperty('falResolution');
@@ -68,16 +68,25 @@ describe('buildVideoGenSubmission — fal options (#9232)', () => {
it('omits unset options so the server keeps its resolution and silent defaults', () => {
const payload = buildVideoGenSubmission(baseArgs({
- isFal: true, falResolution: '', falGenerateAudio: false,
+ hostedLane: 'fal', falResolution: '', falGenerateAudio: false,
}));
expect(payload).not.toHaveProperty('falResolution');
expect(payload).not.toHaveProperty('falGenerateAudio');
});
});
+describe('buildVideoGenSubmission — lane dispatch', () => {
+ it('routes each hosted lane to its own payload and null to the local one', () => {
+ for (const lane of ['grok', 'fal', 'reactor', 'runway']) {
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: lane }))).toMatchObject({ backend: lane });
+ }
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: null }))).toMatchObject({ backend: 'local' });
+ });
+});
+
describe('buildVideoGenSubmission — hosted image-mode source', () => {
const source = { sourceImageFile: 'frame.png', sourceImageUpload: 'data:image/png;base64,AAA' };
- const lanes = { grok: { isGrok: true }, fal: { isFal: true }, reactor: { isReactor: true } };
+ const lanes = { grok: { hostedLane: 'grok' }, fal: { hostedLane: 'fal' }, reactor: { hostedLane: 'reactor' } };
for (const [backend, flag] of Object.entries(lanes)) {
it(`${backend}: image mode copies the source, text mode sends empty strings`, () => {
@@ -98,19 +107,19 @@ describe('buildVideoGenSubmission — hosted image-mode source', () => {
it('fal and reactor never send a negative prompt; grok does', () => {
const args = { negativePrompt: 'blurry' };
- expect(buildVideoGenSubmission(baseArgs({ isFal: true, ...args }))).not.toHaveProperty('negativePrompt');
- expect(buildVideoGenSubmission(baseArgs({ isReactor: true, ...args }))).not.toHaveProperty('negativePrompt');
- expect(buildVideoGenSubmission(baseArgs({ isGrok: true, ...args }))).toHaveProperty('negativePrompt');
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'fal', ...args }))).not.toHaveProperty('negativePrompt');
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'reactor', ...args }))).not.toHaveProperty('negativePrompt');
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'grok', ...args }))).toHaveProperty('negativePrompt');
});
it('fal omits an unset model id', () => {
- expect(buildVideoGenSubmission(baseArgs({ isFal: true, falModelId: '' })).falModelId).toBeUndefined();
- expect(buildVideoGenSubmission(baseArgs({ isFal: true, falModelId: 'm1' })).falModelId).toBe('m1');
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'fal', falModelId: '' })).falModelId).toBeUndefined();
+ expect(buildVideoGenSubmission(baseArgs({ hostedLane: 'fal', falModelId: 'm1' })).falModelId).toBe('m1');
});
});
describe('buildVideoGenSubmission — reactor fields', () => {
- const reactor = (o) => buildVideoGenSubmission(baseArgs({ isReactor: true, ...o }));
+ const reactor = (o) => buildVideoGenSubmission(baseArgs({ hostedLane: 'reactor', ...o }));
it('sends a seed of 0 and omits an unset seed', () => {
expect(reactor({ reactorSeed: 0 }).reactorSeed).toBe(0);
@@ -256,7 +265,7 @@ describe('buildVideoGenSubmission — prompt additions (#11317)', () => {
});
it('sends no No music chip on a hosted lane, which never appends it', () => {
- const payload = buildVideoGenSubmission(baseArgs({ isFal: true, currentModel: {}, stylePreset: preset, noMusic: true }));
+ const payload = buildVideoGenSubmission(baseArgs({ hostedLane: 'fal', currentModel: {}, stylePreset: preset, noMusic: true }));
expect(payload.promptAdditions).toEqual([{ id: 'style-1', label: 'Style preset: Film noir', text: 'cinematic noir' }]);
});
});
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index 36339a9b80..c94df74519 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -240,7 +240,7 @@ export default function VideoGen() {
// Every field the form submits, plus the payload builder both submit paths
// share. See client/src/hooks/useVideoGenForm.js.
const {
- backend, isGrok, isFal, isReactor, isRunway, handleBackendChange, grokDuration, setGrokDuration,
+ backend, hostedLane, isGrok, isFal, isReactor, isRunway, handleBackendChange, grokDuration, setGrokDuration,
runwayModelId, setRunwayModelId, runwayDuration, setRunwayDuration, runwayResolution, setRunwayResolution,
falDuration, setFalDuration, falModelId, setFalModelId,
falResolution, setFalResolution, falGenerateAudio, setFalGenerateAudio,
@@ -362,7 +362,7 @@ export default function VideoGen() {
// short submit / render / fetch ladder instead. A federated PEER is
// deliberately excluded: it really does load the weights and run the sampler,
// it just does so out of view.
- const rendersOffMachine = isGrok || isFal || isReactor || isRunway;
+ const rendersOffMachine = Boolean(hostedLane);
const rendersOnThisMachine = !rendersOffMachine && !remoteTarget.isRemote;
// Can THIS render put the display to sleep at all? The model says whether
@@ -1308,7 +1308,8 @@ export default function VideoGen() {
<div className="mt-2">
<ModelInputPreview preview={modelInputPreview} prompt={prompt} />
</div>
- {!negativePromptSupported && !isFal && !isReactor && !isRunway && (
+ {/* negativePromptSupported is already true for Grok and Runway, so this only fires on local lanes. */}
+ {!negativePromptSupported && !hostedLane && (
<p className="mt-1 text-[11px] text-gray-500 leading-snug">
This model does not use a negative prompt.
</p>