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
address review: infer image mode from sourceImagePath + defensive audio cleanup
Adam Eivyacc66659ebf2
diff --git a/PLAN.md b/PLAN.mdindex bfd7811610..547b0d0a82 100644--- a/PLAN.md+++ b/PLAN.md@@ -29,7 +29,7 @@ The PR landed with full pipeline mechanics + auto-recovery + smoke-test fixture,The dgrauet/ltx-2-mlx runtime now ships with FFLF (true keyframe interpolation) verified on hardware (commit `ef5d9081`). The pipeline supports more native modes that PortOS still emulates with workarounds — wiring each to the proper subcommand will materially improve quality. Helper script (`scripts/generate_ltx2.py`) already accepts the args; the gaps are server dispatch + client routing.- [ ] **Native video Extend (replace chained-i2v workaround).** Today the UI's "Extend" mode extracts the last frame and runs i2v on it — visible motion stalls at every chunk seam. Dgrauet's `ExtendPipeline.extend_from_video()` conditions on the *whole input video's latent* (motion + visual content), so new frames flow naturally. Files (~70 LOC): (1) fix `scripts/generate_ltx2.py` `run_extend` to mirror cli's `_decode_and_save` cleanup pattern (free DiT+TextEncoder, load decoders on-demand, then save) — current implementation OOMs at decode; (2) `server/services/videoGen/local.js` `buildLtx2Args` route extend → helperMode='extend' on ltx2, take new `extendFromVideoPath` param + validate; (3) `server/routes/videoGen.js` accept `extendFromVideoId` in body, resolve to absolute video path under `data/videos/`; (4) `client/src/pages/VideoGen.jsx` when mode=extend AND selected model has runtime='ltx2' skip `extractLastFrame`, send `extendFromVideoId` instead — fall back to existing chained-i2v on legacy runtime. Plus tests for the route's id resolution. Validate on hardware with a known-motion source clip — extension should continue motion vs. start cold.-- [x] ~~**Audio-to-video (a2v).**~~ Done — `run_a2v` in `scripts/generate_ltx2.py` invokes `AudioToVideoPipeline.generate_and_save` with `--audio` (WAV/MP3) and optional `--image` for first-frame conditioning. `server/lib/multipart.js`'s `uploadSingle` now accepts an array of field names so the route can take EITHER `sourceImage` (image/fflf) OR `audioFile` (a2v) through the same single-file uploader (mutually exclusive per request). `server/routes/videoGen.js` mode enum extended to include `a2v`, audio uploads stage to `data/uploads/video-audio-<uuid>.<ext>` and route to `audioFilePath`. `server/services/videoGen/local.js` `buildLtx2Args` maps `mode='a2v'` → `helperMode='a2v'`, passes `--audio`; rejects a2v on legacy `mlx_video` runtime with a clear error. `client/src/pages/VideoGen.jsx` adds the `a2v` mode tile (Music icon), an audio file picker that shows name + size + expected-duration hint, and submit guards for missing audio + non-ltx2 model. UAT: pick a 4–8 second audio clip with clear rhythm + a directive prompt ("a person dancing to this track in a studio"), verify the rendered video's motion syncs to the audio's beats.+- [x] ~~**Audio-to-video (a2v).**~~ Done — `run_a2v` in `scripts/generate_ltx2.py` invokes `AudioToVideoPipeline.generate_and_save` with `--audio` (WAV/MP3) and optional `--image` for first-frame conditioning. `server/lib/multipart.js` exposes `uploadFields(['sourceImage', 'lastImage', 'audioFile'], ...)` so a single route middleware takes whichever uploads the active mode needs (uploadSingle remains a single-fieldname back-compat wrapper). `server/routes/videoGen.js` mode enum extended to include `a2v`, audio uploads stage to `data/uploads/video-audio-<uuid>.<ext>` and route to `audioFilePath`; route fails fast on missing audio (`VIDEO_GEN_AUDIO_REQUIRED`), audio paired with non-a2v mode (`VIDEO_GEN_AUDIO_MODE_MISMATCH`), and a2v on a non-ltx2 model (`A2V_REQUIRES_LTX2`). `server/services/videoGen/local.js` `buildLtx2Args` maps `mode='a2v'` → `helperMode='a2v'`, passes `--audio`; rejects a2v on legacy `mlx_video` runtime with a clear error. `client/src/pages/VideoGen.jsx` adds the `a2v` mode tile (Music icon), an audio file picker that shows name + size + expected-duration hint, and submit guards for missing audio + non-ltx2 model. The mediaJobQueue sanitizes `audioFilePath` against `PATHS.uploads` at the queue→gen boundary as defense-in-depth against tampered persisted jobs. UAT: pick a 4–8 second audio clip with clear rhythm + a directive prompt ("a person dancing to this track in a studio"), verify the rendered video's motion syncs to the audio's beats.- [ ] **Native FFLF deeper test on real keyframe pairs.** FFLF wiring is verified on synthetic ball-motion keyframes (commit `ef5d9081`). Validate with REAL pairs: take last frame of clip A + first frame of clip B from the same scene/camera, render an interpolation, confirm temporally-coherent transition. If it looks weak even on similar keyframes, file a follow-up to expose more pipeline knobs in the UI (cfg-scale, stg-scale, stage1-steps).- [ ] **Add UI hint under FFLF mode.** "Use keyframes that share scene geometry — same camera, same subject; the model interpolates between them. Random unrelated images produce a visual cut." Prevents the "looks like two stills" complaint that surfaced during testing.- [ ] **Once dgrauet is the default for everything we care about, deprecate notapalindrome models.** Mark `ltx2_unified`, `ltx23_unified`, `ltx23_distilled_q4` with `deprecated: true` in `media-models.json` so the model dropdown groups them under a "Legacy" section. Eventually drop them and the `runtime: 'mlx_video'` dispatch entirely (~50 LOC removal in videoGen/local.js).diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.jsindex b8424478f6..3f63f03c1c 100644--- a/server/services/videoGen/local.js+++ b/server/services/videoGen/local.js@@ -99,11 +99,14 @@ const buildLtx2Args = ({ model, prompt, negativePrompt, width, height, numFrames// source video's latent (motion + visual content) rather than just the// last frame. Falls back to i2v only if the caller supplied no source// video (e.g., the chained-render orchestrator already handed us a frame).+ // When mode is omitted, infer i2v from a present sourceImagePath — matches+ // the route schema's documented "absence falls back to inferring" behavior.const wantsNativeExtend = mode === 'extend' && !!extendFromVideoPath;const helperMode = mode === 'fflf' ? 'fflf': mode === 'a2v' ? 'a2v': wantsNativeExtend ? 'extend': mode === 'image' || mode === 'extend' ? 'image'+ : (!mode && sourceImagePath) ? 'image': 'text';if (helperMode === 'fflf' && (!sourceImagePath || !lastImagePath)) {throw new ServerError(@@ -372,6 +375,12 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', mif (resizedLastTempPath) unlink(resizedLastTempPath).catch(() => {});if (uploadedTempPath) unlink(uploadedTempPath).catch(() => {});for (const p of uploadedTempPaths) unlink(p).catch(() => {});+ // Defensive: a direct caller (bypassing the route) may pass audioFilePath+ // without also threading it through uploadedTempPaths. Unlink it here too —+ // double-unlink on the route's path is harmless (catch swallows ENOENT).+ if (audioFilePath && !uploadedTempPaths.includes(audioFilePath)) {+ unlink(audioFilePath).catch(() => {});+ }closeJobAfterDelay(jobs, jobId);});@@ -445,6 +454,12 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m// every i2v request leaves a file in os.tmpdir() forever.if (uploadedTempPath) await unlink(uploadedTempPath).catch(() => {});for (const p of uploadedTempPaths) await unlink(p).catch(() => {});+ // Defensive: catch audioFilePath too in case a direct caller passed it+ // without threading through uploadedTempPaths. Skip when the route+ // already covered it (extraUploadedTempPaths.push(audioFilePath)).+ if (audioFilePath && !uploadedTempPaths.includes(audioFilePath)) {+ await unlink(audioFilePath).catch(() => {});+ }if (code !== 0) {job.status = 'error';