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
Simplify the Video Gen model-picker loading path
[._.]/ Adam Eivy19be5faccc6b
diff --git a/client/src/components/ModelSelect.jsx b/client/src/components/ModelSelect.jsxindex a88aa48e90..0345819988 100644--- a/client/src/components/ModelSelect.jsx+++ b/client/src/components/ModelSelect.jsx@@ -10,11 +10,9 @@// ProviderModelSelector's `emptyModelOption`). `ariaLabel` / `title` let an// inline picker with no visible <label> stay accessible.//-// `loading` renders the picker as a disabled placeholder ("Loading models…")-// instead of an empty select. Model lists come from a probe that can take a-// second or two, and a caller that hides the whole field until it lands makes-// the form jump when it does — so hold the field's place and say why it's-// empty. `loadingLabel` customizes the placeholder text.+// `loading` swaps the options for a disabled "Loading models…" placeholder, so+// a caller whose list arrives from a slow probe can keep the field (and its+// label) in the form instead of letting it pop in late.const defaultGetLabel = (m) => m.name;export default function ModelSelect({models,@@ -28,42 +26,30 @@ export default function ModelSelect({ariaLabel,title,loading = false,- loadingLabel = 'Loading models…',}) {- if (loading) {- return (- <select- id={id}- value=""- disabled- aria-busy="true"- aria-label={ariaLabel}- title={title}- className={className}- onChange={onChange}- >- <option value="">{loadingLabel}</option>- </select>- );- }const active = models.filter((m) => !m.deprecated);const legacy = models.filter((m) => m.deprecated);return (<selectid={id}- value={value}+ value={loading ? '' : value}onChange={onChange}- disabled={disabled}+ disabled={disabled || loading}+ aria-busy={loading || undefined}aria-label={ariaLabel}title={title}className={className}>- {emptyOption != null && <option value="">{emptyOption}</option>}- {active.map((m) => <option key={m.id} value={m.id}>{getLabel(m)}</option>)}- {legacy.length > 0 && (- <optgroup label="Legacy">- {legacy.map((m) => <option key={m.id} value={m.id}>{getLabel(m)}</option>)}- </optgroup>+ {loading ? <option value="">Loading models…</option> : (+ <>+ {emptyOption != null && <option value="">{emptyOption}</option>}+ {active.map((m) => <option key={m.id} value={m.id}>{getLabel(m)}</option>)}+ {legacy.length > 0 && (+ <optgroup label="Legacy">+ {legacy.map((m) => <option key={m.id} value={m.id}>{getLabel(m)}</option>)}+ </optgroup>+ )}+ </>)}</select>);diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 6f41f39360..85791e1259 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -80,7 +80,7 @@ grep -i "what you want to do" client/src/lib/README.md| `videoFinish.js` | Finish-a-draft gate (#3696). `isReproducibleTextToVideo(record)` is true only for a single text-to-video render whose history record already carries everything a re-render needs — `renderInputsVersion` (the positive marker that its conditioning inventory is trustworthy, so legacy records degrade to not-finishable rather than reading as unconditioned), an empty `conditioning` array, a resolved seed, a real prompt, and no stitched/chained/upscaled provenance. `finishTargetForRecord(record, models)` additionally resolves the draft model's server-declared `finishModelId` against the models this install can actually run, returning the delivery model entry or `null`. `isDeliveryVideoModel(model, models)` is the other end of the same graph — true when some entry names `model` as its `finishModelId`, which is what makes a delivery render always decode on the full decoder (#5423). Mirrors `finishTargetForModel` / `isDeliveryVideoModel` in `server/lib/videoFinishProfiles.js`; the pair table itself stays server-side. || `videoGenParams.js` | Pure VideoGen param helpers: `FRAME_OPTIONS`/`FPS_OPTIONS`/`VIDEO_EDGE_BOUNDS`/`MAX_CHUNKS`/`CHUNK_OPTIONS`/`DEFAULT_CONTEXT_FRAMES`/`CONTEXT_FRAME_OPTIONS` constants, model-aware frame/fps/resolution-grid normalization, separate mute vs prompt-audio capability checks, `supportsContextWindow(model)` (does this runtime have an extend pipeline to feed a continuation window to — display mirror of `server/lib/videoContinuity.js`, pinned by `server/lib/videoContinuity.parity.test.js`), `videoModelMemoryGb()` (model memory footprint), `selectVideoMemoryProfile(model, systemMemoryGb)` + `VIDEO_MEMORY_RESERVE_GB` (#5420 — which declared weight-placement profile this machine can actually hold, out of the `memoryProfiles` the server decorates onto the entry; the floors ride on the model so only the reserve is mirrored, and an unmeasured `systemMemoryGb` returns a `null` usable figure rather than reading as a box that is too small), `computeFflfSafeFrames()` (FFLF/ltx2 pixel-budget back-solve, mirrors `server/services/videoGen/local.js`), and `isModelAllowedForMode()` (a2v uses the shared audio-runtime capability; IC remix remains LTX-only). Speed profiles (#4875) mirror the conditioner shape: `DEFAULT_SPEED_PROFILE_ID` (must equal `SPEED_PROFILE_DEFAULT_ID` in `server/lib/videoSpeedProfiles.js` — absence and `'quality'` are the same request), `isDefaultSpeedProfileId()` mirrors the server's absence-is-the-default rule, `speedProfilesForModel()` reads the server-decorated `speedProfiles` off the entry, `speedProfilesForMode(model, mode)` applies the SAME mode gate the server's `speedProfileDeclineReason` does (so a profile the server would decline is never offered, nor allowed to lock the dials), `normalizeSpeedProfileForModel()` snaps a selection onto what a just-switched model declares (mode-independent, so switching to fflf hides the picker without rewriting the choice), `speedProfileIdFromRecord()` reads one back out of a history entry / resumed job, `selectedSpeedProfile(id, model, mode)` resolves the profile actually driving the render — what the picker shows and what disables Steps+CFG — and `videoChainChunkModes({ model, mode, chaining, contextFrames, hasSourceImage })` derives the modes a CHAINED request’s chunks will run in (chunk 0 the request’s, chunks 1+ `extend` on a window-continuity chain or `image` on a frame hop), mirroring `generateChainedVideo`’s dispatch and `resolveContinuityStrategy`; `resolveContextFramesForDisplay()` is the absent/invalid→`DEFAULT_CONTEXT_FRAMES` half of `resolveContextFrames` that gate depends on. All pinned by `server/lib/videoSpeedProfiles.parity.test.js`. Also mirrors the IC-LoRA remix registry (`IC_LORA_MODES`/`IC_LORA_MODE_VALUES`/`isIcLoraMode()`/`icLoraSpecForMode()`/`icResolutionIssue()`) from `server/lib/icLoraWeights.js` so the form validates a reference render pre-submit — pinned by `server/lib/icLoraWeights.parity.test.js`. || `videoGenResolutions.js` | Shared resolution presets/default for video generation, model-specific preset/default resolvers (for native canvases such as MiniMax H3), and `snapAspectToImage()` to pick the closest-aspect preset for an I2V source. |-| `videoGenStatusCache.js` | Session-scoped cache of the `GET /api/video-gen/status` payload (`readCachedVideoGenStatus` / `writeCachedVideoGenStatus` / `VIDEO_GEN_STATUS_CACHE_KEY`). The probe shells out to python and rebuilds the hardware-aware model list on every call, so the Video Gen Model picker would otherwise have nothing to render for a second or two on each page load. The read comes back marked `stale: true` and is trusted only for the model list and the model-shaping numbers (`defaultModel`, `systemMemoryGb`, pixel budget) — connectivity claims stay keyed on the live probe, so a python interpreter the user just fixed or broke is never reported from a stored answer. |+| `videoGenStatusCache.js` | Session-scoped cache of the model-shaping half of `GET /api/video-gen/status` (`readCachedVideoGenStatus` / `writeCachedVideoGenStatus` / `VIDEO_GEN_STATUS_CACHE_KEY`), so the Video Gen Model picker paints from the previous answer instead of waiting on the python probe behind that route. Stores only the model list plus `defaultModel` / `systemMemoryGb` and hands them back marked `stale: true`; every python-health field is dropped rather than guarded, so a stored answer can never report connectivity. || `videoGenSubmission.js` | Builds the local, Grok, and federated video-generation request bodies from validated form state, including prompt envelopes and empty-value wire sentinels. || `videoReferenceModes.js` | Mirror of `server/lib/videoReferenceModes.js` (parity enforced by `server/lib/videoReferenceModes.mirror.test.js`) — the i2v reference-mode contract: `I2V_REFERENCE_MODES`, `I2V_REFERENCE_MODE_OPTIONS` (label + the promise sentence `AdvancedParamsPanel` and the source-frame note print), `runtimeSupportsI2vReferenceMode` (gates which options the picker offers), `resolveI2vReferenceStrength` (the effective strength the panel displays), and `i2vReferenceModeViolation` for pre-submit feedback. || `videoStagePreview.js` | VideoGen main-stage preview resolver (#4588). `resolveVideoStagePreview({ generating, width, height, result, extendSource, sourceImageFile/Url, lastImageFile/Url, keyframes })` → `{ kind: 'loop'|'still'|'result'|'empty', src, poster, label, aspectRatio }` — conditioning media while a render runs and the finished clip once it lands; transient runner frames are intentionally excluded. Plus `videoStageAspectRatio()` (a NUMBER for an inline `aspect-ratio` style — a computed Tailwind `aspect-[w/h]` class never reaches the JIT build; `null` means unknown geometry, not 16:9) and `videoStageSignature()` for the hold/return guard in `components/videoGen/LiveVideoStage.jsx`. |diff --git a/client/src/lib/videoGenStatusCache.js b/client/src/lib/videoGenStatusCache.jsindex 70e0828b6e..d8fd1c6211 100644--- a/client/src/lib/videoGenStatusCache.js+++ b/client/src/lib/videoGenStatusCache.js@@ -1,17 +1,17 @@/**- * Session-scoped cache of the `GET /api/video-gen/status` payload.+ * Session-scoped cache of the model-shaping half of `GET /api/video-gen/status`.** That probe shells out to python and rebuilds the hardware-aware model list on* every call, so a cold Video Gen page load leaves the Model picker with nothing- * to render for a second or two. Caching the last payload lets the picker paint- * from the previous answer while the live probe revalidates behind it.+ * to render for a second or two. Caching lets the picker paint from the previous+ * answer while the live probe revalidates behind it.*- * The cached copy comes back marked `stale: true`, and callers must honour that:- * it is trusted only for the model list and the model-shaping numbers- * (`defaultModel`, `systemMemoryGb`, the pixel budget). Connectivity claims —- * `connected`, `missingPackages`, the "install missing packages" banner — stay- * keyed on the live probe, because a python interpreter the user just fixed (or- * just broke) must never be reported from a stored answer.+ * Only `CACHED_FIELDS` is stored, and the read hands it back marked+ * `stale: true`. Everything the payload says about python health — `connected`,+ * `reason`, `missingPackages`, `pythonPath`, `byovRuntimes`, `runtime` — is+ * deliberately dropped rather than guarded, because an interpreter the user just+ * fixed (or just broke) must never be reported from a stored answer, and a field+ * that isn't there can't be read by mistake.** Session, not local: the model registry and the python environment both move* with an upgrade or an install, and a payload kept for weeks would outlive@@ -19,24 +19,25 @@*/import { safeReadJsonSession, safeWriteJsonSession } from './safeStorage.js';-// Bump the suffix when the shape the page reads out of this changes, so an-// older tab's entry is ignored rather than half-read.+// Bump the suffix when `CACHED_FIELDS` changes, so an older tab's entry is+// ignored rather than half-read.export const VIDEO_GEN_STATUS_CACHE_KEY = 'portos.videoGenStatus.v1';-// Returns the cached payload with `stale: true`, or null when nothing usable is-// stored. A payload with no `models` array is worthless here — the whole point-// is painting the picker — so it reads as absent.+// The model list plus the numbers that decide which model is selected for it.+const CACHED_FIELDS = ['models', 'defaultModel', 'systemMemoryGb'];++// Returns the cached fields with `stale: true`, or null when nothing usable is+// stored. An entry with no `models` array is worthless here — painting the+// picker is the whole point — so it reads as absent.export const readCachedVideoGenStatus = () => {const cached = safeReadJsonSession(VIDEO_GEN_STATUS_CACHE_KEY);if (!cached || typeof cached !== 'object' || !Array.isArray(cached.models)) return null;return { ...cached, stale: true };};-// Store a freshly fetched payload. Never persists the `stale` marker: what is-// written here is by definition the live answer, and it is read back as stale.+// Store the cacheable slice of a freshly fetched payload.export const writeCachedVideoGenStatus = (status) => {if (!status || typeof status !== 'object' || !Array.isArray(status.models)) return;- // `stale: undefined` is dropped by JSON.stringify, so a payload that somehow- // round-tripped through the reader can't be stored as if it were fresh.- safeWriteJsonSession(VIDEO_GEN_STATUS_CACHE_KEY, { ...status, stale: undefined });+ const slice = Object.fromEntries(CACHED_FIELDS.map((field) => [field, status[field]]));+ safeWriteJsonSession(VIDEO_GEN_STATUS_CACHE_KEY, slice);};diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 2a2f23c802..2de0774e4e 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -122,11 +122,10 @@ export default function VideoGen() {refreshGrokEnabled();};- // Paint from the previous /status answer while the live probe runs (it shells- // out to python and rebuilds the hardware-aware model list on every call).- // The cached copy carries `stale: true` and feeds ONLY the model list and the- // model-shaping numbers — every connectivity claim below gates on- // `statusFresh`, so a stale payload can never report python health.+ // Paint the model picker from the previous /status answer while the live+ // probe runs. The cached entry carries `stale: true` and holds nothing but+ // the model-shaping fields (see lib/videoGenStatusCache.js); connectivity UI+ // below gates on `statusFresh`.const [status, setStatus] = useState(readCachedVideoGenStatus);const [statusLoading, setStatusLoading] = useState(true);// Grok Build CLI video backend (#2859 phase 2) — surfaced only when the@@ -807,10 +806,15 @@ export default function VideoGen() {// `byovRuntimeMissing` for those models. Without this, a user who installed// ONLY a BYOV runtime via the modal would stay stuck behind a "not// configured" error from the unrelated legacy probe.- // A cached payload says nothing trustworthy about python health, so every- // connectivity read below waits for the live probe rather than reporting the- // interpreter state of whenever the last visit happened.+ // A cached entry says nothing about python health, so the connectivity UI+ // waits for the live probe rather than reporting the interpreter state of+ // whenever the last visit happened.const statusFresh = !!status && !status.stale;+ // The Model field renders as soon as there is anything to say — the list, or+ // the fact that it is still being probed. Only a finished probe that named no+ // model at all takes the field away.+ const modelsLoading = models.length === 0;+ const modelFieldVisible = !modelsLoading || statusLoading;const notConnected = statusFresh && status.connected === false && !needsByovProbe;// A federated render answers to the PEER’s readiness, not to this machine’s@@ -1250,17 +1254,15 @@ export default function VideoGen() {<div className="grid grid-cols-2 sm:grid-cols-3 gap-3">{/* The peer advertises its own models; the local list would namenone of them, and a stale selection here must not read as the- model that rendered the clip. */}- {/* The list arrives with /status, which probes python — keep the- field (and its label) in place with a loading placeholder rather- than letting it pop into the form a second or two later. */}- {(models.length > 0 || statusLoading) && !remoteTarget.isRemote && (+ model that rendered the clip. Locally the field holds its place+ through the probe rather than popping into the form late. */}+ {modelFieldVisible && !remoteTarget.isRemote && (<FormField className="col-span-2 sm:col-span-3" label="Model" labelClassName="block text-xs font-medium text-gray-400 mb-1"><ModelSelectmodels={visibleModels}value={modelId}onChange={(e) => handleModelChange(e.target.value)}- loading={models.length === 0}+ loading={modelsLoading}/>{remixModelFallback && (<p className="mt-1 text-[11px] text-port-accent leading-snug" role="status">diff --git a/client/src/pages/VideoGen.modelLoading.test.jsx b/client/src/pages/VideoGen.modelLoading.test.jsxindex c8cc055d38..387fde79d2 100644--- a/client/src/pages/VideoGen.modelLoading.test.jsx+++ b/client/src/pages/VideoGen.modelLoading.test.jsx@@ -165,9 +165,6 @@ describe('VideoGen model picker while /status is in flight', () => {localStorage.clear();sessionStorage.clear();state.modelStatuses = {};- state.generateVideo.mockReset().mockResolvedValue({ jobId: 'job-1' });- state.startDownload.mockReset();- state.repairModel.mockReset().mockResolvedValue({ ok: true });state.getVideoGenStatus.mockReset().mockResolvedValue(statusPayload());state.eventSourceRef.current = null;state.attach.mockReset().mockResolvedValue({ filename: 'example.mp4' });@@ -190,22 +187,24 @@ describe('VideoGen model picker while /status is in flight', () => {it('paints the cached model list on the next load instead of waiting for the probe', async () => {const first = await renderPage();await waitFor(() => expect(screen.getByLabelText('Model')).toHaveValue(MODEL_ONE.id));- expect(JSON.parse(sessionStorage.getItem(VIDEO_GEN_STATUS_CACHE_KEY)).models).toHaveLength(2);+ // Only the model-shaping slice is persisted — python health never is.+ expect(Object.keys(JSON.parse(sessionStorage.getItem(VIDEO_GEN_STATUS_CACHE_KEY))).sort())+ .toEqual(['defaultModel', 'models', 'systemMemoryGb']);first.unmount();const resolveStatus = deferredStatus();await renderPage();- // Second visit, probe still in flight: the picker is already populated.const field = screen.getByLabelText('Model');expect(field).toBeEnabled();expect(field).toHaveValue(MODEL_ONE.id);await resolveStatus(statusPayload());});- it('never reports python health from the cached payload', async () => {- // A stored payload whose probe FAILED. The model list may come from it; the- // diagnosis may not — the interpreter can have been fixed since.+ it('never reports python health from a cached entry', async () => {+ // A hand-written entry carrying a FAILED probe — the belt to the+ // projection's braces. The model list may come from storage; the diagnosis+ // may not, because the interpreter can have been fixed since.sessionStorage.setItem(VIDEO_GEN_STATUS_CACHE_KEY, JSON.stringify(statusPayload({connected: false,reason: 'Python probe failed',