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

refactor: apply self-review cleanup to the commission spec split (#6816)

[._.]/ Adam Eivy028c3756756e
diff --git a/client/src/components/creative-commission/commissionForm.js b/client/src/components/creative-commission/commissionForm.js
index 90b74c5fec..dad54dc0e2 100644
--- a/client/src/components/creative-commission/commissionForm.js
+++ b/client/src/components/creative-commission/commissionForm.js
@@ -26,7 +26,7 @@ import {
// module is imported from a server-workspace parity test
// (creativeCommissionSpec.parity.test.js), which fails with ERR_MODULE_NOT_FOUND
// if anything here pulls in a browser-only package.
-import { RENDER_TARGET_BACKEND_AUTO as RENDER_BACKEND_AUTO, MODE_LABELS } from '../../lib/imageGenModes.js';
+import { RENDER_TARGET_BACKEND_AUTO as RENDER_BACKEND_AUTO, modeLabel } from '../../lib/imageGenModes.js';
// Pause and Delete are real STOPS, not just "skip the next tick": the server also
// tears down the Creative Director projects the commission already spawned
@@ -93,10 +93,10 @@ const BACKEND_FIELD_META = {
};
// A render-backend mode's display label. Every real backend reads from the
-// shared MODE_LABELS (client/src/lib/imageGenModes.js) so a backend added
+// shared `modeLabel` (client/src/lib/imageGenModes.js) so a backend added
// there (fal, reactor, agy, …) is labeled here automatically — the drift that
// left the video/image backend pickers behind generationModes.js for months.
-const backendOptionLabel = (mode) => (mode === RENDER_BACKEND_AUTO ? 'Auto (install default)' : (MODE_LABELS[mode] || mode));
+const backendOptionLabel = (mode) => (mode === RENDER_BACKEND_AUTO ? 'Auto (install default)' : modeLabel(mode));
// Build one field descriptor from a generation key's spec descriptor
// (type/bounds/values) plus its presentation metadata above. `type: 'id'` keys
@@ -279,8 +279,8 @@ export function toForm(c) {
// length, matching abilityAdapters.js, while a brand-new commission seeds
// 'auto' (the #4494 product choice).
generation: c.generation == null
- ? { ...GENERATION_DEFAULTS_BY_ABILITY[abilityOr(c.targetAbility || 'video')] }
- : generationToForm(c.targetAbility || 'video', c.generation),
+ ? { ...GENERATION_DEFAULTS_BY_ABILITY[abilityOr(c.targetAbility)] }
+ : generationToForm(c.targetAbility, c.generation),
// Which AI provider/model processes the commission's CD stages. Empty
// providerId → the install's default AI Assignment.
assignment: {
diff --git a/client/src/components/creative-commission/commissionForm.test.js b/client/src/components/creative-commission/commissionForm.test.js
index 9a20c076c4..7bbd359e15 100644
--- a/client/src/components/creative-commission/commissionForm.test.js
+++ b/client/src/components/creative-commission/commissionForm.test.js
@@ -5,6 +5,7 @@ import {
ABILITY_OPTIONS, GENERATION_FIELDS_BY_ABILITY, GENERATION_DEFAULTS_BY_ABILITY,
generationToForm, mergeGenerationForAbility, generationToPayload,
backendFieldsForAbility, RENDER_BACKEND_AUTO,
+ IMAGE_BACKEND_OPTIONS, VIDEO_BACKEND_OPTIONS,
} from './commissionForm.js';
describe('commissionForm helpers', () => {
@@ -280,6 +281,25 @@ describe('commissionForm helpers', () => {
expect(f.generation.imageModelId).toBe('example-model');
});
+ it('round-trips a record pinned to a backend the form used to have no option for (#6816)', () => {
+ // agy (image) and fal/reactor (video) all post-date the hand-copied
+ // IMAGE_BACKEND_OPTIONS/VIDEO_BACKEND_OPTIONS arrays this form used to
+ // carry; a record already pinned to one rendered a <select> with no
+ // matching option. Deriving the options from the server enum fixes this
+ // for every mode at once, not just these three by name.
+ const image = toForm({ targetAbility: 'image', brief: { intent: 'x' }, generation: { imageMode: 'agy' } });
+ expect(image.generation.imageMode).toBe('agy');
+ expect(IMAGE_BACKEND_OPTIONS.some(([v]) => v === 'agy')).toBe(true);
+ expect(toPayload(image).generation.imageMode).toBe('agy');
+
+ for (const videoMode of ['fal', 'reactor']) {
+ const video = toForm({ targetAbility: 'video', brief: { intent: 'x' }, generation: { videoMode } });
+ expect(video.generation.videoMode).toBe(videoMode);
+ expect(VIDEO_BACKEND_OPTIONS.some(([v]) => v === videoMode)).toBe(true);
+ expect(toPayload(video).generation.videoMode).toBe(videoMode);
+ }
+ });
+
it('sends the model id for a model-bearing backend', () => {
const payload = generationToPayload('image', {
quality: 'standard', aspectRatio: '16:9', imageCount: 1, imageMode: 'local', imageModelId: 'example-model',
diff --git a/server/lib/creativeCommissionSpec.parity.test.js b/server/lib/creativeCommissionSpec.parity.test.js
index 020ecaef58..d9194a918d 100644
--- a/server/lib/creativeCommissionSpec.parity.test.js
+++ b/server/lib/creativeCommissionSpec.parity.test.js
@@ -77,6 +77,21 @@ describe('creativeCommissionSpec parity — client mirror of the generation spec
expect(CREATIVE_COMMISSION_VIDEO_MODES).toContain('reactor');
});
+ it('quality and durationMode options carry a real display label, not their raw value', async () => {
+ // The backend-mode check above only covers `type: 'backend'` fields;
+ // OPTION_LABELS-driven plain selects share the identical
+ // `OPTION_LABELS[key]?.[v] || v` fallback shape and deserve the same net —
+ // aspectRatio is deliberately excluded (its values, e.g. '16:9', already
+ // ARE their own best display string).
+ const client = await import('../../client/src/components/creative-commission/commissionForm.js');
+ for (const key of ['quality', 'durationMode']) {
+ const field = client.GENERATION_FIELDS_BY_ABILITY.video.find((f) => f.key === key);
+ for (const [value, label] of field.options) {
+ expect(label, `${key}='${value}' has no distinct display label`).not.toBe(value);
+ }
+ }
+ });
+
it('resolves an absent durationMode identically on the server adapter and the client form', async () => {
const client = await import('../../client/src/components/creative-commission/commissionForm.js');
const { legacyAbsent, default: freshDefault } = GENERATION_KEY_DEFS.durationMode;
@@ -85,19 +100,19 @@ describe('creativeCommissionSpec parity — client mirror of the generation spec
// Server: an ability's sanitizer resolves a generation object with no
// durationMode key to the LEGACY reading (a pre-#4494 record's implicit
- // meaning), never the fresh-commission default.
+ // meaning), never the fresh-commission default. The resolution is keyed
+ // off the descriptor, not the ability (an ability only decides WHICH keys
+ // get resolved this way — coverage for that lives in the per-ability loop
+ // above), so one ability is enough to pin the mechanism.
expect(getAbilityAdapter('video').sanitizeGeneration({}).durationMode).toBe(legacyAbsent);
- expect(getAbilityAdapter('music-video').sanitizeGeneration({}).durationMode).toBe(legacyAbsent);
// Client: projecting a REAL (if sparse) record resolves identically.
expect(client.generationToForm('video', {}).durationMode).toBe(legacyAbsent);
- expect(client.generationToForm('music-video', {}).durationMode).toBe(legacyAbsent);
expect(client.toForm({ targetAbility: 'video', generation: {} }).generation.durationMode).toBe(legacyAbsent);
// A brand-new/blank commission (no record at all) seeds the fresh default
// instead — the one case the two readings are meant to disagree.
expect(client.toForm({}).generation.durationMode).toBe(freshDefault);
- expect(client.blankForm().generation.durationMode).toBe(freshDefault);
expect(client.GENERATION_DEFAULTS_BY_ABILITY.video.durationMode).toBe(freshDefault);
});
});
diff --git a/server/services/creativeCommissions/abilityAdapters.js b/server/services/creativeCommissions/abilityAdapters.js
index d15dde4928..1a1aeb3b83 100644
--- a/server/services/creativeCommissions/abilityAdapters.js
+++ b/server/services/creativeCommissions/abilityAdapters.js
@@ -47,16 +47,6 @@ function pickModel(raw) {
return isStr(raw?.model) && raw.model.trim() ? raw.model.trim() : null;
}
-// A commission's effective duration mode, made explicit: an ABSENT durationMode
-// on a real record reads as `legacyAbsent` ('manual' — the pre-#4494 behavior
-// every record without the key was already rendering), never the fresh-commission
-// `default` ('auto'). Mirrors the client form's own record projection
-// (commissionForm.js `generationToForm`) — see creativeCommissionSpec.js's
-// GENERATION_KEY_DEFS.durationMode for the compatibility split.
-function isAutoDuration(generation) {
- return (generation?.durationMode ?? GENERATION_KEY_DEFS.durationMode.legacyAbsent) === 'auto';
-}
-
// Coerce one generation value against its GENERATION_KEY_DEFS descriptor, falling
// back to the RESOLVED default when absent/invalid (absent-vs-empty: a wrong-type
// or out-of-range value falls back rather than corrupting the record).
@@ -75,6 +65,19 @@ function coerceGenerationValue(key, raw) {
return Number.isInteger(v) && v >= def.min && v <= def.max ? v : resolvedDefault(def);
}
+// A commission's effective duration mode, made explicit: an ABSENT OR INVALID
+// durationMode on a real record reads as `legacyAbsent` ('manual' — the
+// pre-#4494 behavior every record without the key was already rendering),
+// never the fresh-commission `default` ('auto'). Delegates to the same
+// coerceGenerationValue() every other key's absent-value resolution goes
+// through (rather than a bespoke `??` on the raw value), so a second key that
+// ever needs this split gets it for free. Mirrors the client form's own
+// record projection (commissionForm.js `generationToForm`) — see
+// creativeCommissionSpec.js's GENERATION_KEY_DEFS.durationMode.
+function isAutoDuration(generation) {
+ return coerceGenerationValue('durationMode', generation) === 'auto';
+}
+
// Fill an ability's generation defaults and keep ONLY that ability's keys (+ the
// universal model). Data-driven from the spec — no per-type hand-written pick
// scaffolding.