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.
Python ai-filmmakingai-videoai-video-generatorapple-siliconhailuoimage-to-videolip-synclocal-ailora-trainingltx-2ltx-2-5ltx-videomacosminimax-h3mlxmusic-generationoffline-aipinokiotext-to-videovideo-generation
feat(agent): mflux + Flux Krea backend for image gen + fullscreen focus mode
mrbizarro0a3c1b97c2ce
diff --git a/agent/image_engine.py b/agent/image_engine.pyindex 912479c..80d9c41 100644--- a/agent/image_engine.py+++ b/agent/image_engine.py@@ -45,11 +45,25 @@ class ImageEngineConfig:GET masks `bfl_api_key` (returns `has_bfl_api_key` bool only)."""- kind: str = "mock" # "mock" | "bfl"+ kind: str = "mock" # "mock" | "mflux" | "bfl"++ # BFL (cloud)bfl_api_key: str = ""- bfl_model: str = "flux-dev" # flux-dev | flux-pro | flux-schnell+ bfl_model: str = "flux-dev" # flux-dev | flux-pro | flux-pro-1.1 | flux-schnellbfl_base_url: str = "https://api.bfl.ml/v1"+ # mflux (local, MLX-native — `pip install mflux`)+ # `mflux_model` accepts either a named shorthand the CLI understands+ # ("krea-dev", "dev", "schnell", "dev-fill") OR a HF repo id / local+ # path (e.g. "filipstrand/FLUX.1-Krea-dev-mflux-4bit"). When the value+ # is a path, `mflux_base_model` MUST be set (krea-dev / dev / schnell)+ # so mflux knows the architecture to instantiate.+ mflux_model: str = "krea-dev"+ mflux_base_model: str = "" # only needed when mflux_model is a path/HF id+ mflux_steps: int = 25 # 25 for dev/krea, 4 for schnell+ mflux_quantize: int = 4 # 4 | 8 | 16 — 4-bit fits comfortably on 64 GB+ mflux_python_path: str = "" # optional override for `mflux-generate` location+def to_public_dict(self) -> dict:d = asdict(self)if d.get("bfl_api_key"):@@ -86,6 +100,8 @@ def generate(*, prompt: str, n: int, output_dir: Path,if config.kind == "mock":return _generate_mock(prompt, n, width, height, output_dir, base_seed)+ if config.kind == "mflux":+ return _generate_mflux(prompt, n, width, height, output_dir, base_seed, config)if config.kind == "bfl":return _generate_bfl(prompt, n, width, height, output_dir, base_seed, config)raise ValueError(f"unknown image engine kind: {config.kind!r}")@@ -99,6 +115,12 @@ def health_check(config: ImageEngineConfig) -> tuple[bool, str]:return True, "mock engine ready (PIL available)"except ImportError:return False, "PIL not installed — pip install Pillow"+ if config.kind == "mflux":+ bin_path = _resolve_mflux_bin(config)+ if not bin_path:+ return False, ("mflux not installed. Run: "+ "ltx-2-mlx/env/bin/pip install mflux")+ return True, f"mflux ready at {bin_path}; model={config.mflux_model}"if config.kind == "bfl":if not config.bfl_api_key:return False, "BFL API key not configured"@@ -106,6 +128,32 @@ def health_check(config: ImageEngineConfig) -> tuple[bool, str]:return False, f"unknown engine kind: {config.kind!r}"+def _resolve_mflux_bin(config: ImageEngineConfig) -> str | None:+ """Find the `mflux-generate` executable.++ Order:+ 1. config.mflux_python_path (explicit override — useful when mflux+ is installed in a venv outside the panel's standard location)+ 2. The Phosphene panel's bundled venv (ltx-2-mlx/env/bin/mflux-generate)+ 3. shutil.which("mflux-generate") — system PATH fallback+ """+ import os+ import shutil++ if config.mflux_python_path:+ cand = Path(config.mflux_python_path)+ if cand.is_file() and os.access(cand, os.X_OK):+ return str(cand)++ repo_root = Path(__file__).resolve().parent.parent+ panel_venv_bin = repo_root / "ltx-2-mlx" / "env" / "bin" / "mflux-generate"+ if panel_venv_bin.is_file() and os.access(panel_venv_bin, os.X_OK):+ return str(panel_venv_bin)++ found = shutil.which("mflux-generate")+ return found++# ---- Backends ---------------------------------------------------------------def _generate_mock(prompt: str, n: int, width: int, height: int,output_dir: Path, base_seed: int | None) -> list[dict]:@@ -178,6 +226,97 @@ def _generate_mock(prompt: str, n: int, width: int, height: int,return results+def _generate_mflux(prompt: str, n: int, width: int, height: int,+ output_dir: Path, base_seed: int | None,+ config: ImageEngineConfig) -> list[dict]:+ """Subprocess `mflux-generate` once per candidate.++ Loads the model fresh on every call (mflux's CLI doesn't keep it+ warm), so first call eats ~10-30 s of model-load time per+ candidate. For batch generation this is the simplest path; if it+ becomes a real bottleneck, swap in a long-lived `mflux_warm_helper.py`+ subprocess that mirrors `mlx_warm_helper.py`.++ Recommended model: **Flux Krea Dev** (`krea-dev`) — Krea AI's+ fine-tune of Flux.1 Dev, generally regarded as the best+ photorealistic Flux variant. Particularly strong for documentary /+ interview / sterile-clinic looks the agent gravitates toward. The+ mflux 4-bit weights ship at filipstrand/FLUX.1-Krea-dev-mflux-4bit.+ First run downloads ~6 GB to ~/.cache/huggingface.+ """+ import os+ import subprocess++ bin_path = _resolve_mflux_bin(config)+ if not bin_path:+ raise RuntimeError(+ "mflux-generate not found. Install mflux into the panel's "+ "venv: `ltx-2-mlx/env/bin/pip install mflux` "+ "(see docs/AGENTIC_FLOWS.md § Image generation backends). "+ "First-run model download is ~6 GB."+ )++ results: list[dict] = []+ for i in range(n):+ seed = (base_seed + i) if base_seed is not None else None+ out_path = output_dir / f"cand_{i:02d}_mflux.png"+ cmd = [+ bin_path,+ "--model", config.mflux_model,+ "--prompt", prompt,+ "--output", str(out_path),+ "--steps", str(config.mflux_steps),+ "--width", str(width),+ "--height", str(height),+ "-q", str(config.mflux_quantize),+ ]+ if seed is not None:+ cmd.extend(["--seed", str(seed)])+ # When `--model` is a HuggingFace id or local path (i.e. contains+ # a slash or starts with `~` or `/`), mflux needs `--base-model`+ # to know which Flux architecture to instantiate.+ looks_like_path = ("/" in config.mflux_model+ or config.mflux_model.startswith("~"))+ if looks_like_path and config.mflux_base_model:+ cmd.extend(["--base-model", config.mflux_base_model])++ # Inherit env so HF_HOME / HF_TOKEN are honored for the+ # one-time weight download. Capture stderr so the user gets a+ # readable error if anything explodes.+ env = os.environ.copy()+ try:+ result = subprocess.run(+ cmd, capture_output=True, env=env, timeout=420,+ )+ except subprocess.TimeoutExpired as e:+ raise RuntimeError(+ f"mflux-generate timed out after 420s on candidate {i}. "+ f"First run downloads weights — give it longer for the "+ f"first candidate, or pre-download with: "+ f"`{bin_path} --model {config.mflux_model} "+ f"--prompt 'warmup' --steps 1 --output /tmp/_mflux_warmup.png`"+ ) from e+ if result.returncode != 0:+ err = result.stderr.decode("utf-8", errors="replace")+ raise RuntimeError(+ f"mflux-generate failed (exit {result.returncode}) "+ f"on candidate {i}: {err[:600]}"+ )+ if not out_path.is_file():+ raise RuntimeError(+ f"mflux-generate exited 0 but produced no file at {out_path}"+ )++ results.append({+ "png_path": str(out_path),+ "seed": seed if seed is not None else 0,+ "engine": "mflux",+ "model": config.mflux_model,+ "width": width, "height": height,+ })+ return results++def _generate_bfl(prompt: str, n: int, width: int, height: int,output_dir: Path, base_seed: int | None,config: ImageEngineConfig) -> list[dict]:diff --git a/docs/AGENTIC_FLOWS.md b/docs/AGENTIC_FLOWS.mdindex 07377f4..8d92f74 100644--- a/docs/AGENTIC_FLOWS.md+++ b/docs/AGENTIC_FLOWS.md@@ -15,26 +15,45 @@ Panel header → form-pane → top tab strip: **Manual | Agentic Flows**.Manual is the existing form. Agentic Flows is the new tab. Selectionpersists in localStorage.-## How a session goes--1. **You paste** a brief, an idea, or a full script. The composer is- one big textarea — Cmd/Ctrl+Enter sends.-2. **The agent plans in plain text first.** A numbered shot list with- one-line visual descriptions, durations, and a total wall-time- estimate. Nothing is queued yet.-3. **You approve.** "go", "queue it", "yes" — anything that reads as- confirmation. Tweak the plan in the chat first if you want.-4. **The agent submits each shot** by calling `submit_shot` on the- panel's existing `/queue/add` endpoint. Each submission produces a- tool-result chip in the chat with the job id and ETA.-5. **The agent writes a `manifest.json`** listing the queued shots in- cut order. Lands in `mlx_outputs/agentflow_<session_id>/`.-6. **The agent calls `finish`** — the loop ends and you're returned- control. The manual queue keeps rendering while you sleep.+## How a session goes (3-phase director loop)++The default workflow is collaboration: agent generates candidate+stills, you pick the best one per shot, agent renders videos with+your picks as i2v anchors. Locking the look BEFORE the 4-minute+video render dramatically reduces "guess and pray" t2v failures.++1. **Phase A — You paste** a brief, an idea, or a full script. The+ composer is one big textarea — Cmd/Ctrl+Enter sends.+2. **Agent plans in plain text** with a master style suffix, director's+ adjustments, numbered shot list. Nothing queued yet.+3. **Phase B — Agent generates anchor candidates.** For each shot it+ calls `generate_shot_images` (4 candidates default). Each call+ appears as a tool-result card with a thumbnail grid below. Click+ a thumbnail to pick — green border + checkmark. Selection persists+ in `session.tool_state.selected_anchors`.+4. **Phase C — You type "render".** Agent reads `get_selected_anchors`,+ submits each shot via `submit_shot` with `mode: "i2v"` and+ `ref_image_path: <picked anchor>`, writes `manifest.json`, calls+ `finish`. Renders run overnight on your locked anchors.++You can opt out of the anchor flow ("just t2v, skip the picker") for+abstract cutaways or fast tests, in which case the agent skips+phase B and submits straight to t2v.The agent intentionally does **not** auto-stitch the clips. It writesthe manifest; the cut belongs to you.+## Fullscreen / focus mode++Click the expand icon in the agent header (between the "+" new-chat+button and the gear) to spread the chat across the full window —+the panel header, bottom pane (Now/Queue/Recent/Logs), and workflow+tab strip all fold away. **Esc** exits. State persists in+localStorage so reopening the tab keeps you in fullscreen.++Useful when planning a long multi-shot piece: more vertical real+estate for the conversation, less chrome competing for attention.+## Engine optionsThe agent talks to any OpenAI-compatible chat endpoint. Three setups:@@ -146,6 +165,68 @@ agent/runtime.py└── loop until no action block OR finish OR max_steps```+## Image generation backends (Phase B)++The agent uses a pluggable image engine to generate anchor stills.+Configure under *Settings → Image generation*. Three backends ship:++### `mock` (default — zero setup)++Flat-colored PNGs drawn with PIL. Each candidate carries a+distinguishable hue + the prompt excerpt overlaid in white. Free,+instant, useful for testing the pick-flow without spending a dime.+Not for actual production renders — just verifies the UX.++### `mflux` — Phosphene Local Flux (recommended for local)++`mflux` is a MLX-native port of Flux that runs on Apple Silicon. It+ships with several Flux variants; **Flux Krea Dev** (`krea-dev`) is+the recommended default — Krea AI's fine-tune of Flux.1 Dev with+better photorealism, stronger documentary / interview / clinical+aesthetics. Particularly well-suited to the kinds of looks the agent+gravitates toward.++Install once into the panel's bundled venv:++```bash+ltx-2-mlx/env/bin/pip install mflux+```++That brings the `mflux-generate` CLI into `ltx-2-mlx/env/bin/` where+the panel auto-discovers it. First generate downloads the Krea Dev+4-bit weights to `~/.cache/huggingface` (~6 GB), one-time.++Performance on M4 Max 64 GB: ~25–60 s per image (model loads each+call — first candidate per shot is the slow one, subsequent ones+amortize once HF caches are warm). 4 candidates per shot ≈ 2–4 min.+12 shots ≈ 25–50 min for a complete plan's anchors.++Settings exposed:+- **Model**: `krea-dev` (recommended) / `dev` / `schnell` / Custom HF id+- **Custom path**: e.g. `filipstrand/FLUX.1-Krea-dev-mflux-4bit`+- **Base model**: required when Custom path is used (`krea-dev` /+ `dev` / `schnell`)+- **Steps**: 25 for dev/krea, 4 for schnell+- **Quantize**: 4 (~6 GB) or 8 (~12 GB, sharper)++### `bfl` — Black Forest Labs API (recommended for cloud)++The canonical Flux source. `flux-dev` ≈ $0.025/img, `flux-pro` ≈+$0.05, `flux-pro-1.1` ≈ $0.04, `flux-schnell` ≈ $0.003. Roughly+10–15 s per image. Get a key at `https://api.bfl.ml`; paste into+*Settings → Image generation → BFL API key*. Stored in+`state/agent_image_config.json`, only sent as the `X-Key` header.++### Future backends++The interface is open — `_generate_<kind>()` in+`agent/image_engine.py` is the only place to add. Likely candidates:++- **DiffusionKit / CoreML** for ANE acceleration (~10 s / image, fully+ local). Heavier install (CoreML model conversion).+- **Replicate** API (mirrors BFL flow + supports Flux Krea hosted)+- **fal.ai** API (very fast, generous trial credits)+## Known limitations + workarounds- **Bundled Gemma 3 12B IT is good at planning a shot list** but adiff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.pyindex e68dff7..ae0ee4c 100644--- a/mlx_ltx_panel.py+++ b/mlx_ltx_panel.py@@ -6894,6 +6894,52 @@ HTML = r"""<!doctype html>max-height: 80px; overflow-y: auto;}+ /* ---- Fullscreen / Focus mode ---- */+ /* Toggle via .agent-fullscreen on <body>. Hides every chrome+ element except the agent pane itself and pins the pane to the+ full viewport. ESC also exits. */+ body.agent-fullscreen header,+ body.agent-fullscreen .bottom-pane,+ body.agent-fullscreen .form-pane > :not(.agent-pane),+ body.agent-fullscreen .workflow-tabs {+ display: none !important;+ }+ body.agent-fullscreen .layout {+ max-width: none; padding: 0; margin: 0;+ height: 100vh;+ display: block;+ }+ body.agent-fullscreen .form-pane {+ max-width: none; padding: 0;+ width: 100vw; height: 100vh;+ }+ body.agent-fullscreen .agent-pane {+ width: min(960px, 100vw);+ margin: 0 auto;+ height: 100vh; max-height: 100vh;+ border-radius: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border);+ border-top: none; border-bottom: none;+ }+ body.agent-fullscreen .agent-chat {+ max-height: none;+ flex: 1;+ }+ /* Show a thin "Exit fullscreen" badge top-left when in fullscreen+ so the user always knows how to get out, even if they forget+ Esc. */+ body.agent-fullscreen::before {+ content: "Esc to exit fullscreen";+ position: fixed; top: 12px; left: 14px;+ z-index: 1000;+ font-size: 10px; letter-spacing: 0.5px;+ padding: 4px 9px;+ background: var(--panel); color: var(--muted);+ border: 1px solid var(--border);+ border-radius: 999px;+ pointer-events: none;+ opacity: 0.7;+ }+/* ---- Typing indicator ---- */.agent-typing-row {display: flex; gap: 12px;@@ -7221,6 +7267,21 @@ HTML = r"""<!doctype html><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg></button>+ <button type="button" class="icon-btn" id="agentFullscreenBtn"+ onclick="agentToggleFullscreen()" title="Expand to fullscreen (Esc to exit)">+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" id="agentFullscreenIconExpand">+ <polyline points="15 3 21 3 21 9"/>+ <polyline points="9 21 3 21 3 15"/>+ <line x1="21" y1="3" x2="14" y2="10"/>+ <line x1="3" y1="21" x2="10" y2="14"/>+ </svg>+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" id="agentFullscreenIconCollapse" style="display:none">+ <polyline points="4 14 10 14 10 20"/>+ <polyline points="20 10 14 10 14 4"/>+ <line x1="14" y1="10" x2="21" y2="3"/>+ <line x1="3" y1="21" x2="10" y2="14"/>+ </svg>+ </button><button type="button" class="icon-btn" onclick="openAgentSettings()" title="Settings"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle>@@ -8067,11 +8128,57 @@ HTML = r"""<!doctype html><div class="field"><label>Backend</label><select id="agentImageKind" onchange="agentImageKindChanged()">- <option value="mock">Mock (PIL placeholders, free, instant — for testing the flow)</option>- <option value="bfl">Black Forest Labs API (real Flux, ~$0.025/img on flux-dev)</option>+ <option value="mock">Mock — PIL placeholders, free, instant (for testing the flow)</option>+ <option value="mflux">Phosphene Local Flux (mflux + Flux Krea Dev) — fully on-Mac, free, ~25–60 s/img</option>+ <option value="bfl">Black Forest Labs API — cloud Flux, ~$0.025/img on flux-dev, ~10–15 s/img</option>+ </select>+ </div>++ <!-- mflux fields -->+ <div class="field" id="agentMfluxModelField" style="display:none">+ <label>mflux model</label>+ <select id="agentMfluxModel" onchange="agentMfluxModelChanged()">+ <option value="krea-dev">Flux Krea Dev — recommended (best photorealism)</option>+ <option value="dev">Flux.1 Dev — vanilla 28-step</option>+ <option value="schnell">Flux.1 Schnell — 4-step, fastest</option>+ <option value="__custom__">Custom HF id / local path…</option></select></div>+ <div class="field" id="agentMfluxCustomField" style="display:none">+ <label>Custom model (HF repo id or local path)</label>+ <input type="text" id="agentMfluxCustomPath" placeholder="filipstrand/FLUX.1-Krea-dev-mflux-4bit">+ <div style="margin-top:4px;font-size:11px;color:var(--muted)">+ Required when using a non-named model. mflux will download to <code>~/.cache/huggingface</code> on first use (~6 GB for Krea Dev 4-bit).+ </div>+ </div>+ <div class="field" id="agentMfluxBaseField" style="display:none">+ <label>Base model (when using custom path)</label>+ <select id="agentMfluxBaseModel">+ <option value="krea-dev">krea-dev</option>+ <option value="dev">dev</option>+ <option value="schnell">schnell</option>+ </select>+ </div>+ <div class="row" id="agentMfluxParamsField" style="display:none">+ <div class="field">+ <label>Steps</label>+ <input type="number" id="agentMfluxSteps" min="1" max="50" value="25">+ </div>+ <div class="field">+ <label>Quantize (bits)</label>+ <select id="agentMfluxQuantize">+ <option value="4">4-bit (~6 GB, recommended)</option>+ <option value="8">8-bit (~12 GB, sharper)</option>+ </select>+ </div>+ </div>+ <div class="hint" id="agentMfluxInstallHint" style="display:none">+ <strong>First-time setup:</strong> install mflux into the panel's venv with+ <code>ltx-2-mlx/env/bin/pip install mflux</code> (one-time, ~50 MB of code; weights download separately on first generate).+ Verify the install with <code>ltx-2-mlx/env/bin/mflux-generate --help</code>.+ </div>+ <!-- BFL fields --><div class="field" id="agentBflModelField" style="display:none"><label>BFL model</label><select id="agentBflModel">@@ -11876,6 +11983,20 @@ function openAgentSettings() {// Image-engine fieldsdocument.getElementById('agentImageKind').value = imgCfg.kind || 'mock';+ // mflux+ const namedMfluxModels = ['krea-dev', 'dev', 'schnell'];+ const mfModel = imgCfg.mflux_model || 'krea-dev';+ if (namedMfluxModels.includes(mfModel)) {+ document.getElementById('agentMfluxModel').value = mfModel;+ document.getElementById('agentMfluxCustomPath').value = '';+ } else {+ document.getElementById('agentMfluxModel').value = '__custom__';+ document.getElementById('agentMfluxCustomPath').value = mfModel;+ }+ document.getElementById('agentMfluxBaseModel').value = imgCfg.mflux_base_model || 'krea-dev';+ document.getElementById('agentMfluxSteps').value = imgCfg.mflux_steps || 25;+ document.getElementById('agentMfluxQuantize').value = String(imgCfg.mflux_quantize || 4);+ // BFLdocument.getElementById('agentBflModel').value = imgCfg.bfl_model || 'flux-dev';document.getElementById('agentBflKey').value = '';document.getElementById('agentBflKey').placeholder =@@ -11928,10 +12049,34 @@ function agentKindChanged() {function agentImageKindChanged() {const kind = document.getElementById('agentImageKind').value;+ // mflux fields+ const isMflux = kind === 'mflux';+ document.getElementById('agentMfluxModelField').style.display = isMflux ? '' : 'none';+ document.getElementById('agentMfluxParamsField').style.display = isMflux ? '' : 'none';+ document.getElementById('agentMfluxInstallHint').style.display = isMflux ? '' : 'none';+ if (isMflux) agentMfluxModelChanged();+ else {+ document.getElementById('agentMfluxCustomField').style.display = 'none';+ document.getElementById('agentMfluxBaseField').style.display = 'none';+ }+ // BFL fieldsdocument.getElementById('agentBflModelField').style.display = kind === 'bfl' ? '' : 'none';document.getElementById('agentBflKeyField').style.display = kind === 'bfl' ? '' : 'none';}+function agentMfluxModelChanged() {+ const v = document.getElementById('agentMfluxModel').value;+ const isCustom = v === '__custom__';+ document.getElementById('agentMfluxCustomField').style.display = isCustom ? '' : 'none';+ document.getElementById('agentMfluxBaseField').style.display = isCustom ? '' : 'none';+ // For schnell, drop the recommended steps to 4+ const stepsInput = document.getElementById('agentMfluxSteps');+ if (stepsInput && !stepsInput.dataset.userTouched) {+ if (v === 'schnell') stepsInput.value = 4;+ else if (v === 'krea-dev' || v === 'dev') stepsInput.value = 25;+ }+}+function agentLocalRefreshRow(local) {const pill = document.getElementById('agentLocalPill');const detail = document.getElementById('agentLocalDetail');@@ -12002,12 +12147,29 @@ async function agentSaveSettings() {}// Save image-engine config too (separate file).+ const imgKind = document.getElementById('agentImageKind').value;const imgPayload = {- kind: document.getElementById('agentImageKind').value,+ kind: imgKind,bfl_model: document.getElementById('agentBflModel').value,};const bk = (document.getElementById('agentBflKey').value || '').trim();if (bk) imgPayload.bfl_api_key = bk;+ // mflux fields (only meaningful when kind === 'mflux', but we save them+ // either way so the form retains the user's previous setup when they+ // toggle backends back and forth).+ const mfSel = document.getElementById('agentMfluxModel').value;+ if (mfSel === '__custom__') {+ const cp = (document.getElementById('agentMfluxCustomPath').value || '').trim();+ if (cp) {+ imgPayload.mflux_model = cp;+ imgPayload.mflux_base_model = document.getElementById('agentMfluxBaseModel').value;+ }+ } else {+ imgPayload.mflux_model = mfSel;+ imgPayload.mflux_base_model = '';+ }+ imgPayload.mflux_steps = parseInt(document.getElementById('agentMfluxSteps').value || '25', 10);+ imgPayload.mflux_quantize = parseInt(document.getElementById('agentMfluxQuantize').value || '4', 10);try {const ir = await fetch('/agent/image/config', {method: 'POST',@@ -12027,10 +12189,43 @@ async function agentSaveSettings() {await agentRefreshImageConfig();}+// ---- Fullscreen / focus mode ---------------------------------------------+function agentToggleFullscreen(force) {+ // `force === true` to enter, `false` to exit, undefined to toggle+ const cur = document.body.classList.contains('agent-fullscreen');+ const next = (typeof force === 'boolean') ? force : !cur;+ document.body.classList.toggle('agent-fullscreen', next);+ const btn = document.getElementById('agentFullscreenBtn');+ if (btn) btn.title = next ? 'Exit fullscreen (Esc)' : 'Expand to fullscreen';+ const ix = document.getElementById('agentFullscreenIconExpand');+ const iy = document.getElementById('agentFullscreenIconCollapse');+ if (ix) ix.style.display = next ? 'none' : '';+ if (iy) iy.style.display = next ? '' : 'none';+ try { localStorage.setItem('phos_agent_fullscreen', next ? '1' : ''); } catch(e) {}+ // After collapse animation settles, scroll chat to bottom so the+ // user keeps their place.+ requestAnimationFrame(() => {+ const chat = document.getElementById('agentChat');+ if (chat) chat.scrollTop = chat.scrollHeight;+ });+}++// Esc to exit fullscreen.+document.addEventListener('keydown', (e) => {+ if (e.key === 'Escape' && document.body.classList.contains('agent-fullscreen')) {+ agentToggleFullscreen(false);+ }+});+// Initial workflow tab restore from localStorage.try {const saved = localStorage.getItem('phos_workflow');if (saved === 'agent') workflowSwitch('agent');+ // Restore fullscreen state, but ONLY when the agent tab is the+ // active workflow — otherwise we'd hide the manual form too.+ if (localStorage.getItem('phos_agent_fullscreen') && saved === 'agent') {+ agentToggleFullscreen(true);+ }} catch(e) {}</script></body>