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: keep image dimensions and backup retention aligned with server limits (#9336)

[._.]/ Adam Eivyafaaf2dc1c26
diff --git a/client/src/components/settings/BackupTab.jsx b/client/src/components/settings/BackupTab.jsx
index 4828266fc4..4b76d03919 100644
--- a/client/src/components/settings/BackupTab.jsx
+++ b/client/src/components/settings/BackupTab.jsx
@@ -1,3 +1,4 @@
+import { MIN_RETENTION_COUNT, MAX_RETENTION_COUNT, DEFAULT_RETENTION_COUNT } from '../../../../server/lib/backupConfig.js';
import { useState, useEffect, useId, useRef } from 'react';
import { AlertTriangle, Archive, CalendarClock, CheckCircle2, Database, Play, Plus, Save, ShieldOff, Trash2, X, ChevronDown, ChevronRight } from 'lucide-react';
import toast from '../ui/Toast';
@@ -15,13 +16,6 @@ import { describeCron } from '../../utils/cronHelpers';
import CronSchedulePicker from '../CronSchedulePicker';
import { anchorUserExclude, anchorUserExcludes, isSafeExcludePattern } from '../../lib/backupExcludes';
-// Mirrors MIN_RETENTION_COUNT/MAX_RETENTION_COUNT in server/lib/backupConfig.js —
-// the server is the source of truth and re-validates on save; these only bound
-// the input control.
-const MIN_RETENTION_COUNT = 1;
-const MAX_RETENTION_COUNT = 365;
-const DEFAULT_RETENTION_COUNT = 30;
-
// Set equality — rsync --exclude flags are order-independent, so reordering
// is NOT a dirty state; only membership changes (added/removed entries) are.
const sameSet = (a, b) => a.length === b.length && a.every(x => b.includes(x));
diff --git a/client/src/lib/imageGenResolutions.js b/client/src/lib/imageGenResolutions.js
index 6a4205848d..3a2ec98f3c 100644
--- a/client/src/lib/imageGenResolutions.js
+++ b/client/src/lib/imageGenResolutions.js
@@ -1,3 +1,5 @@
+import { MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from '../../../server/lib/imageLimits.js';
+export { MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from '../../../server/lib/imageLimits.js';
// Shared resolution presets for image generation. Used by the standalone
// Image Gen page and the Universe Builder batch render so the size dropdown
// stays consistent everywhere.
@@ -56,12 +58,6 @@ export const RESOLUTIONS = [
{ label: '2880×2880 (4K square)', w: 2880, h: 2880, compatible: ['codex'] },
];
-// Mirror of server/lib/validation.js MAX_IMAGE_EDGE / MAX_IMAGE_PIXELS — the
-// gpt-image-2 / image-gen route ceiling (each edge ≤ 3840, total ≤ 8,294,400).
-// Keep in sync with that module.
-export const MAX_IMAGE_EDGE = 3840;
-export const MAX_IMAGE_PIXELS = 8_294_400;
-
// Clamp arbitrary source dimensions (e.g. an uploaded photo) down to the
// server's per-edge and total-pixel caps, preserving aspect ratio and snapping
// to a multiple of 8 (runner-friendly). Returns integer { width, height } ≥ 64,
diff --git a/client/src/lib/imageGenResolutions.test.js b/client/src/lib/imageGenResolutions.test.js
index 8ac7e7e89e..e7b6415dbe 100644
--- a/client/src/lib/imageGenResolutions.test.js
+++ b/client/src/lib/imageGenResolutions.test.js
@@ -1,7 +1,12 @@
+import { MAX_IMAGE_EDGE as SERVER_MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS as SERVER_MAX_IMAGE_PIXELS } from '../../../server/lib/imageLimits.js';
import { describe, it, expect } from 'vitest';
import { clampImageDimensions, clampImageEdge, MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from './imageGenResolutions';
describe('clampImageEdge', () => {
+ it('uses the caps enforced by server validation', () => {
+ expect([MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS]).toEqual([SERVER_MAX_IMAGE_EDGE, SERVER_MAX_IMAGE_PIXELS]);
+ });
+
it('passes valid edges through unchanged', () => {
expect(clampImageEdge(704)).toBe(704);
expect(clampImageEdge(1280)).toBe(1280);
diff --git a/server/lib/README.md b/server/lib/README.md
index c4efe652ea..83ec5bc83e 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -804,3 +804,5 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `musicVideoMotion.js` | `MOTION_CONTINUITY_CLAUSE`: the clause every Music Video motion (i2v) prompt ends with, pinning the reference frame's lighting, time of day and palette. Shared by `handoff.js` and the client board. |
| `musicVideoConditioning.js` | `musicVideoStyleImages`, `musicVideoStylePrompt`, `musicVideoStyleBasis`, and `musicVideoStyleReferenceCapacity` supply bounded moodboard conditioning and text fallback; `musicVideoConditioningReferences(project, scene)` selects the approved character sheet and scene's mapped set plate, with capped project-wide fallback; shared by board and production. |
| `musicVideoMediumPlan.js` | `normalizeMusicVideoProductionPolicy`, `planMusicVideoMedia`, `summarizeMusicVideoMediumPlan`, and `codeFirstProductionAssets`: pinned shot media, union-of-intervals video allowance, and selected-asset preflight shared by planning and Board review. |
+
+| `imageLimits.js` | MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS — browser-safe image generation caps shared with validation. |
diff --git a/server/lib/imageLimits.js b/server/lib/imageLimits.js
new file mode 100644
index 0000000000..6d0216228b
--- /dev/null
+++ b/server/lib/imageLimits.js
@@ -0,0 +1,8 @@
+// gpt-image-2 (codex backend) caps at 3840px per edge and 8,294,400 total
+// pixels. Mirror the ceiling for every image-gen route. Local mflux can
+// render up to 3840 in principle but is impractically slow past ~2048 — the
+// UI's `compatible: ['codex']` filter on the 4K presets keeps those out of
+// the local picker. Shared so the cap and refinement message stay identical
+// across schemas.
+export const MAX_IMAGE_EDGE = 3840;
+export const MAX_IMAGE_PIXELS = 8_294_400;
diff --git a/server/lib/index.js b/server/lib/index.js
index 10ab68477d..b6dbfea1f4 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -787,3 +787,6 @@ export * from './musicVideoAspect.js';
export * from './musicVideoMotion.js';
export * from './musicVideoMediumPlan.js';
+
+// Flat: validation re-exports these same bindings.
+export * from './imageLimits.js';
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 970bbc868c..e357eb4fdd 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -1,3 +1,5 @@
+import { MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from './imageLimits.js';
+export { MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from './imageLimits.js';
import { CREDENTIALS } from './credentialRegistry.js';
import { DEFAULT_BACKUP_CRON, MIN_RETENTION_COUNT, MAX_RETENTION_COUNT } from './backupConfig.js';
import { z } from 'zod';
@@ -78,14 +80,6 @@ export const gitDeleteBranchBodySchema = z.object({
});
-// gpt-image-2 (codex backend) caps at 3840px per edge and 8,294,400 total
-// pixels. Mirror the ceiling for every image-gen route. Local mflux can
-// render up to 3840 in principle but is impractically slow past ~2048 — the
-// UI's `compatible: ['codex']` filter on the 4K presets keeps those out of
-// the local picker. Shared so the cap and refinement message stay identical
-// across schemas.
-export const MAX_IMAGE_EDGE = 3840;
-export const MAX_IMAGE_PIXELS = 8_294_400;
export const imageEdgeSchema = z.number().int().min(64).max(MAX_IMAGE_EDGE).optional();
export const refineImagePixelCap = (d) =>
!(d.width && d.height) || d.width * d.height <= MAX_IMAGE_PIXELS;