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
fix: visible loading feedback on Image Gen backend switcher
Adam Eivy3edd09df8b06
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex bb09c8b093..1de199a275 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -20,6 +20,7 @@## Fixed+- **Image Gen backend switcher no longer feels frozen mid-check.** Clicking Local / Codex / External in the backend chip strip kicks off a status probe (e.g. SD API reachability for External, codex CLI version for Codex) — the buttons were already correctly `disabled` during the probe, but there was no visible feedback so the UI just felt unresponsive while the request was in flight. The clicked chip now swaps its icon for a spinning `Loader2`, the tooltip flips to "Checking <label>…", and the status badge to the left shows "🔄 Checking <mode>…" instead of stale state from the previous backend. `BackendChipStrip` gains an optional `loadingId` prop (default `null`) — existing consumers (WorldBuilder, Storyboard) keep their current behavior.- **mflux corrupted-install detection.** When mflux's entry-point shim references `mflux.models.flux.cli.flux_generate` but the importable `mflux/` package on disk is stuck at an older layout (file tree out of sync with the dist-info — easy to hit when `~/.local/lib/python*/site-packages/mflux/` and a conda-env mflux both exist at version 0.12.1 but were installed at different repackaging stages), the runner crashed with bare "Exit code 1" and a Python `ModuleNotFoundError`. PortOS now detects that specific traceback in the runner's stderr and surfaces an actionable message explaining the cause and the exact `pip uninstall -y mflux && pip install --user --force-reinstall --no-cache-dir --no-deps mflux` repair command. `scripts/setup-image-video.sh` also now passes `--force-reinstall --no-deps` on the mflux install so subsequent setup runs flush the package's file tree without re-resolving torch/mlx and friends — heading off the divergence at the source.- **Guidance input hidden for distilled image models; runner stops emitting "Guidance scale X is ignored" warnings.** Step-wise distilled image models (Flux 1 Schnell, FLUX.2 Klein 4B/9B/Int8, Z-Image-Turbo) bake classifier-free guidance internally — any guidance scale > 1.0 is silently dropped by diffusers, which logs a noisy `"Guidance scale 7.0 is ignored for step-wise distilled models."` line on every render. The registry now flags those entries with `cfgDisabled: true` (backfilled on existing installs by id, in `server/lib/mediaModels.js → backfillCfgDisabled`), the Image Gen / World Builder Guidance input is hidden when the selected model has the flag set, and `server/services/imageGen/local.js` pins the resolved guidance to `1.0` for cfgDisabled models so the runner's diffusers call stays quiet and the saved metadata sidecar reflects the value the model actually used. Any user override of `cfgDisabled` (true OR false) on a custom registry entry wins.- **World Builder expansion no longer 0-variations on Codex CLI responses.** The expand-starter step had three failure modes against Codex's CLI provider that all manifested as "Expanded into 0 variations": (1) Codex echoes the user prompt back to stdout before the model's reply, and the prompt itself contains a JSON-shaped *schema example* (`{ "label": string (max 80 chars), "prompt": … }`) — its braces balance but its contents are not valid JSON, so the previous first-balanced-block extractor crashed on it; (2) Codex occasionally emits an orphan `}` between a variation's close-brace and the array's `]` (`…blister"}}]}}}`), making `JSON.parse` throw on otherwise-recoverable output; (3) some prompt variants embed small literal `{ "label": …, "prompt": … }` example variations that parse cleanly but are not the response, so the extractor would happily return the wrong object. `extractJson` now (a) walks every top-level brace-balanced block and tries each in order, (b) prefers a block that has any of `stylePrompt` / `negativePrompt` / `categories` at the top level over an example-shaped one, and (c) attempts cheap repairs for trailing commas and the orphan-brace `}}]` → `}]` corruption before giving up. The expand path also logs the toolkit `runId` plus per-category variation counts so a 0-variation outcome is debuggable from `data/runs/<id>/output.txt`. Four new tests cover the Codex prompt-echo, orphan-brace, trailing-comma, and shape-preference cases.diff --git a/client/src/components/media/BackendChipStrip.jsx b/client/src/components/media/BackendChipStrip.jsxindex 7d7970e827..dbcf5aafd2 100644--- a/client/src/components/media/BackendChipStrip.jsx+++ b/client/src/components/media/BackendChipStrip.jsx@@ -2,6 +2,8 @@// Room storyboard config. `size="md"` matches the standalone Image Gen// page; `size="sm"` matches the storyboard's denser config tab.+import { Loader2 } from 'lucide-react';+const SIZES = {sm: 'px-2 py-0.5 text-[10px]',md: 'px-2.5 py-1 text-xs',@@ -15,24 +17,30 @@ export default function BackendChipStrip({size = 'md',ariaLabel = 'Backend',titlePrefix = 'Use',+ loadingId = null,}) {if (!availableBackends?.length) return null;const sizeCls = SIZES[size] || SIZES.md;return (<div className="inline-flex items-center gap-1 p-0.5 border border-port-border rounded-full bg-port-bg" role="group" aria-label={ariaLabel}>- {availableBackends.map(({ id, label, icon: Icon }) => (- <button- key={id}- type="button"- onClick={() => onChange?.(id)}- disabled={disabled}- className={`inline-flex items-center gap-1 rounded-full transition-colors disabled:opacity-50 ${sizeCls} ${value === id ? 'bg-port-accent text-white' : 'text-gray-400 hover:text-white hover:bg-port-border/40'}`}- title={`${titlePrefix} ${label}`}- >- <Icon className="w-3 h-3" />- {label}- </button>- ))}+ {availableBackends.map(({ id, label, icon: Icon }) => {+ const isLoading = loadingId === id;+ const isSelected = value === id;+ return (+ <button+ key={id}+ type="button"+ onClick={() => onChange?.(id)}+ disabled={disabled}+ aria-busy={isLoading || undefined}+ className={`inline-flex items-center gap-1 rounded-full transition-colors disabled:opacity-50 ${sizeCls} ${isSelected ? 'bg-port-accent text-white' : 'text-gray-400 hover:text-white hover:bg-port-border/40'}`}+ title={isLoading ? `Checking ${label}…` : `${titlePrefix} ${label}`}+ >+ {isLoading ? <Loader2 className="w-3 h-3 animate-spin" /> : <Icon className="w-3 h-3" />}+ {label}+ </button>+ );+ })}</div>);}diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsxindex 6190164d83..b30d9086a0 100644--- a/client/src/pages/ImageGen.jsx+++ b/client/src/pages/ImageGen.jsx@@ -700,7 +700,11 @@ export default function ImageGen() {<div className="space-y-3"><div className="flex items-center justify-between gap-2 text-xs"><div className="flex items-center gap-2 flex-wrap">- {status ? (+ {statusLoading ? (+ <span className="inline-flex items-center gap-1.5 px-2 py-1 rounded-full border border-port-border bg-port-card text-gray-400">+ <RefreshCw className="w-3 h-3 animate-spin" /> Checking {effectiveMode}…+ </span>+ ) : status ? (<span className={`inline-flex items-center gap-1.5 px-2 py-1 rounded-full border ${status.connected? 'border-port-success/40 bg-port-success/10 text-port-success'@@ -725,6 +729,7 @@ export default function ImageGen() {value={effectiveMode}onChange={setSelectedMode}disabled={statusLoading}+ loadingId={statusLoading ? effectiveMode : null}titlePrefix="Use"/>)}