Skip to content

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

resolve the Universe Builder's render config through the same install ladder

[._.]/ Adam Eivy1d7a49c4e370
diff --git a/client/src/components/decks/DeckRenderControls.jsx b/client/src/components/decks/DeckRenderControls.jsx
index c9627fa48d..b59bcbd13c 100644
--- a/client/src/components/decks/DeckRenderControls.jsx
+++ b/client/src/components/decks/DeckRenderControls.jsx
@@ -158,6 +158,10 @@ export default function DeckRenderControls({
function CardSize({ kind, size, onPatch }) {
const kindDefault = DECK_CARD_SIZE_BY_KIND[kind] || DECK_CARD_SIZE;
const commit = (axis) => (raw) => {
+ // A cleared field is a mid-edit state, not a request for the 256px floor
+ // `clampImageEdge` would snap an empty string to. `useFieldDraft` drops the
+ // draft either way, so the input snaps back to the stored size.
+ if (String(raw).trim() === '') return;
const clamped = clampImageEdge(raw, SIZE_BOUNDS);
if (clamped !== size[axis]) onPatch({ cardSize: { ...size, [axis]: clamped } });
};
diff --git a/client/src/hooks/useImageRenderSettings.js b/client/src/hooks/useImageRenderSettings.js
index 5cd34f180b..f0ec6890e8 100644
--- a/client/src/hooks/useImageRenderSettings.js
+++ b/client/src/hooks/useImageRenderSettings.js
@@ -1,43 +1,20 @@
import { useState, useEffect, useMemo } from 'react';
import { getSettings } from '../services/api';
-import { IMAGE_RENDER_KNOB_DEFAULTS } from '../lib/pipelineImageDefaults';
-import {
- deriveAvailableBackends, IMAGE_GEN_MODE, installLocalModelId, LOCAL_IMAGEGEN_DEFAULT_MODEL,
- pickUsableMode, renderPinLadder, renderTargetPin, supportsCloudModelOverride,
-} from '../lib/imageGenBackends';
-
-// What the hook reports before the settings blob lands, and after a failed
-// fetch: the shipped knobs on the backend that is always usable. Frozen and
-// module-level so an unresolved hook hands every consumer the same identity
-// rather than a fresh object per render.
-const UNRESOLVED = Object.freeze({
- ...IMAGE_RENDER_KNOB_DEFAULTS,
- mode: IMAGE_GEN_MODE.LOCAL,
- modelId: LOCAL_IMAGEGEN_DEFAULT_MODEL,
- cloudModel: null,
-});
+import { resolveRenderCfg } from '../lib/pipelineImageDefaults';
+import { deriveAvailableBackends } from '../lib/imageGenBackends';
/**
- * Resolve "what will this record's next render actually run on" — the client
- * mirror of the server's own ladder — and expose it as a ready-to-use
- * `imageCfg`. Collapses the `getSettings` + resolve every single-image-render
- * call site re-implements (Story Builder's characters step, the universe
- * base-style probe, the Decks render bar).
- *
- * The backend walks `renderPinLadder` (the record's own `imageMode`, then the
- * target's `renderDefaults` pin, both gated on backends this install actually
- * has) and falls through to the install-wide `imageGen.mode` via the shared
- * `pickUsableMode`. The model then follows the backend it belongs to: local
- * takes the pin, else `imageGen.local.modelId`, else the shipped default;
- * an override-capable cloud CLI takes the pin as `cloudModel` and nothing
- * else. Neither ever comes from `settings.pipeline.imageGen` — that slice is
- * the Pipeline visual FORM's sticky state, and reading it here is what made a
- * deck advertise the model a comic page was last rendered with while the
- * server rendered on the install pin.
+ * Load the settings blob once on mount and expose "what will this record's next
+ * render actually run on" as a ready-to-use `imageCfg`. Collapses the
+ * `getSettings` + `resolveRenderCfg` pair every single-image-render call site
+ * re-implements (Story Builder's characters step, the universe base-style
+ * probe, the Decks render bar). The resolution itself lives in
+ * `resolveRenderCfg` — read its header for the ladder and for why nothing here
+ * may read `settings.pipeline.imageGen`.
*
* Components that already load the full settings blob for other reasons (e.g.
- * the Universe Builder reads loras + models from the same fetch) should keep
- * deriving `imageCfg` from that shared fetch rather than double-fetching here.
+ * the Universe Builder reads loras + models from the same fetch) should call
+ * `resolveRenderCfg` against that shared fetch rather than double-fetching here.
*
* @param {object} [opts]
* @param {object|null} [opts.record] - Record whose `imageMode`/`imageModelId` pin wins.
@@ -61,23 +38,10 @@ export default function useImageRenderSettings({ record = null, target = null }
// a freshly-fetched draft object on every save, and re-deriving an identical
// cfg would churn the render opts for every consumer downstream.
return useMemo(() => {
- if (!settings) return { imageCfg: UNRESOLVED, backends: [] };
- const backends = deriveAvailableBackends(settings, { excludeExternal: true });
- const pin = renderPinLadder([record, renderTargetPin(settings, target)], backends);
- const mode = pin.mode || pickUsableMode(settings, [settings.imageGen?.mode]);
- const isLocal = mode === IMAGE_GEN_MODE.LOCAL;
+ const backends = settings ? deriveAvailableBackends(settings, { excludeExternal: true }) : [];
return {
backends,
- imageCfg: {
- ...IMAGE_RENDER_KNOB_DEFAULTS,
- mode,
- // Only one of these is ever set: a local render reads `modelId`, an
- // override-capable cloud CLI reads `cloudModel`. Carrying the local
- // model alongside a cloud mode is how "Renders on Codex · <local
- // model>" would get advertised.
- modelId: isLocal ? (pin.modelId || installLocalModelId(settings)) : null,
- cloudModel: !isLocal && supportsCloudModelOverride(mode) ? pin.modelId : null,
- },
+ imageCfg: resolveRenderCfg(settings, { record, target, backends: settings ? backends : null }),
};
}, [settings, target, record?.imageMode, record?.imageModelId]);
}
diff --git a/client/src/hooks/useUniverseDraft.js b/client/src/hooks/useUniverseDraft.js
index 724e1699bd..fb72c46eef 100644
--- a/client/src/hooks/useUniverseDraft.js
+++ b/client/src/hooks/useUniverseDraft.js
@@ -19,10 +19,10 @@ import {
ensureInfluences,
} from '../services/api';
import {
- applyRecordRenderPin, deriveAvailableBackends, renderPinLadder, renderTargetPin,
+ deriveAvailableBackends, renderPinLadder, renderTargetPin,
IMAGE_GEN_MODE, RENDER_TARGET,
} from '../lib/imageGenBackends';
-import { PIPELINE_IMAGE_DEFAULTS, readPipelineImageSettings } from '../lib/pipelineImageDefaults';
+import { resolveRenderCfg } from '../lib/pipelineImageDefaults';
import { sameJsonShape } from '../lib/sameJsonShape';
import { upsertByIdPrepend } from '../lib/upsertByIdPrepend';
import { mergeCanonByName } from '../lib/universeBuilderExpand';
@@ -93,7 +93,10 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {
const [availableLoras, setAvailableLoras] = useState([]);
const [availableBackends, setAvailableBackends] = useState([]);
const [defaultMode, setDefaultMode] = useState(null);
- const [settingsImageCfg, setSettingsImageCfg] = useState(PIPELINE_IMAGE_DEFAULTS);
+ // The raw settings blob, held so the render config below can be re-resolved
+ // whenever this universe s own pin changes rather than only at fetch time.
+ // Null until the first successful read (and after a failed one).
+ const [renderSettings, setRenderSettings] = useState(null);
// The Universe Bible target's own `settings.renderDefaults` pin — the rung
// between this universe's pin and the install default. Held as the normalized
// pin rather than the whole settings blob so the memo below has a stable dep.
@@ -208,7 +211,7 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {
setAvailableBackends(backends);
const saved = settings?.imageGen?.mode;
setDefaultMode(backends.find((backend) => backend.id === saved)?.id || backends[0]?.id || IMAGE_GEN_MODE.LOCAL);
- setSettingsImageCfg(readPipelineImageSettings(settings));
+ setRenderSettings(settings);
setTargetPin(renderTargetPin(settings, RENDER_TARGET.UNIVERSE_BIBLE));
}
setLoading(false);
@@ -706,8 +709,10 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {
// What every SINGLE-image render on this page uses: cast / places / objects
// reference renders and clean plates.
const imageCfg = useMemo(
- () => applyRecordRenderPin(settingsImageCfg, pinSources, pinBackends),
- [settingsImageCfg, targetPin, draft.imageMode, draft.imageModelId, availableBackends],
+ () => resolveRenderCfg(renderSettings, {
+ record: draft, target: RENDER_TARGET.UNIVERSE_BIBLE, backends: pinBackends,
+ }),
+ [renderSettings, targetPin, draft.imageMode, draft.imageModelId, availableBackends],
);
// The same ladder for the BATCH form's default mode. The client always sends
// an explicit body.mode once settings load, so without resolving it here the
diff --git a/client/src/lib/pipelineImageDefaults.js b/client/src/lib/pipelineImageDefaults.js
index 2eba20d639..f99239c122 100644
--- a/client/src/lib/pipelineImageDefaults.js
+++ b/client/src/lib/pipelineImageDefaults.js
@@ -5,7 +5,10 @@
// models render multi-panel pages dramatically better than local diffusion,
// so Codex is the right default whenever the user has it wired up.
-import { isCloudCliMode, IMAGE_GEN_MODE } from './imageGenBackends';
+import {
+ installLocalModelId, isCloudCliMode, IMAGE_GEN_MODE, LOCAL_IMAGEGEN_DEFAULT_MODEL,
+ pickUsableMode, renderPinLadder, renderTargetPin, supportsCloudModelOverride,
+} from './imageGenBackends';
// The geometry + prompt knobs of a render config, with no backend or model —
// the half that is NOT install-wide state. `settings.pipeline.imageGen` is the
@@ -32,6 +35,54 @@ export const PIPELINE_IMAGE_DEFAULTS = Object.freeze({
...IMAGE_RENDER_KNOB_DEFAULTS,
});
+// The config a surface with NO settings blob yet reports — the shipped knobs on
+// the backend that is always usable. Frozen and module-level so an unresolved
+// caller hands every consumer the same identity rather than a fresh object.
+export const UNRESOLVED_RENDER_CFG = Object.freeze({
+ ...IMAGE_RENDER_KNOB_DEFAULTS,
+ mode: IMAGE_GEN_MODE.LOCAL,
+ modelId: LOCAL_IMAGEGEN_DEFAULT_MODEL,
+ cloudModel: null,
+});
+
+/**
+ * Resolve "what will a render on this surface actually run on" — the client
+ * mirror of the server's own ladder, and the ONE place a non-Pipeline surface
+ * derives a render config.
+ *
+ * The backend walks `renderPinLadder` (the record's own `imageMode`, then the
+ * target's `renderDefaults` pin, both gated on backends this install actually
+ * has) and falls through to the install-wide `imageGen.mode` via the shared
+ * `pickUsableMode`. The model then follows the backend it belongs to: local
+ * takes the pin, else `imageGen.local.modelId`, else the shipped default; an
+ * override-capable cloud CLI takes the pin as `cloudModel` and nothing else, so
+ * a cloud mode can never be advertised beside a local model.
+ *
+ * Nothing here reads `settings.pipeline.imageGen`. That slice is the Pipeline
+ * visual FORM's sticky buffer, and using it as a general base is what made a
+ * deck claim it would render on the model a comic page was last rendered with
+ * while the server used the install pin the whole time.
+ *
+ * @param {object|null} settings - The settings blob, or null when unresolved.
+ * @param {object} [opts]
+ * @param {object|null} [opts.record] - Record whose `imageMode`/`imageModelId` pin wins.
+ * @param {string|null} [opts.target] - RENDER_TARGET id whose `renderDefaults` pin is next.
+ * @param {Array<{id:string}>|null} [opts.backends] - Enabled backends a pin is gated on;
+ * `null` while the list isn't loaded (`[]` means "loaded, nothing enabled").
+ */
+export function resolveRenderCfg(settings, { record = null, target = null, backends = null } = {}) {
+ if (!settings) return UNRESOLVED_RENDER_CFG;
+ const pin = renderPinLadder([record, renderTargetPin(settings, target)], backends);
+ const mode = pin.mode || pickUsableMode(settings, [settings.imageGen?.mode]);
+ const isLocal = mode === IMAGE_GEN_MODE.LOCAL;
+ return {
+ ...IMAGE_RENDER_KNOB_DEFAULTS,
+ mode,
+ modelId: isLocal ? (pin.modelId || installLocalModelId(settings)) : null,
+ cloudModel: !isLocal && supportsCloudModelOverride(mode) ? pin.modelId : null,
+ };
+}
+
// Resolve the per-render config. Codex-enabled systems default to codex
// mode unless the user explicitly stored a different mode on
// `settings.pipeline.imageGen` — that override always wins so the form