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
address review (opencode): treat a saved record with a missing generation as legacy, not fresh
[._.]/ Adam Eivy6635dc62df48
diff --git a/client/src/components/creative-commission/commissionForm.js b/client/src/components/creative-commission/commissionForm.jsindex dad54dc0e2..74145f9433 100644--- a/client/src/components/creative-commission/commissionForm.js+++ b/client/src/components/creative-commission/commissionForm.js@@ -270,15 +270,22 @@ export function toForm(c) {timezone: c.schedule?.timezone || null,},// Per-ability generation (#2769): only the selected type's fields, filled- // from the record or the type's defaults. A BLANK/new commission (no- // `generation` object at all — e.g. `blankForm()`'s `toForm({})`) seeds- // every key's fresh-commission default; a REAL record (however old)- // projects through generationToForm, which resolves an absent key to its- // spec `legacyAbsent` reading when the key has one — durationMode's is- // 'manual', so an existing record with no key still projects as a fixed- // length, matching abilityAdapters.js, while a brand-new commission seeds- // 'auto' (the #4494 product choice).- generation: c.generation == null+ // from the record or the type's defaults. NOT YET PERSISTED (no `id` —+ // `blankForm()`'s `toForm({})`, or a create-drawer harness that pre-seeds+ // just a brief before the user has touched generation at all) with no+ // `generation` opinion either seeds every key's fresh-commission default;+ // anything else — any record that HAS an id, or that already carries a+ // `generation` object of its own — projects through generationToForm,+ // which resolves an absent key to its spec `legacyAbsent` reading when+ // the key has one. durationMode's is 'manual', so an existing record+ // with no key still projects as a fixed length (matching+ // abilityAdapters.js) while a genuinely brand-new commission seeds 'auto'+ // (the #4494 product choice). Gating on `c.generation == null` alone+ // would treat a saved record whose generation object is missing/null the+ // same as a fresh one; requiring `!c.id` too keeps that record on the+ // legacy-aware path (ids are always minted server-side, never present on+ // an unsaved commission).+ generation: c.generation == null && !c.id? { ...GENERATION_DEFAULTS_BY_ABILITY[abilityOr(c.targetAbility)] }: generationToForm(c.targetAbility, c.generation),// Which AI provider/model processes the commission's CD stages. Emptydiff --git a/client/src/components/creative-commission/commissionForm.test.js b/client/src/components/creative-commission/commissionForm.test.jsindex 7bbd359e15..3245e2858e 100644--- a/client/src/components/creative-commission/commissionForm.test.js+++ b/client/src/components/creative-commission/commissionForm.test.js@@ -227,6 +227,19 @@ describe('commissionForm helpers', () => {expect(generationToForm('video', {}).aspectRatio).toBe('16:9');});+ it('treats a SAVED record with a missing generation object as legacy, not fresh', () => {+ // A record with an `id` has already been persisted — it is never the+ // blank/new-commission case, even if its `generation` object happens to+ // be absent or null (which a real API response never actually sends,+ // but toForm() must not silently mis-seed one that did).+ expect(toForm({ id: 'c-1', targetAbility: 'video' }).generation.durationMode).toBe('manual');+ expect(toForm({ id: 'c-1', targetAbility: 'video', generation: null }).generation.durationMode).toBe('manual');+ // The blank/new case is unaffected: no id AND no generation still seeds+ // the fresh default, including when other fields (a pre-filled brief)+ // are already present.+ expect(toForm({ brief: { intent: 'x' } }).generation.durationMode).toBe('auto');+ });+it('toPayload round-trips a non-video commission', () => {const form = toForm({ name: 'Daily Stills', targetAbility: 'image', brief: { intent: 'x' }, generation: { imageCount: 2 } });const payload = toPayload(form);