Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

fix: pre-ship audit pass 2 — mflux update + Gemma local + leak sweep + pull-state ordering

mrbizarro11c1a390330d
diff --git a/assets/phosphene_wordmark_compact_transparent.svg b/assets/phosphene_wordmark_compact_transparent.svg
index 07d97d3..b8be10a 100644
--- a/assets/phosphene_wordmark_compact_transparent.svg
+++ b/assets/phosphene_wordmark_compact_transparent.svg
@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 768 256" width="768" height="256">
-
+
<g transform="translate(0, 0)">
<g data-ring="0" stroke="#FF2E9F" stroke-width="1.485" stroke-linecap="round">
<line x1="147.46" y1="128.00" x2="152.06" y2="128.00"/>
diff --git a/image_engine.py b/image_engine.py
index b07c0a2..592b540 100644
--- a/image_engine.py
+++ b/image_engine.py
@@ -31,7 +31,8 @@ This module is the dispatch layer. Four backends ship today:
don't have to know it needs 4 steps vs 25.
- **hidream** — fully-local HiDream-O1-Image-Dev (8B Qwen3-VL-based unified
pixel-patch transformer, MIT). Lives in its own venv outside Phosphene
- at `/Users/salo/HIDREAM-O1-MLX-LAB-active/`. Subprocess pattern, mirrors
+ at ``$HIDREAM_LAB_DIR`` (defaults to ``~/HIDREAM-O1-MLX-LAB-active``).
+ Subprocess pattern, mirrors
mflux. Default **BF16** (~16 GB working set, 1024×1024 in ~67s) —
matches upstream's master-weight precision and is the only precision
that doesn't show patch-grid artifacts in flat regions. Q8/Q6 work
@@ -1150,8 +1151,8 @@ def _generate_bfl(prompt: str, n: int, width: int, height: int,
# ltx-2-mlx env stay decoupled (different MLX-related dep trees historically
# fight each other on install). Subprocess pattern, mirrors mflux.
#
-# Lab layout:
-# /Users/salo/HIDREAM-O1-MLX-LAB-active/
+# Lab layout (resolved via $HIDREAM_LAB_DIR; default ~/HIDREAM-O1-MLX-LAB-active):
+# <HIDREAM_LAB_DIR>/
# .venv/bin/python <- the interpreter we shell out to
# mlx_models/hidream-o1-dev-bf16/
# model.safetensors <- 17 GB BF16 backbone (mlx-vlm-loadable)
diff --git a/lora_lab/character_runtime.py b/lora_lab/character_runtime.py
index 7a72a9a..015f02e 100644
--- a/lora_lab/character_runtime.py
+++ b/lora_lab/character_runtime.py
@@ -26,9 +26,27 @@ from pathlib import Path
from typing import Any, Optional
-# Default locations — override at module import if needed.
-CHARACTERS_DIR = Path("/Users/salo/pinokio/api/phosphene-dev.git/mlx_models/characters")
-LORAS_DIR = Path("/Users/salo/pinokio/api/phosphene-dev.git/mlx_models/loras")
+# Default locations — derived from the panel install root the same
+# way the other vendored lora_lab modules resolve their model dir.
+# Override either by reassigning these constants at import time or by
+# setting LTX_MODELS_DIR which the resolver also honors.
+def _default_models_root() -> Path:
+ import os
+ env_dir = os.environ.get("LTX_MODELS_DIR")
+ if env_dir:
+ return Path(env_dir).expanduser()
+ here = Path(__file__).resolve()
+ for parent in here.parents:
+ candidate = parent / "mlx_models"
+ if candidate.is_dir():
+ return candidate
+ if (parent / ".git").exists():
+ return parent / "mlx_models"
+ return here.parents[1] / "mlx_models"
+
+_MODELS_ROOT = _default_models_root()
+CHARACTERS_DIR = _MODELS_ROOT / "characters"
+LORAS_DIR = _MODELS_ROOT / "loras"
@dataclass
diff --git a/lora_lab/preprocess_images.py b/lora_lab/preprocess_images.py
index 5408d0c..a09c1d0 100644
--- a/lora_lab/preprocess_images.py
+++ b/lora_lab/preprocess_images.py
@@ -186,13 +186,22 @@ def preprocess_images(
images_dir: str,
output_dir: str,
model_dir: str = DEFAULT_MODEL_DIR,
- gemma_model_id: str = "mlx-community/gemma-3-12b-it-4bit",
+ gemma_model_id: str | None = None,
target_height: int = 320,
target_width: int = 512,
captions_dir: str | None = None,
caption_ext: str = ".txt",
crop_anchor: str = "center",
) -> None:
+ # Default to the locally-resolved Gemma path (vendored install ships
+ # mlx_models/gemma-3-12b-it-4bit; the panel sets LTX_MODELS_DIR so
+ # the resolver lands there). Falling back to the HF repo id, the way
+ # the previous hard-coded default did, would silently duplicate-
+ # download ~6 GB to HF_HOME on a clean Pinokio install AND fail on
+ # offline rigs that have the local Gemma already cached.
+ if gemma_model_id is None:
+ from lora_lab import resolve_default_text_encoder
+ gemma_model_id = resolve_default_text_encoder()
mx.set_cache_limit(mx.device_info()["memory_size"])
model_dir = _resolve_model_dir(model_dir)
diff --git a/lora_lab/train_character.py b/lora_lab/train_character.py
index bbace45..2ad4649 100644
--- a/lora_lab/train_character.py
+++ b/lora_lab/train_character.py
@@ -425,6 +425,10 @@ def run_preprocess(
pp.preprocess_images(
images_dir=str(images_dir),
output_dir=str(output_root),
+ # Pass the locally-resolved Gemma path explicitly. Without
+ # this the preprocessor falls back to the HF repo id and
+ # may duplicate-download ~6 GB to HF_HOME (or fail offline).
+ gemma_model_id=DEFAULT_TEXT_ENCODER,
target_height=resolution,
target_width=resolution,
captions_dir=str(captions_dir),
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 516eca5..810c372 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -9783,6 +9783,64 @@ class Handler(BaseHTTPRequestHandler):
# `git pull`), we set pull_requires_full_update=True and the
# UI nudges the user toward Pinokio's full Update flow
# instead of just Stop+Start.
+ # Server-side guards run BEFORE we mutate _VERSION_STATE so a
+ # rejected 409 doesn't leave pull_state="pulling" stuck on
+ # disk for the UI poller to chew on forever. Previously the
+ # state was set first and the guards lived inside the try
+ # block; a guarded return would skip the cleanup branch in
+ # the bottom finally clause and never reset pull_state. Codex
+ # caught this on the second pre-ship review.
+ #
+ # The UI already refuses to surface the magic Update button
+ # unless the local repo is clean + on main + with no local
+ # commits ahead, but a malicious POST could otherwise bypass
+ # that and silently trigger `reset --hard`. Re-validate here.
+ cur_branch = (_git_capture(
+ ["rev-parse", "--abbrev-ref", "HEAD"]) or "").strip()
+ if cur_branch != "main":
+ self._json({
+ "ok": False,
+ "error": (
+ f"refusing to pull: local repo is on '{cur_branch}', "
+ f"not 'main'. Switch to main or run a fresh Pinokio "
+ f"install if you didn't intend to be on a side branch."
+ ),
+ }, 409)
+ return
+ # `git status --porcelain` is empty iff the working tree is
+ # clean. The UI's clean-check uses the same probe.
+ dirty = (_git_capture(["status", "--porcelain"]) or "").strip()
+ if dirty:
+ self._json({
+ "ok": False,
+ "error": (
+ "refusing to pull: local working tree has "
+ "uncommitted changes. Commit, stash, or discard "
+ "them, then click Update again."
+ ),
+ "dirty_files": dirty.splitlines()[:20],
+ }, 409)
+ return
+ # Block if there are local commits ahead of origin — those
+ # would be wiped by the reset --hard fallback below.
+ ahead = (_git_capture(
+ ["rev-list", "--count", "origin/main..HEAD"]) or "0").strip()
+ try:
+ ahead_n = int(ahead)
+ except ValueError:
+ ahead_n = 0
+ if ahead_n > 0:
+ self._json({
+ "ok": False,
+ "error": (
+ f"refusing to pull: local has {ahead_n} commit(s) "
+ f"ahead of origin/main. Push them or reset manually "
+ f"if you don't need them."
+ ),
+ }, 409)
+ return
+
+ # All guards passed — claim the pulling state and proceed.
with _VERSION_LOCK:
_VERSION_STATE["pull_state"] = "pulling"
_VERSION_STATE["pull_message"] = None
@@ -9790,58 +9848,6 @@ class Handler(BaseHTTPRequestHandler):
_VERSION_STATE["pull_pulled_to_version"] = None
_VERSION_STATE["pull_requires_full_update"] = False
try:
- # Server-side guard (P2 hardening 2026-05-18). The UI already
- # refuses to surface the magic Update button unless the
- # local repo is clean + on main + with no local commits
- # ahead, but a malicious POST could otherwise bypass that
- # and silently trigger `reset --hard` on the user's repo.
- # Re-validate here so the endpoint never destroys local
- # work without explicit ?force=1 opt-in.
- cur_branch = (_git_capture(
- ["rev-parse", "--abbrev-ref", "HEAD"]) or "").strip()
- if cur_branch != "main":
- self._json({
- "ok": False,
- "error": (
- f"refusing to pull: local repo is on '{cur_branch}', "
- f"not 'main'. Switch to main or run a fresh Pinokio "
- f"install if you didn't intend to be on a side branch."
- ),
- }, 409)
- return
- # `git status --porcelain` is empty iff the working tree is
- # clean. The UI's clean-check uses the same probe.
- dirty = (_git_capture(["status", "--porcelain"]) or "").strip()
- if dirty:
- self._json({
- "ok": False,
- "error": (
- "refusing to pull: local working tree has "
- "uncommitted changes. Commit, stash, or discard "
- "them, then click Update again."
- ),
- "dirty_files": dirty.splitlines()[:20],
- }, 409)
- return
- # Block if there are local commits ahead of origin — those
- # would be wiped by the reset --hard fallback below.
- ahead = (_git_capture(
- ["rev-list", "--count", "origin/main..HEAD"]) or "0").strip()
- try:
- ahead_n = int(ahead)
- except ValueError:
- ahead_n = 0
- if ahead_n > 0:
- self._json({
- "ok": False,
- "error": (
- f"refusing to pull: local has {ahead_n} commit(s) "
- f"ahead of origin/main. Push them or reset manually "
- f"if you don't need them."
- ),
- }, 409)
- return
-
# Capture HEAD before the pull so we can diff afterwards.
pre_sha = _git_capture(["rev-parse", "HEAD"]) or ""
# Step 1: fetch — populates origin/main without touching HEAD.
diff --git a/update.js b/update.js
index a98add9..a92fb22 100644
--- a/update.js
+++ b/update.js
@@ -125,13 +125,40 @@ module.exports = {
}
},
// Pin mflux to the exact version our FBCache patch is line-targeted
- // against (0.17.5). --force-reinstall + --no-deps so we don't churn
- // unrelated packages. If a future bump is needed, change the pin here
+ // against (0.17.5). If a future bump is needed, change the pin here
// AND in install_qwen.js AND re-validate patch_mflux_fbcache.py.
+ //
+ // Two-step shape mirrors install_qwen.js (the previous single-step
+ // `--force-reinstall --no-deps` could leave mflux's transitive deps
+ // MISSING after this update ran — the panel would show Qwen as
+ // available, then runtime would ImportError on first call).
+ //
+ // Gated on "is mflux already installed?" because update.js runs for
+ // every user on every update — including ones who never opted into
+ // Qwen via install_qwen.js. Importing mflux is the cheapest probe
+ // we can do without touching pip. The patch step below is already
+ // idempotent (skips when its marker is present); the install step
+ // we gate is the one that materially adds packages to the venv.
{
method: "shell.run",
params: {
- message: "./ltx-2-mlx/env/bin/pip install --force-reinstall --no-deps 'mflux==0.17.5'"
+ message: [
+ // Step 1: probe. If mflux isn't already on the venv, skip the
+ // whole repair block — user didn't install Qwen, don't add it
+ // on their behalf.
+ "if ./ltx-2-mlx/env/bin/python -c 'import mflux' 2>/dev/null; then \\",
+ " echo 'mflux present — refreshing pin to 0.17.5 with deps to repair any missing transitive packages…' && \\",
+ // Step 2: install WITH deps so pip resolves the full transitive
+ // set (transformers, accelerate, sentencepiece, etc.). Repairs
+ // any user whose previous --no-deps install left deps missing.
+ " ./ltx-2-mlx/env/bin/pip install 'mflux==0.17.5' && \\",
+ // Step 3: force-reinstall WITHOUT deps to lock the version
+ // without churning the deps we just installed.
+ " ./ltx-2-mlx/env/bin/pip install --force-reinstall --no-deps 'mflux==0.17.5'; \\",
+ "else \\",
+ " echo 'mflux not installed (user never opted into Qwen image gen) — skipping mflux repair.'; \\",
+ "fi"
+ ].join("\n")
}
},
// Re-apply patches. Codec patch is required; I2V OOM patch is a no-op