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

address review (copilot): runtime-status 400 path, enqueue + probe-window race gates, tensor truthiness, STAGE heartbeat parser

[._.]/ Adam Eivy0df0eb86d973
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index 5e4efb3265..983c9e4d7c 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -495,6 +495,14 @@ export default function VideoGen() {
return () => controller.abort();
}, [needsByovProbe, refreshByovStatus]);
const byovRuntimeMissing = !!byovStatus && byovStatus.installed === false;
+ // While the runtime-status probe is in flight (`needsByovProbe` is true but
+ // we haven't received a response yet), `byovStatus` is null and
+ // `byovRuntimeMissing` reads false — without this guard the user could
+ // submit during that window and hit a venv-missing 500 before the install
+ // banner appears. Gate Generate / Enqueue on the broader "BYOV not yet
+ // confirmed ready" instead. The banner itself still keys on `byovRuntimeMissing`
+ // (we don't want to flash "isn't installed yet" copy before we know).
+ const byovGateBlocked = needsByovProbe && (byovStatus === null || byovStatus.installed === false);
// Inline cache-status badge for the picked video model + the active text
// encoder (a separate ~7-25 GB HF pull). Drives the "Available" / "Download"
@@ -798,12 +806,16 @@ export default function VideoGen() {
// Without these guards the user could press Enter in the prompt
// textarea and fire a request the disabled button would otherwise
// have prevented.
- if (!prompt.trim() || generating || notConnected || extendModeBlocked || a2vModeBlocked || byovRuntimeMissing) return;
+ if (!prompt.trim() || generating || notConnected || extendModeBlocked || a2vModeBlocked || byovGateBlocked) return;
await runGeneration(buildGeneratePayload()).catch(() => {});
};
const handleEnqueue = () => {
- if (!prompt.trim() || notConnected || extendModeBlocked || a2vModeBlocked) return;
+ // Mirror the Generate guard — a BYOV runtime that isn't installed yet
+ // would silently queue a doomed job that fails late in the worker with
+ // VENV_MISSING, hiding the installer banner from the user. Block at
+ // enqueue time so the only path forward is the install banner above.
+ if (!prompt.trim() || notConnected || extendModeBlocked || a2vModeBlocked || byovGateBlocked) return;
const payload = buildGeneratePayload();
// Strip File blobs for snapshot — re-using a File across multiple queued
// submissions is fine, but we need a stable JSON-ish summary for the
@@ -910,7 +922,7 @@ export default function VideoGen() {
// ONLY a BYOV runtime via the modal would stay stuck behind a "not
// configured" error from the unrelated legacy probe.
const notConnected = !!status && status.connected === false && !needsByovProbe;
- const canEnqueue = prompt.trim() && !notConnected && !extendModeBlocked && !a2vModeBlocked;
+ const canEnqueue = prompt.trim() && !notConnected && !extendModeBlocked && !a2vModeBlocked && !byovGateBlocked;
// Symmetric frame picker for the FFLF + image modes. Each slot accepts
// EITHER a gallery filename OR a fresh upload; the preview renders
@@ -1462,10 +1474,11 @@ export default function VideoGen() {
) : (
<button
type="submit"
- disabled={!prompt.trim() || notConnected || extendModeBlocked || a2vModeBlocked || byovRuntimeMissing}
+ disabled={!prompt.trim() || notConnected || extendModeBlocked || a2vModeBlocked || byovGateBlocked}
className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg min-h-[40px]"
title={
byovRuntimeMissing ? `${byovStatus?.label || byovRuntime} runtime is not installed — use the install banner above`
+ : byovGateBlocked ? `Checking ${byovRuntime} runtime status…`
: extendModeBlocked ? 'Pick a prior render and wait for the last frame to extract before generating'
: a2vModeBlocked ? (currentModel?.runtime !== 'ltx2'
? 'a2v mode requires an ltx2-runtime model — pick one from the Model dropdown'
diff --git a/scripts/generate_hunyuan.py b/scripts/generate_hunyuan.py
index 26b5008266..bc1b6e99b2 100644
--- a/scripts/generate_hunyuan.py
+++ b/scripts/generate_hunyuan.py
@@ -359,8 +359,12 @@ def main() -> int:
num_videos_per_prompt=hv.num_videos,
)
- samples = outputs.get("samples") or []
- if len(samples) == 0:
+ # `outputs["samples"]` may be a list, None, or — in some hyvideo paths — a
+ # torch tensor. Don't use `or []`: bool(tensor) on a multi-element tensor
+ # raises `RuntimeError: Boolean value of Tensor with more than one value
+ # is ambiguous` before we ever reach save_videos_grid. Check explicitly.
+ samples = outputs.get("samples")
+ if samples is None or len(samples) == 0:
print("❌ hunyuan predict() returned no samples", file=sys.stderr)
return 1
diff --git a/server/routes/videoGen.js b/server/routes/videoGen.js
index 41c468082a..81ab0933a3 100644
--- a/server/routes/videoGen.js
+++ b/server/routes/videoGen.js
@@ -179,7 +179,13 @@ router.get('/setup/runtime-status', asyncHandler(async (req, res) => {
const runtime = String(req.query?.runtime || '');
const info = BYOV_RUNTIME_INFO[runtime];
if (!info) {
- return failValidation(res, `Unknown runtime: ${runtime}. Expected one of: ${Object.keys(BYOV_RUNTIME_INFO).join(', ')}`);
+ // `failValidation` only accepts a Zod safeParse result — calling it with
+ // (res, string) would TypeError on `parsed.error.issues.map(...)` and
+ // bubble as a 500 instead of the intended 400.
+ throw new ServerError(
+ `Unknown runtime: ${runtime}. Expected one of: ${Object.keys(BYOV_RUNTIME_INFO).join(', ')}`,
+ { status: 400, code: 'UNKNOWN_BYOV_RUNTIME' },
+ );
}
const binaryPresent = isByovRuntimeInstalled(info.id);
const packagesReady = binaryPresent ? await isByovRuntimeReady(info.id) : false;
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 8d609d4cab..4d97dd7703 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -760,10 +760,32 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
}
if (line.startsWith('STAGE:')) {
const parts = line.split(':');
- const step = parseInt(parts[3], 10) || 0;
- const total = parseInt(parts[4], 10) || 1;
- broadcastSse(job, { type: 'progress', progress: step / total, message: parts.slice(5).join(':') });
- videoGenEvents.emit('progress', { generationId: jobId, progress: step / total, step, totalSteps: total });
+ // Three STAGE: shapes ship today:
+ // STAGE:<stage>:step:<cur>:<total>:<msg> — explicit progress (parts[2]='step')
+ // STAGE:<stage>:heartbeat:<N>s — idle-watchdog ping (parts[2]='heartbeat')
+ // STAGE:<stage> — terse phase marker (no extra fields)
+ // The legacy "treat every STAGE: as step:" parse mangled heartbeat
+ // lines: parts[3]='20s' → parseInt=20, parts[4]=undefined → total=1, so
+ // a download-clip heartbeat broadcast progress=20.0 (= 2000%) to the UI.
+ // Normalize tag case — generate_ltx2.py emits `STEP:` (uppercase),
+ // generate_hunyuan.py emits `step:` and `heartbeat:` (lowercase).
+ const tag = (parts[2] || '').toLowerCase();
+ if (tag === 'heartbeat') {
+ // Surface as a status message; the activity emit above already
+ // resets the queue watchdog.
+ broadcastSse(job, { type: 'status', message: `${parts[1]}: heartbeat ${parts[3] || ''}` });
+ return true;
+ }
+ if (tag === 'step') {
+ const step = parseInt(parts[3], 10) || 0;
+ const total = parseInt(parts[4], 10) || 1;
+ broadcastSse(job, { type: 'progress', progress: step / total, message: parts.slice(5).join(':') });
+ videoGenEvents.emit('progress', { generationId: jobId, progress: step / total, step, totalSteps: total });
+ return true;
+ }
+ // Bare phase marker (e.g. STAGE:load-pipeline, STAGE:from-pretrained) —
+ // surface as a status line. No progress %, no division-by-undefined.
+ broadcastSse(job, { type: 'status', message: parts.slice(1).join(':') });
return true;
}
if (line.startsWith('DOWNLOAD:')) {