Skip to content

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

fix: make delivery intent outrank a declared draft decoder on every client path (#5449)

[._.]/ Adam Eivy83fb216067c9
diff --git a/client/src/components/media/MediaJobsQueue.jsx b/client/src/components/media/MediaJobsQueue.jsx
index 192020656c..0d8122fb41 100644
--- a/client/src/components/media/MediaJobsQueue.jsx
+++ b/client/src/components/media/MediaJobsQueue.jsx
@@ -27,7 +27,7 @@ import {
videoEdgeBoundsForModel, textEncoderOptionsForModel, STOCK_TEXT_ENCODER_ID,
normalizeTextEncoderForModel,
DEFAULT_SPEED_PROFILE_ID, normalizeSpeedProfileForModel, speedProfileIdFromRecord,
- DEFAULT_DRAFT_DECODE_ID, isFullDecodeId, normalizeDraftDecodeForModel, draftDecodeFromRecord,
+ isFullDecodeId, resolveDraftDecodeForModel, draftDecodeFromRecord,
} from '../../lib/videoGenParams';
import { isDeliveryVideoModel } from '../../lib/videoFinish';
import { loraFamilyOf, videoLoraFamily } from '../../lib/runnerFamilies';
@@ -760,15 +760,17 @@ function VideoRetryForm({ job, onSubmit, onCancel }) {
// to Full there rather than offering a draft the server would decline — the
// same reset the Video Gen form makes when Finish switches models.
const deliveryModel = isDeliveryVideoModel(currentModel, models);
- const snapDraftDecode = useCallback((id) => (
- deliveryModel ? DEFAULT_DRAFT_DECODE_ID : normalizeDraftDecodeForModel(id, currentModel)
- ), [currentModel, deliveryModel]);
- // Until `models` resolves, an unknown model means "not known yet", never "no
- // draft decoder" — so the baseline stays the RECORDED value and an untouched
- // requeue submitted mid-load still sends no decode override at all.
- const originalDraftDecode = currentModel
- ? snapDraftDecode(draftDecodeFromRecord(p.draftDecode))
- : draftDecodeFromRecord(p.draftDecode);
+ const recordedDraftDecode = draftDecodeFromRecord(p.draftDecode);
+ // What an UNTOUCHED requeue would re-submit. Two deliberate readings:
+ // - until `models` resolves, an unknown model means "not known yet", never
+ // "no draft decoder", so the baseline stays the recorded value and a
+ // requeue submitted mid-load still sends no decode override at all;
+ // - on a delivery model it ALSO stays the recorded value, so the lock's
+ // reset to Full counts as a change and clears the stale request rather
+ // than silently re-inheriting a decode the render can never perform.
+ const originalDraftDecode = (currentModel && !deliveryModel)
+ ? resolveDraftDecodeForModel(recordedDraftDecode, currentModel, models)
+ : recordedDraftDecode;
// Models arrive asynchronously, so the recorded profile can only be validated
// once the entry resolves. Until then state holds the raw recorded id; this
// snaps it to what the model actually declares, so an untouched form can't
@@ -782,8 +784,8 @@ function VideoRetryForm({ job, onSubmit, onCancel }) {
// is known, so the <select> can never hold a value it has no <option> for.
useEffect(() => {
if (!currentModel) return;
- setDraftDecode((current) => snapDraftDecode(current));
- }, [currentModel, snapDraftDecode]);
+ setDraftDecode((current) => resolveDraftDecodeForModel(current, currentModel, models));
+ }, [currentModel, models]);
// Multi-keyframe inputs are not exposed in the sanitized queue projection,
// but FFLF is their persisted semantic mode. IC/a2v conditioning also pins
// a single render, so keep the shared chaining controls consistent with the
diff --git a/client/src/components/media/MediaJobsQueue.test.jsx b/client/src/components/media/MediaJobsQueue.test.jsx
index 3da35dec1a..0de4dd17f0 100644
--- a/client/src/components/media/MediaJobsQueue.test.jsx
+++ b/client/src/components/media/MediaJobsQueue.test.jsx
@@ -526,12 +526,23 @@ describe('MediaJobsQueue — video retry decode override (#5449)', () => {
expect(select).toBeDisabled();
expect(screen.getByText(/Example Delivery is a delivery model/)).toBeInTheDocument();
- // The baseline snaps with the value, so an untouched requeue of a delivery
- // job stays byte-identical to today rather than growing a no-op override.
+ // The lock is a real reset, not just a display: it clears the inherited
+ // request so the requeued job stops carrying a decode it can never perform.
await user.click(screen.getByRole('button', { name: /Retry with changes/i }));
- expect(retryMediaJob).toHaveBeenCalledWith('decodefail000dead', null, { silent: true });
+ expect(retryMediaJob).toHaveBeenCalledWith(
+ 'decodefail000dead', { draftDecode: null }, { silent: true },
+ );
});
+ it('sends no override for a delivery-model job that never carried a decode', async () => {
+ const user = userEvent.setup();
+ getVideoGenStatus.mockResolvedValue({ models: MODELS });
+ await openRetryEditor(user, failedJob({ modelId: 'example-delivery' }));
+ await waitFor(() => expect(screen.getByLabelText('Decode').value).toBe('full'));
+
+ await user.click(screen.getByRole('button', { name: /Retry with changes/i }));
+ expect(retryMediaJob).toHaveBeenCalledWith('decodefail000dead', null, { silent: true });
+ });
it('resets the decode to Full when the retry is retargeted at a delivery model', async () => {
const user = userEvent.setup();
getVideoGenStatus.mockResolvedValue({ models: MODELS });
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.js
index d744930f05..50dac1bff2 100644
--- a/client/src/hooks/useVideoGenForm.js
+++ b/client/src/hooks/useVideoGenForm.js
@@ -22,7 +22,7 @@ import {
textEncoderIdFromRecord,
normalizeSpeedProfileForModel, speedProfileIdFromRecord,
DEFAULT_DRAFT_DECODE_ID, draftDecodeOptionsForModel,
- normalizeDraftDecodeForModel, draftDecodeFromRecord,
+ resolveDraftDecodeForModel, draftDecodeFromRecord,
} from '../lib/videoGenParams.js';
import { useVideoGenFieldState } from './useVideoGenFieldState.js';
import { useVideoGenSubmitFlow } from './useVideoGenSubmitFlow.js';
@@ -472,9 +472,11 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled, r
setSpeedProfileId((current) => normalizeSpeedProfileForModel(current, currentModel));
// And the same for the decode: only some models declare a draft decoder, so
// a switch away from one must not leave "Draft" selected on a model whose
- // renders would silently be full decodes.
- setDraftDecode((current) => normalizeDraftDecodeForModel(current, currentModel));
- }, [currentModel]);
+ // renders would silently be full decodes. `resolveDraftDecodeForModel` also
+ // clamps a DELIVERY model to Full — applyFinish covers the Finish button,
+ // but a model picked by hand (or restored from history) reaches here instead.
+ setDraftDecode((current) => resolveDraftDecodeForModel(current, currentModel, models));
+ }, [currentModel, models]);
// Substitutable prompt conditioners the selected model can load, straight off
// the server-decorated entry. Empty for every runtime without substitutions,
@@ -1208,7 +1210,7 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled, r
prompt, negativePrompt, stylePreset,
width, height, mode, sourceImageFile, sourceImageUpload,
numFrames, fps, steps, guidanceScale, seed,
- currentModel, modelId, tiling, textEncoderId, speedProfileId, draftDecode,
+ currentModel, models, modelId, tiling, textEncoderId, speedProfileId, draftDecode,
disableAudio, noMusic, imageStrength, i2vReferenceMode,
keyframesActive, keyframes, loraFamily, selectedLoras,
lastImageFile, lastImageUpload, extendFromVideoId, audioFile,
diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsx
index 6c1bc0140d..f2a54cb5a5 100644
--- a/client/src/hooks/useVideoGenForm.test.jsx
+++ b/client/src/hooks/useVideoGenForm.test.jsx
@@ -786,6 +786,26 @@ describe('useVideoGenForm', () => {
expect(result.current.mode).toBe('text');
});
+ // #5449 — applyFinish resets the decode, but a user can also reach a delivery
+ // model by hand from the Model dropdown. Without the same clamp there the
+ // form would submit a draft decode the server declines, and persist a knob
+ // that changed nothing on the render.
+ it('clamps a draft decode to full when a delivery model is picked by hand', async () => {
+ const DECODE_OPTIONS = [
+ { id: 'full', label: 'Full decode' },
+ { id: 'draft', label: 'Example draft decoder' },
+ ];
+ const draft = { ...MLX, finishModelId: LTX2.id, draftDecodeOptions: DECODE_OPTIONS };
+ const delivery = { ...LTX2, draftDecodeOptions: DECODE_OPTIONS };
+ const { result } = render({ models: [draft, delivery] });
+ await waitFor(() => expect(result.current.modelId).toBe(draft.id));
+
+ act(() => result.current.setDraftDecode('draft'));
+ await waitFor(() => expect(result.current.draftDecode).toBe('draft'));
+
+ act(() => result.current.handleModelChange(delivery.id));
+ await waitFor(() => expect(result.current.draftDecode).toBe('full'));
+ });
it('applyFinish switches off the grok backend so the delivery model is what actually renders', async () => {
const { result } = render({ grokEnabled: true });
act(() => result.current.handleBackendChange('grok'));
diff --git a/client/src/lib/videoGenParams.js b/client/src/lib/videoGenParams.js
index b61e0e6ad3..f4fee685b5 100644
--- a/client/src/lib/videoGenParams.js
+++ b/client/src/lib/videoGenParams.js
@@ -5,6 +5,7 @@
// page and any future consumer import them directly.
import { isLtx2FamilyRuntime } from './runnerFamilies';
+import { isDeliveryVideoModel } from './videoFinish.js';
// Values follow LTX-2's 8k+1 latent boundary so the model doesn't silently
// snap. 241 = 10s @ 24fps is the comfortable single-pass ceiling on 48 GB
@@ -236,6 +237,19 @@ export const normalizeDraftDecodeForModel = (id, model) => (
export const draftDecodeFromRecord = (value) => (
typeof value === 'string' && value ? value : DEFAULT_DRAFT_DECODE_ID
);
+// The decode a request on THIS model actually resolves to. Delivery intent
+// OUTRANKS declaration, in the same order `draftDecodeDeclineReason` gates it
+// server-side: a model the finish graph names as a delivery target always
+// decodes on its own decoder, so the request snaps to Full there before the
+// question of "with which decoder?" is even asked. Every client path that
+// reconciles a decode against a model — the Video Gen form's model-switch
+// snap-back, its submit payload, and the requeue editor — goes through this, so
+// none of them can offer or POST a draft the server would decline.
+export const resolveDraftDecodeForModel = (id, model, models) => (
+ isDeliveryVideoModel(model, models)
+ ? DEFAULT_DRAFT_DECODE_ID
+ : normalizeDraftDecodeForModel(id, model)
+);
// Per-edge bounds for video: mirrors the videoGen route (64..2048). The base
// grid is 64px, while a model may declare a finer resolutionStep (H3 uses 32).
diff --git a/client/src/lib/videoGenParams.test.js b/client/src/lib/videoGenParams.test.js
index 3daf9542aa..563bdbd463 100644
--- a/client/src/lib/videoGenParams.test.js
+++ b/client/src/lib/videoGenParams.test.js
@@ -12,6 +12,7 @@ import {
speedProfileIdFromRecord, selectedSpeedProfile, videoChainChunkModes,
DEFAULT_DRAFT_DECODE_ID, isFullDecodeId, draftDecodeOptionsForModel,
supportsDraftDecode, normalizeDraftDecodeForModel, draftDecodeFromRecord,
+ resolveDraftDecodeForModel,
} from './videoGenParams.js';
describe('videoModelMemoryGb', () => {
@@ -396,6 +397,30 @@ describe('draft decode helpers', () => {
])('reads %p out of a record as %p', (stored, expected) => {
expect(draftDecodeFromRecord(stored)).toBe(expected);
});
+
+ // Delivery intent outranks declaration (#5449), the same order
+ // `draftDecodeDeclineReason` gates it server-side: a model another entry
+ // names as its Finish target always decodes on its own decoder, even when it
+ // declares a draft decoder of its own.
+ describe('resolveDraftDecodeForModel', () => {
+ const DELIVERY = { id: 'delivery_model', draftDecodeOptions: OPTIONS };
+ const DRAFT = { id: 'draft_model', finishModelId: 'delivery_model', draftDecodeOptions: OPTIONS };
+ const MODELS = [DRAFT, DELIVERY];
+
+ it('keeps a declared decode on a model at the draft end of the graph', () => {
+ expect(resolveDraftDecodeForModel('draft', DRAFT, MODELS)).toBe('draft');
+ });
+
+ it('snaps to full on a delivery model even though it declares a decoder', () => {
+ expect(resolveDraftDecodeForModel('draft', DELIVERY, MODELS)).toBe(DEFAULT_DRAFT_DECODE_ID);
+ });
+
+ // Without the list nothing can be read as a delivery target, so this must
+ // fall through to the plain declaration check rather than locking to full.
+ it('falls back to the declaration check when the model list is absent', () => {
+ expect(resolveDraftDecodeForModel('draft', DELIVERY, null)).toBe('draft');
+ });
+ });
});
// @vitest-environment node
diff --git a/client/src/lib/videoGenSubmission.js b/client/src/lib/videoGenSubmission.js
index 575988184f..0bfb05ec84 100644
--- a/client/src/lib/videoGenSubmission.js
+++ b/client/src/lib/videoGenSubmission.js
@@ -12,7 +12,7 @@ import {
selectedSpeedProfile,
videoChainChunkModes,
DEFAULT_DRAFT_DECODE_ID,
- normalizeDraftDecodeForModel,
+ resolveDraftDecodeForModel,
} from './videoGenParams.js';
// The form owns state transitions and validation. This module owns the three
@@ -32,7 +32,7 @@ export function buildVideoGenSubmission({
prompt, negativePrompt, stylePreset,
width, height, mode, sourceImageFile, sourceImageUpload,
numFrames, fps, steps, guidanceScale, seed,
- currentModel, modelId, tiling, textEncoderId, speedProfileId, draftDecode,
+ currentModel, models, modelId, tiling, textEncoderId, speedProfileId, draftDecode,
disableAudio, noMusic, imageStrength, i2vReferenceMode,
keyframesActive, keyframes, loraFamily, selectedLoras,
lastImageFile, lastImageUpload, extendFromVideoId, audioFile,
@@ -104,10 +104,11 @@ export function buildVideoGenSubmission({
model: currentModel, mode, chaining: chainingActive, contextFrames,
}))?.id,
// Preview-fidelity decode (#5423). Sent only when it is a real, still-valid
- // choice on THIS model — a stale selection carried across a model switch
- // would otherwise POST a knob the server declines and logs. Absence is a
- // full decode, so an unswapped render's payload is unchanged.
- draftDecode: normalizeDraftDecodeForModel(draftDecode, currentModel) === DEFAULT_DRAFT_DECODE_ID
+ // choice on THIS model — a stale selection carried across a model switch, or
+ // one aimed at a DELIVERY model, would otherwise POST a knob the server
+ // declines and logs. Absence is a full decode, so an unswapped render's
+ // payload is unchanged.
+ draftDecode: resolveDraftDecodeForModel(draftDecode, currentModel, models) === DEFAULT_DRAFT_DECODE_ID
? undefined
: draftDecode,
disableAudio: effectiveDisableAudio ? 'true' : 'false',