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

fix([image-gen-mode-enum-unify]): address codex review — sweep remaining mode literals

[._.]/ Adam Eivy7e91187f0dd8
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsx
index b53e041364..d1a7dd77fd 100644
--- a/client/src/pages/UniverseBuilder.jsx
+++ b/client/src/pages/UniverseBuilder.jsx
@@ -3455,7 +3455,7 @@ function RenderTab({
</p>
)}
<ImageGenSettingsForm
- value={{ ...renderOpts, mode: renderOpts.mode || defaultMode || 'local' }}
+ value={{ ...renderOpts, mode: renderOpts.mode || defaultMode || IMAGE_GEN_MODE.LOCAL }}
onChange={(next) => setRenderOpts(next)}
models={imageModels}
availableBackends={availableBackends}
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index 30a5e64343..f4d7cc873f 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -60,6 +60,7 @@ import { startEpisodeVideoForIssue, ERR_NO_STORYBOARDS } from '../services/pipel
import { generateSeriesTitleLogo } from '../services/pipeline/seriesTitleLogo.js';
import { COMIC_PAGE_VARIANTS, slotKeyForVariant } from '../services/pipeline/owners.js';
import { ASPECT_RATIOS, QUALITIES } from '../lib/creativeDirectorPresets.js';
+import { IMAGE_GEN_MODE } from '../services/imageGen/modes.js';
import { extractScenes, SOURCE_KIND } from '../lib/sceneExtractor.js';
import { buildComicPdf, PAGE_SIZES, DEFAULT_PAGE_SIZE, ERR_NO_RENDERED_PAGES } from '../services/pipeline/comicPdf.js';
import {
@@ -278,7 +279,7 @@ const visualStageInputSchema = stageInputSchema.extend({
// refine-LLM override. Sanitizer drops the field entirely when nothing
// is set, so a `null` here clears it.
genConfig: z.object({
- imageMode: z.enum(['auto', 'local', 'codex']).optional(),
+ imageMode: z.enum(['auto', IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX]).optional(),
imageModelId: z.string().trim().max(200).nullable().optional(),
refineProvider: z.string().trim().max(200).nullable().optional(),
refineModel: z.string().trim().max(200).nullable().optional(),
@@ -349,7 +350,7 @@ const visualGenerateSchema = z.object({
slugline: z.string().trim().max(200).optional(),
negativePrompt: z.string().trim().max(2000).optional(),
extraStyle: z.string().trim().max(2000).optional(),
- mode: z.enum(['local', 'codex']).optional(),
+ mode: z.enum([IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX]).optional(),
modelId: z.string().trim().max(64).optional(),
width: imageEdgeSchema,
height: imageEdgeSchema,
@@ -376,7 +377,7 @@ const makeCoverRenderSchema = (scriptField) => z.object({
[scriptField]: z.string().max(8000).optional(),
negativePrompt: z.string().trim().max(2000).optional(),
extraStyle: z.string().trim().max(2000).optional(),
- mode: z.enum(['local', 'codex']).optional(),
+ mode: z.enum([IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX]).optional(),
modelId: z.string().trim().max(64).optional(),
width: imageEdgeSchema,
height: imageEdgeSchema,
@@ -412,7 +413,7 @@ const comicCoverConceptsSchema = z.object({
const comicPageRenderSchema = z.object({
negativePrompt: z.string().trim().max(2000).optional(),
extraStyle: z.string().trim().max(2000).optional(),
- mode: z.enum(['local', 'codex']).optional(),
+ mode: z.enum([IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX]).optional(),
modelId: z.string().trim().max(64).optional(),
width: imageEdgeSchema,
height: imageEdgeSchema,
diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.js
index c67fa2b890..9383fefae4 100644
--- a/server/routes/universeBuilder.js
+++ b/server/routes/universeBuilder.js
@@ -31,7 +31,7 @@ import { getSettings } from '../services/settings.js';
import { findOrCreateUniverseCollection } from '../services/mediaCollections.js';
import { registerUniverseBuilderRun } from '../services/universeBuilderCollectionHook.js';
import { getImageModels, isFlux2, isZImage, isErnie } from '../lib/mediaModels.js';
-import { IMAGE_GEN_MODE } from '../services/imageGen/modes.js';
+import { IMAGE_GEN_MODE, IMAGE_GEN_MODES } from '../services/imageGen/modes.js';
import { getStylePresetById } from '../lib/writersRoomStylePresets.js';
const router = Router();
@@ -303,7 +303,7 @@ const renderSchema = z.object({
collectionName: z.unknown().optional(),
// Image-gen knobs — these mirror /api/image-gen/generate so the user can
// pick mode/size/steps without bouncing to the Image page first.
- mode: z.enum(['external', 'local', 'codex']).optional(),
+ mode: z.enum(IMAGE_GEN_MODES).optional(),
modelId: z.string().trim().max(64).optional(),
width: z.number().int().min(64).max(2048).optional(),
height: z.number().int().min(64).max(2048).optional(),
diff --git a/server/services/pipeline/issues.js b/server/services/pipeline/issues.js
index d3e2d31e53..fa51f32048 100644
--- a/server/services/pipeline/issues.js
+++ b/server/services/pipeline/issues.js
@@ -23,6 +23,7 @@ import { randomUUID } from 'crypto';
import { PATHS, atomicWrite, readJSONFile, ensureDir } from '../../lib/fileUtils.js';
import { createFileWriteQueue } from '../../lib/fileWriteQueue.js';
import { isPlainObject } from '../../lib/objects.js';
+import { IMAGE_GEN_MODE } from '../imageGen/modes.js';
import {
LENGTH_PROFILE_NAMES, DEFAULT_LENGTH_PROFILE,
CUSTOM_PAGE_MIN, CUSTOM_PAGE_MAX, CUSTOM_MINUTE_MIN, CUSTOM_MINUTE_MAX,
@@ -150,7 +151,7 @@ const QUALITY_VALUES = new Set(['draft', 'standard', 'high']);
// `imageMode: 'auto'` defers to the server resolver (codex when enabled,
// local otherwise). Returns null when nothing was set so the persisted
// JSON stays clean for issues that never opened the panel.
-const IMAGE_MODE_VALUES = new Set(['auto', 'local', 'codex']);
+const IMAGE_MODE_VALUES = new Set(['auto', IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX]);
const GEN_CONFIG_STR_MAX = 200;
const sanitizeGenConfig = (raw) => {
if (!raw || typeof raw !== 'object') return null;
@@ -158,7 +159,7 @@ const sanitizeGenConfig = (raw) => {
// imageModelId is only meaningful for local diffusion — clear it for other
// modes so a previously-pinned model doesn't silently persist in the config
// and mislead the UI or any future reader that doesn't filter by mode.
- const imageModelId = imageMode === 'local'
+ const imageModelId = imageMode === IMAGE_GEN_MODE.LOCAL
? (trimTo(raw.imageModelId, GEN_CONFIG_STR_MAX) || null)
: null;
const refineProvider = trimTo(raw.refineProvider, GEN_CONFIG_STR_MAX) || null;
diff --git a/server/services/voice/tools.js b/server/services/voice/tools.js
index 5f7a4c03a1..67b0f1e5e6 100644
--- a/server/services/voice/tools.js
+++ b/server/services/voice/tools.js
@@ -1288,7 +1288,7 @@ const TOOLS = [
// and not every plan exposes image_gen. The dispatcher would also
// reject this, but catching it here lets us return a friendlier
// summary to the voice agent / palette.
- if (requestedMode === 'codex') {
+ if (requestedMode === imageGen.IMAGE_GEN_MODE.CODEX) {
const s = await getSettings();
if (!s?.imageGen?.codex?.enabled) {
return { ok: false, summary: 'Codex Imagegen is disabled — enable it in Settings → Image Gen first.' };
@@ -1336,7 +1336,7 @@ const TOOLS = [
}
const usedMode = result?.mode || requestedMode || 'default';
- const isAsync = usedMode === 'local' || usedMode === 'codex';
+ const isAsync = usedMode === imageGen.IMAGE_GEN_MODE.LOCAL || usedMode === imageGen.IMAGE_GEN_MODE.CODEX;
// External resolves with the file already on disk — short-circuit.
if (!isAsync) {
waiter.cleanup();
diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.js
index d0ad10f5f4..712405e134 100644
--- a/server/services/voice/tools.test.js
+++ b/server/services/voice/tools.test.js
@@ -64,6 +64,7 @@ const generateImageMock = vi.fn(async (params) => {
});
vi.mock('../imageGen/index.js', () => ({
generateImage: (...args) => generateImageMock(...args),
+ IMAGE_GEN_MODE: { EXTERNAL: 'external', LOCAL: 'local', CODEX: 'codex' },
IMAGE_GEN_MODES: ['external', 'local', 'codex'],
}));
vi.mock('../settings.js', () => ({