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 (codex): mountedRef StrictMode reset, exempt BYOV runtimes from pythonPath gate

[._.]/ Adam Eivydae16bcf3ee0
diff --git a/PLAN.md b/PLAN.md
index 0cfd7a851f..4f38c3acae 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -224,6 +224,7 @@ The first slice shipped a working **seed-mode** conductor (`/story-builder`): cr
- [ ] [hidream-qwen-client-runner-consumers] **Wire HIDREAM/QWEN through client runnerFamily consumers.** `client/src/lib/runnerFamilies.js` exports the constants and `server/lib/runners.js` mirrors them, but client-side consumers haven't been extended: `client/src/lib/imageGenResolutions.js`'s `compatibilityKey` OR-chain still only checks `FLUX2 | Z_IMAGE | ERNIE` (falls through to `'flux1'` for HiDream/Qwen — silently denies their natural 1536× hi-res variants), and `client/src/pages/Loras.jsx` `RUNNER_LABELS` / `RUNNER_BG_COLORS` / Top-LoRA section list omit them so the LoRA picker shows them as unlabeled / no badge color. Either extend each consumer site or document that HiDream/Qwen intentionally inherit Flux 1 resolution presets. Surfaced by /do:review of PR #516 (2026-05-28).
- [ ] [wan22-hunyuan-setup-pin-shas] **Pin Wan22 / HunyuanVideo MLX clones to known-good commit SHAs.** `scripts/setup-image-video.sh` defaults `WAN22_PIN="${WAN22_PIN:-main}"` and `HUNYUAN_PIN="${HUNYUAN_PIN:-main}"`. Floating `main` on two community-maintained ports with unpinned CLIs (the PR description explicitly flags both as experimental — "if upstream renames args, flip the registry entry broken: true") means every new install gets whatever HEAD is on those repos that day. Replace the default with a tested SHA for each; let users override via the env var (same shape as the diffusers pin). Surfaced by /do:review of PR #516 (2026-05-28).
- [ ] [memory-mgmt-new-endpoint-tests] **Add tests for the 5 new memory-management routes.** `/api/local-llm/loaded`, `/api/local-llm/unload`, `/api/voice/whisper`, `/api/voice/tts/status`, `/api/voice/tts/unload` have no test coverage. The PR description claims "8062/8062 tests passing" — true for the existing suite, but no asserts pin the new wire contracts (response shapes, residency precondition, validation rejection). Add focused happy-path + validation-rejection tests so future regressions in the schema-parity fixes (or the `unloadModel` residency check) surface as test failures. Surfaced by /do:review of PR #516 (2026-05-28).
+- [ ] [qwen-image-edit-init-image-required] **Qwen-Image-Edit dispatches without its required init image.** `qwen-image-edit` (registry `mediaModels.js:202`) loads `QwenImageEditPipeline` which requires an `image` arg; the entry is exposed in the normal image-gen model picker which permits text-only submission. Today the user picks the model, submits a text prompt, and the runner crashes deep inside the diffusers pipeline after loading the 20B-param model from disk. Options: (a) add an `editOnly: true` flag to the model + validate at `routes/imageGen.js` POST; (b) filter the model from the picker when no source image is uploaded; (c) reroute through a future `/api/image-gen/edit` endpoint. Touches the image route schema + UI gating — defer to a focused PR. Surfaced by codex review of PR #516 (2026-05-28).
- [ ] [hidream-requires-hf-token-fail-fast] **Probe HF token upfront for HiDream gated-encoder downloads.** `data.reference/media-models.json`'s HiDream entries carry `requiresHfToken: true` + a `licenseUrl` pointing at `meta-llama/Meta-Llama-3.1-8B-Instruct`, but `scripts/z_image_turbo.py` `load_external_text_encoder()` does NOT call `probe_hf_auth()` the way `flux2_macos.py:265` does for the base FLUX repo. A user without a valid HF token currently sees a multi-GB download attempt that fails with a 401 deep inside transformers instead of a clean upfront error. Mirror the FLUX.2 probe before invoking `transformers.from_pretrained()` on the gated encoder repo. Surfaced by /do:review of PR #516 (2026-05-28).
## Future Ideas
diff --git a/client/src/components/settings/MemoryManagement.jsx b/client/src/components/settings/MemoryManagement.jsx
index 31228c5a18..acbc764a2d 100644
--- a/client/src/components/settings/MemoryManagement.jsx
+++ b/client/src/components/settings/MemoryManagement.jsx
@@ -20,11 +20,12 @@
// apiCore's default toast doesn't fire underneath; per the CLAUDE.md
// "Silent vs. toasting API requests" rule, custom catch ⇒ silent: true.
-import { useState, useEffect, useCallback, useRef } from 'react';
+import { useState, useEffect, useCallback } from 'react';
import { Cpu, Mic, Volume2, Trash2, Power, PowerOff, RefreshCw, AlertTriangle } from 'lucide-react';
import toast from '../ui/Toast';
import BrailleSpinner from '../BrailleSpinner';
import { useAsyncAction } from '../../hooks/useAsyncAction.js';
+import useMounted from '../../hooks/useMounted.js';
import { formatBytes } from '../../utils/formatters';
import { getLoadedLlmModels, unloadOllamaModel } from '../../services/apiLocalLlm.js';
import { getTtsStatus, unloadKokoroTts, controlWhisper, getVoiceStatus } from '../../services/apiVoice.js';
@@ -58,11 +59,10 @@ export default function MemoryManagement() {
const [lastFetched, setLastFetched] = useState(0);
// Guards the polled setState calls — a late /voice/status response that
// resolves after unmount would otherwise call setState on a dead tree.
- // Never reset to true: React 18 dev double-mount runs the cleanup once
- // and only re-mounts the same component instance; the new instance gets
- // its own ref.
- const mountedRef = useRef(true);
- useEffect(() => () => { mountedRef.current = false; }, []);
+ // useMounted resets the ref to true on every mount so React 18 StrictMode's
+ // mount→cleanup→remount cycle doesn't leave it permanently false (which
+ // would otherwise keep the panel stuck on "Loading memory status…" in dev).
+ const mountedRef = useMounted();
const refresh = useCallback(async () => {
const [llm, tts, voice] = await Promise.all([
diff --git a/server/routes/videoGen.js b/server/routes/videoGen.js
index c04150becb..66750c9ce8 100644
--- a/server/routes/videoGen.js
+++ b/server/routes/videoGen.js
@@ -196,17 +196,6 @@ router.post('/', frameImageUpload, asyncHandler(async (req, res) => {
const body = parsed.data;
const s = await getSettings();
const pythonPath = s.imageGen?.local?.pythonPath || null;
- // Reject up-front when the local python isn't configured. Without this,
- // the queue would happily accept the job, return 200/queued, and only
- // surface the failure asynchronously on SSE — which then pollutes the
- // persisted queue with a doomed entry.
- if (!pythonPath) {
- await cleanupTempUploads();
- throw new ServerError(
- 'Local video generation is not configured (settings.imageGen.local.pythonPath is missing).',
- { status: 400, code: 'VIDEO_GEN_NOT_CONFIGURED' },
- );
- }
// Resolve the effective model up front — both the modelId-exists check
// below AND the a2v runtime guard further down need the model entry,
// and listVideoModels() is the kind of thing test mocks easily get out
@@ -224,6 +213,21 @@ router.post('/', frameImageUpload, asyncHandler(async (req, res) => {
{ status: 400, code: 'VIDEO_GEN_UNKNOWN_MODEL' },
);
}
+ // Reject up-front when the local python isn't configured AND the model's
+ // runtime needs it. ltx2/wan22/hunyuan bring their own venv (resolved
+ // inside buildArgs), so they must NOT be blocked by the legacy mlx_video
+ // pythonPath setting. Without this gate, the queue would happily accept
+ // a job that's known to fail and only surface it asynchronously on SSE,
+ // polluting the persisted queue with a doomed entry.
+ const BYOV_RUNTIMES = new Set(['ltx2', 'wan22', 'hunyuan']);
+ const runtimeBringsOwnVenv = effectiveModel && BYOV_RUNTIMES.has(effectiveModel.runtime);
+ if (!pythonPath && !runtimeBringsOwnVenv) {
+ await cleanupTempUploads();
+ throw new ServerError(
+ 'Local video generation is not configured (settings.imageGen.local.pythonPath is missing).',
+ { status: 400, code: 'VIDEO_GEN_NOT_CONFIGURED' },
+ );
+ }
// Track every durable file we've already copied into PATHS.uploads so a
// *later* staging failure can roll them back. Without this, staging
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.js
index af0b2a8864..4cb15fc461 100644
--- a/server/routes/videoGen.test.js
+++ b/server/routes/videoGen.test.js
@@ -653,15 +653,32 @@ describe('videoGen routes', () => {
// Pre-enqueue config validation: without pythonPath the queue would
// accept the job, return 200/queued, then fail asynchronously over SSE
- // and pollute the persisted queue with a doomed entry.
- it('rejects 400 VIDEO_GEN_NOT_CONFIGURED when pythonPath is missing', async () => {
+ // and pollute the persisted queue with a doomed entry. Skipped for
+ // ltx2/wan22/hunyuan runtimes which bring their own venv (see the
+ // BYOV_RUNTIMES allowlist mirrored in services/videoGen/local.js).
+ it('rejects 400 VIDEO_GEN_NOT_CONFIGURED when pythonPath is missing and the model needs it', async () => {
const settingsMock = await import('../services/settings.js');
settingsMock.getSettings.mockResolvedValueOnce({ imageGen: { local: {} } });
- const r = await request(app).post('/api/video-gen/').send({ prompt: 'a cat' });
+ // Override the default `ltx2` mock with a legacy mlx_video runtime so
+ // the pythonPath gate actually fires — ltx2/wan22/hunyuan are exempt.
+ videoGenService.listVideoModels.mockReturnValueOnce([
+ { id: 'legacy_mlx', name: 'legacy mlx_video', runtime: 'mlx_video' },
+ ]);
+ const r = await request(app).post('/api/video-gen/').send({ prompt: 'a cat', modelId: 'legacy_mlx' });
expect(r.status).toBe(400);
expect(r.body.error).toMatch(/not configured/i);
expect(mediaJobQueue.enqueueJob).not.toHaveBeenCalled();
});
+
+ // The matching positive case: an ltx2/wan22/hunyuan model bypasses the
+ // pythonPath gate because buildArgs resolves its own venv.
+ it('accepts a BYOV-runtime model (ltx2) when pythonPath is missing', async () => {
+ const settingsMock = await import('../services/settings.js');
+ settingsMock.getSettings.mockResolvedValueOnce({ imageGen: { local: {} } });
+ const r = await request(app).post('/api/video-gen/').send({ prompt: 'a cat', modelId: 'ltx2_unified' });
+ expect(r.status).toBe(200);
+ expect(mediaJobQueue.enqueueJob).toHaveBeenCalledTimes(1);
+ });
});
describe('GET /:jobId/events', () => {
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 6a5ced376a..73c2a664ef 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -406,7 +406,6 @@ export const DEFAULT_NUM_FRAMES = 121;
export async function generateVideo({ pythonPath, prompt, negativePrompt = '', modelId = defaultVideoModelId(), width = 768, height = 512, numFrames = DEFAULT_NUM_FRAMES, fps = 24, steps, guidanceScale, seed, tiling = 'auto', disableAudio = false, sourceImagePath = null, uploadedTempPath = null, uploadedTempPaths = [], lastImagePath = null, keyframes = null, extendFromVideoPath = null, audioFilePath = null, mode = null, imageStrength = null, hidden = false, jobId: providedJobId = null }) {
uploadedTempPaths = Array.isArray(uploadedTempPaths) ? uploadedTempPaths : [];
- if (!pythonPath) throw new ServerError('Python path not configured — set it in Settings > Image Gen', { status: 400, code: 'VIDEO_GEN_NOT_CONFIGURED' });
if (!prompt?.trim()) throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });
// Single-flight is now enforced by the mediaJobQueue worker upstream — only
// one job is dequeued at a time, so we don't need a BUSY guard here. Direct
@@ -415,6 +414,15 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
const model = VIDEO_MODELS[modelId];
if (!model) throw new ServerError(`Unknown video model: ${modelId}`, { status: 400, code: 'VALIDATION_ERROR' });
+ // Only require the legacy mlx_video pythonPath when the chosen runtime
+ // actually uses it. ltx2/wan22/hunyuan resolve their own venv path inside
+ // buildArgs — gating them on the unrelated mlx_video setting locks users
+ // out of the runtimes they just installed via INSTALL_WAN22 / INSTALL_LTX2
+ // / INSTALL_HUNYUAN. Routes/videoGen.js mirrors this allowlist.
+ const BYOV_RUNTIMES = new Set(['ltx2', 'wan22', 'hunyuan']);
+ if (!pythonPath && !BYOV_RUNTIMES.has(model.runtime)) {
+ throw new ServerError('Python path not configured — set it in Settings > Image Gen', { status: 400, code: 'VIDEO_GEN_NOT_CONFIGURED' });
+ }
// macOS/mlx_video requires a HuggingFace repo id — Windows doesn't (the
// diffusers wrapper hardcodes Lightricks/LTX-Video). A user-edited registry
// entry missing `repo` would otherwise pass `undefined` into spawn args.