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

feat: codex hi-res image presets + per-backend resolution filter

Adam Eivy01e6b932399f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index e929e22874..93ecd3b054 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -1 +1,9 @@
# Unreleased Changes
+
+## Added
+
+- Codex image gen: hi-res resolution presets (1024×1536, 1536×1024, 1536×1536) — gpt-image-1's native hi-res tier. Picking any ≥1536 size automatically appends a `(high quality)` hint to the codex prompt so the model renders at full fidelity instead of its 1024 default.
+
+## Changed
+
+- Image Gen resolution dropdown now filters by the selected backend. Flux-bucketed sizes (832×1216 / 1216×832) only appear for Flux 1/2 and external; the new 1536 hi-res tier only appears for codex and Flux 2. Z-Image-Turbo and ERNIE (trained at 1024²) now hide both groups to prevent users from picking sizes the model can't handle. A stale incompatible selection falls through to a `(custom)` option so the value stays visible until the user picks a supported one.
diff --git a/PLAN.md b/PLAN.md
index 1152505afa..7ec31a7b0d 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -40,6 +40,7 @@ The dgrauet/ltx-2-mlx runtime ships with FFLF (true keyframe interpolation), aud
- [ ] **M34 P5-P7 — Digital Twin** — Multi-modal capture (voice/video/image identity sources), advanced testing, personas. Ties to GOALS.md secondary "Multi-Modal Identity Capture".
- [ ] **Multi-reference image editing for FLUX.2** — UI on the Image Gen page that accepts 2+ reference images plus an edit prompt (e.g. "put the subject from image A into the scene from image B"). When this lands, swap the model registry's 9B entry to [`black-forest-labs/FLUX.2-klein-9B-kv`](https://huggingface.co/black-forest-labs/FLUX.2-klein-9B-kv) — KV-cache optimization gives up to 2.5× speedup on multi-reference workflows. Work involves: schema for multi-image payload (`referenceImages: [...]`), client multi-uploader, server FormData parsing, and adapting `flux2_macos.py` to call the multi-reference pipeline API. Separately-gated repo on HF — user must request access.
- [ ] **World Builder Phase 2 — external SD-API + per-bucket model overrides.** The shipped batch render only supports local mflux + Codex. Wire the existing external SD-API providers (Together, Replicate, Fal) into the world-builder batch path so high-end renders are practical, and let each bucket pick its own model (e.g. characters → SDXL portrait LoRA, environments → Flux-pro). Single touchpoint: `server/services/worldBuilder.js#compileBatchPrompts` + `worldBuilderCollectionHook.js`. (Surfaced from PR #211 follow-ups.)
+- [ ] **Unify VideoGen.jsx RESOLUTIONS with the shared image-gen list** — `client/src/pages/VideoGen.jsx:54` defines its own private `RESOLUTIONS` array + finds-by-w/h block, duplicating the pattern in `client/src/lib/imageGenResolutions.js`. Move VideoGen's presets into a shared `client/src/lib/videoGenResolutions.js` (or extend `imageGenResolutions.js` with a `media: 'image' | 'video'` field) so the dropdown + custom-fallback logic only lives in one place. Surfaced during the codex hi-res / per-backend filter work — `filterResolutions(mode, runner)` is exactly the helper VideoGen will want once mlx-video models gain runner-specific size constraints.
### Civitai LoRA / Z-Image-Turbo follow-ups (from /simplify pass)
diff --git a/client/src/components/imageGen/ImageGenControls.jsx b/client/src/components/imageGen/ImageGenControls.jsx
index 2f0185befb..31fcfa4889 100644
--- a/client/src/components/imageGen/ImageGenControls.jsx
+++ b/client/src/components/imageGen/ImageGenControls.jsx
@@ -9,7 +9,7 @@
// resolution; external swaps guidance for cfgScale; local shows guidance + quantize.
import { Dice5 } from 'lucide-react';
-import { RESOLUTIONS, findResolution } from '../../lib/imageGenResolutions';
+import { filterResolutions } from '../../lib/imageGenResolutions';
import { randomSeed } from '../../lib/genUtils';
const QUANTIZE_OPTIONS = [
@@ -44,10 +44,14 @@ export default function ImageGenControls({
const currentModel = models.find((m) => m.id === modelId);
const isFlux2 = currentModel?.runner === 'flux2';
- const matched = findResolution(width, height);
+ // Filter by backend; a stale w/h (e.g. Flux 2 → Flux 1 with 1536 still set)
+ // falls through to the (custom) <option> below so the value stays visible
+ // until the user picks a supported one.
+ const availableResolutions = filterResolutions(mode, currentModel?.runner);
+ const matched = availableResolutions.find((r) => r.w === width && r.h === height);
const resolutionLabel = matched?.label || (width && height ? `${width}×${height}` : '');
const handleResolution = (e) => {
- const r = RESOLUTIONS.find((opt) => opt.label === e.target.value);
+ const r = availableResolutions.find((opt) => opt.label === e.target.value);
if (r) onResolutionChange?.(r.w, r.h);
};
@@ -77,7 +81,7 @@ export default function ImageGenControls({
disabled={disabled}
className={inputCls}
>
- {RESOLUTIONS.map((r) => <option key={r.label} value={r.label}>{r.label}</option>)}
+ {availableResolutions.map((r) => <option key={r.label} value={r.label}>{r.label}</option>)}
{!matched && resolutionLabel && <option value={resolutionLabel}>{resolutionLabel} (custom)</option>}
</select>
</div>
diff --git a/client/src/lib/imageGenResolutions.js b/client/src/lib/imageGenResolutions.js
index 85c6bc6f42..b572c20ae0 100644
--- a/client/src/lib/imageGenResolutions.js
+++ b/client/src/lib/imageGenResolutions.js
@@ -1,16 +1,36 @@
// Shared resolution presets for image generation. Used by the standalone
// Image Gen page and the World Builder batch render so the size dropdown
// stays consistent everywhere.
+//
+// Entries without a `compatible` field are universal. The non-universal
+// ones reflect real model constraints, not just style — Z-Image-Turbo and
+// ERNIE were trained at 1024² and degrade past ~1280, and gpt-image-1's
+// native sizes are 1024² / 1024×1536 / 1536×1024.
export const RESOLUTIONS = [
{ label: '512×512', w: 512, h: 512 },
{ label: '768×512', w: 768, h: 512 },
{ label: '512×768', w: 512, h: 768 },
{ label: '768×768', w: 768, h: 768 },
{ label: '1024×1024', w: 1024, h: 1024 },
- { label: '832×1216 (Flux portrait)', w: 832, h: 1216 },
- { label: '1216×832 (Flux landscape)', w: 1216, h: 832 },
+ { label: '832×1216 (Flux portrait)', w: 832, h: 1216, compatible: ['flux1', 'flux2', 'external'] },
+ { label: '1216×832 (Flux landscape)', w: 1216, h: 832, compatible: ['flux1', 'flux2', 'external'] },
{ label: '1024×576 (16:9)', w: 1024, h: 576 },
{ label: '576×1024 (9:16)', w: 576, h: 1024 },
+ { label: '1536×1536 (hi-res square)', w: 1536, h: 1536, compatible: ['codex', 'flux2'] },
+ { label: '1024×1536 (hi-res portrait)', w: 1024, h: 1536, compatible: ['codex', 'flux2'] },
+ { label: '1536×1024 (hi-res landscape)', w: 1536, h: 1024, compatible: ['codex', 'flux2'] },
];
-export const findResolution = (w, h) => RESOLUTIONS.find((r) => r.w === w && r.h === h);
+// Flux 1 (mflux/diffusers, `dev` / `schnell`) has no `runner` field — it's
+// the fallback for local mode when nothing more specific matches.
+export const compatibilityKey = (mode, runner) => {
+ if (mode === 'codex') return 'codex';
+ if (mode === 'external') return 'external';
+ if (runner === 'flux2' || runner === 'z-image' || runner === 'ernie') return runner;
+ return 'flux1';
+};
+
+export const filterResolutions = (mode, runner) => {
+ const key = compatibilityKey(mode, runner);
+ return RESOLUTIONS.filter((r) => !r.compatible || r.compatible.includes(key));
+};
diff --git a/server/services/imageGen/codex.js b/server/services/imageGen/codex.js
index 0b6ca95e7c..ae4c8d75b1 100644
--- a/server/services/imageGen/codex.js
+++ b/server/services/imageGen/codex.js
@@ -105,9 +105,12 @@ export async function generateImage({ codexPath, model, prompt, width, height, n
// Width/height/negative aren't first-class args for Codex's built-in
// image_gen tool — pass them as natural-language hints inside the prompt.
// Codex's imagegen skill is prompt-driven; the model decides resolution.
+ // gpt-image-1 honors a quality hint to escape its 1024 default and render
+ // at native hi-res (1024×1536 / 1536×1024 / 1536×1536).
const sizeHint = (width && height) ? ` (${width}x${height})` : '';
+ const qualityHint = (width >= 1536 || height >= 1536) ? ' (high quality)' : '';
const avoidHint = negativePrompt?.trim() ? `\nAvoid: ${negativePrompt.trim()}` : '';
- const fullPrompt = `$imagegen ${prompt.trim()}${sizeHint}${avoidHint}`;
+ const fullPrompt = `$imagegen ${prompt.trim()}${sizeHint}${qualityHint}${avoidHint}`;
const bin = codexPath || DEFAULT_BIN;
const args = [
diff --git a/server/services/imageGen/codex.test.js b/server/services/imageGen/codex.test.js
index c1b320a053..2209f21b8f 100644
--- a/server/services/imageGen/codex.test.js
+++ b/server/services/imageGen/codex.test.js
@@ -100,6 +100,26 @@ describe('codex provider — generateImage', () => {
await flush();
});
+ it('appends a "(high quality)" hint when width or height ≥ 1536', async () => {
+ await codex.generateImage({ prompt: 'a fox', width: 1536, height: 1024 });
+ const promptArg = spawnCalls[0].args[spawnCalls[0].args.length - 1];
+ expect(promptArg).toContain('(1536x1024)');
+ expect(promptArg).toContain('(high quality)');
+ spawnCalls[0].child.exitCode = 1;
+ spawnCalls[0].child.emit('close', 1, null);
+ await flush();
+ });
+
+ it('does not append "(high quality)" for sub-1536 dimensions', async () => {
+ await codex.generateImage({ prompt: 'a fox', width: 1024, height: 1024 });
+ const promptArg = spawnCalls[0].args[spawnCalls[0].args.length - 1];
+ expect(promptArg).toContain('(1024x1024)');
+ expect(promptArg).not.toContain('high quality');
+ spawnCalls[0].child.exitCode = 1;
+ spawnCalls[0].child.emit('close', 1, null);
+ await flush();
+ });
+
it('honors codexPath override (custom binary)', async () => {
await codex.generateImage({ prompt: 'a fox', codexPath: '/opt/custom/codex' });
expect(spawnCalls[0].bin).toBe('/opt/custom/codex');