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
refactor: hoist image-gen mode ladder into a shared server/lib leaf (#6815)
[._.]/ Adam Eivy8bc59bf5b85b
diff --git a/server/lib/README.md b/server/lib/README.mdindex 430a51d6d2..a34cad22e9 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -33,6 +33,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `sharedSchemas.js` | Cross-domain Zod fragments that `validation.js` and the per-domain `*Validation.js` files both need, kept in a leaf module so the domain files never import back through `validation.js` (its hoisted `export * from` lines would TDZ). `grokVideoDurationSchema` (grok clip-length union), `cloudModelIdString(message)` (cloud-CLI model-id charset/bounds), `recordRenderPinFields` (the `imageMode`/`imageModelId` per-record render pin pair), and `isSafeSubdirFilter(v)` (relative path with no wildcard, `..` segment, or leading `/`), and `csvIdsParam({ max, maxIdLength, truncate })` (the `?ids=a,b,c` batch-by-id query param: trims, drops empties, reads all-blank as absent, and either 400s or silently slices an over-cap batch). || `generationModes.js` | Shared immutable image/video render-backend alphabets (`IMAGE_GEN_MODE[S]`, `QUEUEABLE_IMAGE_MODES`, `VIDEO_GEN_MODE[S]`, and cloud subsets) plus `mediaJobExecutionLane({ kind, mode, remote })` / `MEDIA_JOB_EXECUTION_LANES` — THE media-queue lane rule the scheduler and the public job projection share, kept below both validation and generation services so schemas never import orchestration modules. || `imageGenCapabilities.js` | Per-backend image-gen capability literals, a dependency-free leaf beside `generationModes.js`: `EDIT_INCAPABLE_IMAGE_MODES`/`isEditCapableMode` and the derived `I2I_CAPABLE_MODES`, the shipped defaults (`CODEX_IMAGEGEN_DEFAULT_MODEL`/`_EFFORT`, `AGY_IMAGEGEN_DEFAULT_MODEL`, `AGY_IMAGEGEN_IMAGE_MODEL`), the `AGY_`/`GROK_ASPECT_RATIOS` alphabets, and `IMAGE_GEN_PROVIDER_CAPABILITIES` (`supportsModelOverride`, `maxInputImages`, `promptRequiredWithInputImage`) with its `supportsCloudModelOverride`/`maxInputImages`/`cloudPromptRequired` readers. The `services/imageGen/*` modules re-export these, and `client/src/lib/imageGenModes.js` imports them instead of copying them (#6590). |+| `renderModeLadder.js` | Image-gen mode resolution ladder (#6815), a dependency-free leaf beside `generationModes.js`/`renderTargets.js` so the client imports it directly instead of hand-copying it: `isModeUsable(settings, mode)` (queueable + enabled gate, no per-provider spec lookup), `pickUsableMode(settings, candidates)` (first usable candidate, falling through disabled pins to the cloud-then-local tail), `renderTargetDefaults(settings, target)` (the normalized `settings.renderDefaults[target]` pin), and `imageModeCandidates(settings, target, record)` (the shared `[recordPin, targetPin, installDefault]` candidate order, declared once so a UI's own "what will Auto resolve to" display can't drift from the resolver). `services/imageGen/cloudProviderConfig.js` re-exports the first three for its existing callers. || `fableLoomLimits.js` | FableLoom record caps (`LOOM_LIMITS`) — the single source of truth shared by the route schemas and the record sanitizer. A leaf module, below both. || `fableLoomCameraMovements.js` | Shared FableLoom camera-movement registry for generated cut direction and the manual scene editor selector. || `fableLoomPlayback.js` | FableLoom node playback modes (`cut` auto-advances; `decision` loops while awaiting input), with the backward-compatible default. |diff --git a/server/lib/index.js b/server/lib/index.jsindex f61c37bded..ad9f0cbf9a 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -481,6 +481,7 @@ export * from './renderTargets.js';export * from './renderTiming.js';export * from './generationModes.js';export * from './imageGenCapabilities.js';+export * from './renderModeLadder.js';export * from './spriteVocabulary.js';export * from './spriteChromaKey.js';export * from './spriteAnimationTracks.js';diff --git a/server/lib/renderModeLadder.js b/server/lib/renderModeLadder.jsnew file mode 100644index 0000000000..f7e68275ff--- /dev/null+++ b/server/lib/renderModeLadder.js@@ -0,0 +1,109 @@+/**+ * Image-gen mode resolution ladder — the pure "which backend actually+ * renders" resolver shared by every server surface AND the client (#6815).+ *+ * Dependency-free leaf (imports only the sibling `generationModes.js` and+ * `renderTargets.js`) so the browser bundle can import it directly, the same+ * way `client/src/lib/imageGenModes.js` already imports those two siblings —+ * see that file's header. Before this existed, `VisualGenSettings.jsx`+ * hand-copied the ladder for its "Auto → …" label and drifted from the real+ * one: #3231 added two rungs to the server ladder (a per-record pin, a+ * per-render-target pin) that the hand copy never got.+ *+ * `services/imageGen/cloudProviderConfig.js` re-exports `isModeUsable` /+ * `pickUsableMode` / `renderTargetDefaults` for its existing callers — this+ * module is the one place they're defined.+ *+ * Fall-through semantics (the part worth getting right before editing this+ * file): every entry in a candidate list is a PREFERENCE, not a guarantee. A+ * pin naming a backend that is disabled, removed, or was never enabled on+ * this install falls through to the next candidate rather than failing the+ * render — see `pickUsableMode`. The one thing that is NOT a preference is a+ * caller's own explicit per-request mode (an API body's `mode`, or a stage's+ * non-"auto" `genConfig.imageMode`): callers prepend that ahead of+ * `imageModeCandidates`'s output themselves, because "usable or reject" at+ * that rung is the caller's own contract, not this ladder's.+ */++import {+ CLOUD_IMAGE_GEN_MODES,+ IMAGE_GEN_MODE,+ QUEUEABLE_IMAGE_MODES,+} from './generationModes.js';+import { normalizeRenderPinValue, recordRenderPin } from './renderTargets.js';++/**+ * Can the queue-backed surfaces render in `mode` right now? Local is always+ * usable (its own pythonPath/model validation happens per call site);+ * external isn't queueable at all; a cloud CLI needs its own opt-in toggle.+ *+ * `QUEUEABLE_IMAGE_MODES` is LOCAL plus every mode in `CLOUD_IMAGE_GEN_MODES`+ * — by construction, every cloud mode is one this install can enable/disable+ * via `settings.imageGen.<mode>.enabled` — so this needs no per-provider spec+ * lookup. Contrast `resolveCloudProviderConfig` (imageGen/cloudProviderConfig.js),+ * which assembles the FULL per-provider job-param bundle and is not safe to+ * import from a dependency-free leaf.+ *+ * There is no edit/i2i variant: every queueable backend accepts an input+ * image, so an i2i render walks this exact ladder too.+ */+export function isModeUsable(settings, mode) {+ if (!QUEUEABLE_IMAGE_MODES.includes(mode)) return false;+ if (mode === IMAGE_GEN_MODE.LOCAL) return true;+ return settings?.imageGen?.[mode]?.enabled === true;+}++/**+ * First usable mode from an ordered candidate list, falling back to the+ * cloud providers (in `CLOUD_IMAGE_GEN_MODES` order) and finally local.+ *+ * A record pinned to a DISABLED backend falls through to the next usable one+ * rather than failing — a pin is a preference (the enforceRenderBackendPin+ * contract). LOCAL is always usable, so the tail always resolves.+ */+export function pickUsableMode(settings, candidates = []) {+ const ordered = [...candidates, ...CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODE.LOCAL];+ return ordered.find((m) => m && isModeUsable(settings, m)) || IMAGE_GEN_MODE.LOCAL;+}++/**+ * The user's saved per-surface pins for one render target (#3231 Phase 2) —+ * `settings.renderDefaults[target]`, normalized: the `'auto'` sentinel and+ * blank strings collapse to null ("no pin — fall through").+ */+export function renderTargetDefaults(settings, target) {+ const d = settings?.renderDefaults?.[target] || {};+ return {+ imageMode: normalizeRenderPinValue(d.imageMode),+ imageModel: normalizeRenderPinValue(d.imageModel),+ videoMode: normalizeRenderPinValue(d.videoMode),+ videoModel: normalizeRenderPinValue(d.videoModel),+ };+}++/**+ * The image-mode candidate order shared by every "auto-resolve a backend for+ * this surface" caller, declared ONCE so a new rung (or a reordering) can't+ * drift between the server resolver and a UI's own display of what it will+ * resolve to (#6815):+ *+ * 1. `record`'s own persisted pin (a series/universe/sprite's `imageMode`)+ * — "this record renders on codex" beats the surface default.+ * 2. The render target's saved `renderDefaults` pin (#3231 Phase 2) — "this+ * surface renders on codex" beats the install-wide default.+ * 3. The install-wide `settings.imageGen.mode` default.+ *+ * `record` is optional — omit it (or pass null) for a surface with no+ * per-record pin concept. Every entry is usability-gated by+ * `pickUsableMode`/`isModeUsable` when the caller resolves the list, not+ * here — this function only declares the order. The caller's own explicit+ * per-request override (not a preference) is not part of this list; prepend+ * it: `pickUsableMode(settings, [explicitMode, ...imageModeCandidates(...)])`.+ */+export function imageModeCandidates(settings, target, record = null) {+ return [+ recordRenderPin(record).mode,+ renderTargetDefaults(settings, target).imageMode,+ settings?.imageGen?.mode,+ ];+}diff --git a/server/lib/renderModeLadder.test.js b/server/lib/renderModeLadder.test.jsnew file mode 100644index 0000000000..fbae3871c6--- /dev/null+++ b/server/lib/renderModeLadder.test.js@@ -0,0 +1,134 @@+/**+ * `renderModeLadder.js` is a dependency-free leaf hoisted out of+ * `services/imageGen/cloudProviderConfig.js` (#6815) specifically so the+ * client can import it directly instead of hand-copying the ladder — the+ * hand copy in `VisualGenSettings.jsx` is what drifted and prompted this+ * split. `cloudProviderConfig.test.js` already exercises `isModeUsable` /+ * `pickUsableMode` / `renderTargetDefaults` exhaustively through the+ * re-export, so this file does not repeat that matrix. It instead pins the+ * two things unique to this module's own boundary: the candidate ORDER+ * `imageModeCandidates` declares (never tested elsewhere — the callers all+ * inline their own array), and that resolving through this leaf directly+ * (not proxied through the service layer) reproduces the exact fall-through+ * behavior the "Auto" label bug (#6815) depended on.+ */++import { describe, it, expect } from 'vitest';+import {+ imageModeCandidates, isModeUsable, pickUsableMode, renderTargetDefaults,+} from './renderModeLadder.js';+import { IMAGE_GEN_MODE } from './generationModes.js';+import { RENDER_TARGET } from './renderTargets.js';++const settingsWith = (imageGen, renderDefaults) => ({ imageGen, renderDefaults });++describe('imageModeCandidates (#6815)', () => {+ it('declares the candidate order: record pin, then target pin, then install default', () => {+ const settings = settingsWith(+ { mode: IMAGE_GEN_MODE.GROK },+ { [RENDER_TARGET.PIPELINE_VISUAL]: { imageMode: IMAGE_GEN_MODE.AGY } },+ );+ const record = { imageMode: IMAGE_GEN_MODE.CODEX };+ expect(imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL, record)).toEqual([+ IMAGE_GEN_MODE.CODEX, // record pin+ IMAGE_GEN_MODE.AGY, // render-target pin+ IMAGE_GEN_MODE.GROK, // install-wide default+ ]);+ });++ it('normalizes an absent record and an unset target pin to null rather than dropping the slot', () => {+ const settings = settingsWith({ mode: IMAGE_GEN_MODE.CODEX }, {});+ expect(imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL)).toEqual([+ null, null, IMAGE_GEN_MODE.CODEX,+ ]);+ });++ it('collapses the `auto` sentinel on a target pin to null (renderTargetDefaults normalization)', () => {+ const settings = settingsWith(+ { mode: IMAGE_GEN_MODE.CODEX },+ { [RENDER_TARGET.PIPELINE_VISUAL]: { imageMode: 'auto' } },+ );+ expect(imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL, { imageMode: 'auto' })).toEqual([+ null, null, IMAGE_GEN_MODE.CODEX,+ ]);+ });+});++describe('pickUsableMode + imageModeCandidates composed (the "Auto" label bug, #6815)', () => {+ // This is the exact scenario the issue describes: a record pinned to a+ // backend that is DISABLED (or was pinned before this install had it+ // configured at all) must fall through to the next rung rather than+ // sticking — a pin is a preference, not a guarantee.+ it('falls through a disabled record pin to the render-target pin', () => {+ const settings = settingsWith(+ { agy: { enabled: false }, codex: { enabled: true } },+ { [RENDER_TARGET.PIPELINE_VISUAL]: { imageMode: IMAGE_GEN_MODE.CODEX } },+ );+ const record = { imageMode: IMAGE_GEN_MODE.AGY };+ const resolved = pickUsableMode(settings, imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL, record));+ expect(resolved).toBe(IMAGE_GEN_MODE.CODEX);+ });++ it('falls through a disabled render-target pin to the install-wide default', () => {+ const settings = settingsWith(+ { grok: { enabled: false }, codex: { enabled: true }, mode: IMAGE_GEN_MODE.CODEX },+ { [RENDER_TARGET.PIPELINE_VISUAL]: { imageMode: IMAGE_GEN_MODE.GROK } },+ );+ const resolved = pickUsableMode(settings, imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL));+ expect(resolved).toBe(IMAGE_GEN_MODE.CODEX);+ });++ it('reaches the cloud-then-local tail (auto-default) when no pin or install default exists', () => {+ const settings = settingsWith({ codex: { enabled: true } }, {});+ // No record, no target pin, no install default — nothing but the tail.+ const resolved = pickUsableMode(settings, imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL));+ expect(resolved).toBe(IMAGE_GEN_MODE.CODEX);+ });++ it('lands on local when nothing in the whole ladder is usable', () => {+ const settings = settingsWith({}, {});+ const resolved = pickUsableMode(settings, imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL));+ expect(resolved).toBe(IMAGE_GEN_MODE.LOCAL);+ });++ it('an explicit per-request mode (prepended by the caller) outranks every pin', () => {+ // The caller's own explicit override is NOT part of imageModeCandidates —+ // it is prepended ahead of the ladder, and is not usability-gated away+ // from a record pin the way a pin is gated against another pin.+ const settings = settingsWith(+ { agy: { enabled: true }, codex: { enabled: true } },+ { [RENDER_TARGET.PIPELINE_VISUAL]: { imageMode: IMAGE_GEN_MODE.AGY } },+ );+ const record = { imageMode: IMAGE_GEN_MODE.AGY };+ const resolved = pickUsableMode(settings, [+ IMAGE_GEN_MODE.CODEX,+ ...imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL, record),+ ]);+ expect(resolved).toBe(IMAGE_GEN_MODE.CODEX);+ });+});++describe('isModeUsable (leaf boundary)', () => {+ // cloudProviderConfig.test.js exhaustively covers this predicate through the+ // re-export; this is a minimal smoke test that imports it directly from the+ // dependency-free leaf, which has no `resolveCloudProviderConfig` to call —+ // it derives usability from `QUEUEABLE_IMAGE_MODES` + the enable toggle only.+ it('local is always usable, cloud modes are gated on their enable toggle, external never is', () => {+ const settings = settingsWith({ codex: { enabled: true }, grok: { enabled: false } }, {});+ expect(isModeUsable(settings, IMAGE_GEN_MODE.LOCAL)).toBe(true);+ expect(isModeUsable(settings, IMAGE_GEN_MODE.CODEX)).toBe(true);+ expect(isModeUsable(settings, IMAGE_GEN_MODE.GROK)).toBe(false);+ expect(isModeUsable(settings, IMAGE_GEN_MODE.EXTERNAL)).toBe(false);+ });+});++describe('renderTargetDefaults (leaf boundary)', () => {+ it('reads the render-target pin straight from settings.renderDefaults', () => {+ const settings = settingsWith({}, {+ [RENDER_TARGET.SPRITE_REFERENCE]: { imageMode: IMAGE_GEN_MODE.AGY, imageModel: 'gemini-3.5-pro' },+ });+ expect(renderTargetDefaults(settings, RENDER_TARGET.SPRITE_REFERENCE)).toEqual({+ imageMode: IMAGE_GEN_MODE.AGY, imageModel: 'gemini-3.5-pro', videoMode: null, videoModel: null,+ });+ });+});diff --git a/server/services/imageGen/cloudProviderConfig.js b/server/services/imageGen/cloudProviderConfig.jsindex 26b2cb22ac..6020e825b1 100644--- a/server/services/imageGen/cloudProviderConfig.js+++ b/server/services/imageGen/cloudProviderConfig.js@@ -17,18 +17,20 @@*/import { ServerError } from '../../lib/errorHandler.js';-import { normalizeRenderPinValue } from '../../lib/renderTargets.js';import {cloudPromptRequired,IMAGE_GEN_PROVIDER_CAPABILITIES,maxInputImages,} from '../../lib/imageGenCapabilities.js';+import {+ isModeUsable,+ pickUsableMode,+ renderTargetDefaults,+} from '../../lib/renderModeLadder.js';import {AGY_IMAGEGEN_DEFAULT_MODEL,- CLOUD_IMAGE_GEN_MODES,CODEX_IMAGEGEN_DEFAULT_MODEL,IMAGE_GEN_MODE,- QUEUEABLE_IMAGE_MODES,} from './modes.js';// The pure capability half of the specs below, plus the two predicates that@@ -38,6 +40,14 @@ import {// fableLoom/production) imports them from this module.export { cloudPromptRequired, maxInputImages };+// The pure resolution ladder lives in the dependency-free `lib/renderModeLadder.js`+// leaf (#6815) so the client can import it directly instead of hand-copying it —+// see that module for their docs and the fall-through semantics (a pin is a+// preference, not a guarantee). Re-exported here because every existing caller+// (visualStageHelpers, sprites/reference, creativeCommissions/scheduler,+// creative/tools/media, videoGen/backendPin) imports them from this module.+export { isModeUsable, pickUsableMode, renderTargetDefaults };+/*** Per-provider knowledge, keyed by mode:* - `label` — user-facing provider name used in every disabled message.@@ -140,56 +150,6 @@ export function resolveCloudProviderConfig(settings, mode, overrides = {}) {};}-/**- * Can the queue-backed surfaces render in `mode` right now? Cloud CLIs need- * their opt-in toggle; local is always usable (its own pythonPath/model- * validation happens per call site); external isn't queueable at all.- *- * The predicate behind the candidate walk in `resolveMode`- * (pipeline/visualStageHelpers.js), so the mode ladder no longer grows a- * pairwise `if` per backend.- *- * There is no edit/i2i variant: every queueable backend accepts an input image- * (see EDIT_INCAPABLE_IMAGE_MODES, whose sole member — external — is not- * queueable), so an i2i render walks this exact ladder. #3243 threaded an- * `{ edit }` flag through here to route redraws away from Agy; that turned out- * to be a misreading of Agy's tool schema, and the flag is gone rather than- * left as a branch that can never be taken.- */-export function isModeUsable(settings, mode) {- if (!QUEUEABLE_IMAGE_MODES.includes(mode)) return false;- const cloud = resolveCloudProviderConfig(settings, mode);- return cloud ? cloud.enabled : true;-}--/**- * First usable mode from an ordered candidate list, falling back to the- * cloud providers (in `CLOUD_IMAGE_GEN_MODES` order) and finally local.- *- * A record pinned to a DISABLED backend falls through to the next usable one- * rather than failing — a pin is a preference (the enforceRenderBackendPin- * contract). LOCAL is always usable, so the tail always resolves.- */-export function pickUsableMode(settings, candidates = []) {- const ordered = [...candidates, ...CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODE.LOCAL];- return ordered.find((m) => m && isModeUsable(settings, m)) || IMAGE_GEN_MODE.LOCAL;-}--/**- * The user's saved per-surface pins for one render target (#3231 Phase 2) —- * `settings.renderDefaults[target]`, normalized: the `'auto'` sentinel and- * blank strings collapse to null ("no pin — fall through").- */-export function renderTargetDefaults(settings, target) {- const d = settings?.renderDefaults?.[target] || {};- return {- imageMode: normalizeRenderPinValue(d.imageMode),- imageModel: normalizeRenderPinValue(d.imageModel),- videoMode: normalizeRenderPinValue(d.videoMode),- videoModel: normalizeRenderPinValue(d.videoModel),- };-}-/*** Resolve one surface's image render config through the render-target ladder* (#3231 Phase 2): per-request/per-record override → the target's saveddiff --git a/server/services/pipeline/visualStageHelpers.js b/server/services/pipeline/visualStageHelpers.jsindex 4bb0ebdf0d..279deafcb0 100644--- a/server/services/pipeline/visualStageHelpers.js+++ b/server/services/pipeline/visualStageHelpers.js@@ -23,7 +23,8 @@ import { loraCompatKey } from '../../lib/runners.js';import { resolveCharacterLoras } from '../characterLoraResolver.js';import { pickCanon } from './seriesCanon.js';import { IMAGE_GEN_MODE } from '../imageGen/modes.js';-import { pickUsableMode, renderTargetDefaults, resolveRenderTargetConfig } from '../imageGen/cloudProviderConfig.js';+import { resolveRenderTargetConfig } from '../imageGen/cloudProviderConfig.js';+import { imageModeCandidates, pickUsableMode } from '../../lib/renderModeLadder.js';import { RENDER_TARGET, recordRenderPin } from '../../lib/renderTargets.js';import { resolveImageCleaners } from '../imageGen/index.js';@@ -53,31 +54,31 @@ const applyWorldStyle = (prompt, world, series = null) => {// 1. Per-request override (`options.mode`) — set by the stage's persisted// `genConfig` or an explicit UI selection. A cloud mode is only honored// when its `imageGen.<mode>.enabled` toggle is on; a stale 'codex'-// override from before the toggle was turned off falls through.-// 2. Saved dispatcher default (`settings.imageGen.mode`) — same usability-// gate, and non-queueable modes (external SD-API, which this surface-// doesn't proxy) never qualify.-// 3. Auto-default — prefer an enabled cloud backend, since cloud image gen+// override from before the toggle was turned off falls through. This is+// the caller's own explicit request, not a preference, so it is+// prepended here rather than folded into the shared candidate order.+// 2. The series' persisted per-record pin (#3231 Phase 3) — "this series+// renders on codex" beats the surface default, loses to #1.+// 3. The pipeline-visual `renderDefaults` pin (#3231 Phase 2) — "this+// surface renders on codex" beats the install-wide default.+// 4. Saved dispatcher default (`settings.imageGen.mode`).+// 5. Auto-default — prefer an enabled cloud backend, since cloud image gen// produces print-quality comic pages out of the box. Otherwise fall back// to local diffusion (flux-1) the way the original default behaved.-// `pickUsableMode` appends the cloud-then-local tail, so this only lists the-// two explicit candidates. (Sprite renders use the equivalent-// `resolveQueueImageMode` ladder in imageGen/modes.js — #2896 hoisted that-// one first; this is the wider param-assembly consolidation from #2881.)-// The pipeline-visual renderDefaults pin (#3231) slots between the explicit-// per-request override and the install default — usability-gated like both.-// The series' persisted per-record pin (#3231 Phase 3) sits between the-// per-request override and the install-wide target pin: "this series renders-// on codex" beats the surface default, loses to an explicit UI selection.+// Candidates 2-4 are `imageModeCandidates` (lib/renderModeLadder.js, #6815) —+// the SAME candidate order the "Auto → …" label in VisualGenSettings.jsx+// resolves through, so that panel can't drift from what this actually+// dispatches. `pickUsableMode` appends the cloud-then-local tail for #5.+// (Sprite renders use the equivalent `resolveQueueImageMode` ladder in+// imageGen/modes.js — #2896 hoisted that one first; this is the wider+// param-assembly consolidation from #2881.)// An i2i render ("use proof as base", a reference page, a refine pass) walks// this same ladder — every queueable backend accepts an input image, so there// is nothing for it to skip. #3243 added an `edit` flag here to route redraws// away from Agy; Agy's tool does take input images, so the flag is gone.const resolveMode = (options, settings, series = null) => pickUsableMode(settings, [options.mode,- recordRenderPin(series).mode,- renderTargetDefaults(settings, RENDER_TARGET.PIPELINE_VISUAL).imageMode,- settings?.imageGen?.mode,+ ...imageModeCandidates(settings, RENDER_TARGET.PIPELINE_VISUAL, series),]);/**