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: clamp invalid kind, generic migration warning, auto-create on expand for unsaved drafts
[._.]/ Adam Eivyf029e19f4b90
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsxindex 5d8d7ca9c8..c873dae27f 100644--- a/client/src/pages/UniverseBuilder.jsx+++ b/client/src/pages/UniverseBuilder.jsx@@ -637,12 +637,14 @@ export default function UniverseBuilder() {if (expandedDraft.compositeSheets?.length) {setRenderOpts((r) => ({ ...r, promptMode: 'sheets' }));}- // Auto-persist expansion if the world is already saved — otherwise the- // user clicks Render and hits "No prompts to render" because the disk- // copy still has empty categories. New (unsaved) drafts still need a- // manual Save since they have no name yet.- if (selectedId && expandedDraft.name?.trim()) {- const updated = await updateUniverse(selectedId, {+ // Auto-persist expansion when the draft has a name. Updates the existing+ // record when one is selected; creates a new one when the user has only+ // typed a name + starter prompt and clicked Expand. The create path is+ // important for the canon section's visibility — it's gated on+ // `selectedId && draft.id === selectedId`, so without an id the user+ // can't see/manage the canon arrays just merged into the draft.+ if (expandedDraft.name?.trim()) {+ const payload = {name: expandedDraft.name.trim(),starterPrompt: expandedDraft.starterPrompt || '',logline: expandedDraft.logline || '',@@ -656,12 +658,18 @@ export default function UniverseBuilder() {influences: ensureInfluences(expandedDraft.influences),locked: expandedDraft.locked || {},llm: expandedDraft.llm || {},- }).catch((e) => { toast.error(`Auto-save after expand failed: ${e.message}`); return null; });- if (updated) {+ };+ const saved = selectedId+ ? await updateUniverse(selectedId, payload).catch((e) => { toast.error(`Auto-save after expand failed: ${e.message}`); return null; })+ : await createUniverse(payload).catch((e) => { toast.error(`Auto-save after expand failed: ${e.message}`); return null; });+ if (saved) {setWorlds((prev) => {- const without = prev.filter((w) => w.id !== updated.id);- return [updated, ...without];+ const without = prev.filter((w) => w.id !== saved.id);+ return [saved, ...without];});+ // New record: route to its id so the canon section gates flip and+ // subsequent draft state reflects the persisted record.+ if (!selectedId) goToWorld(saved.id);toast.success(expandToast({variationCount: total,sheetCount: expandedDraft.compositeSheets?.length || 0,diff --git a/scripts/migrations/019-arc-volume-prompts-canon-context.js b/scripts/migrations/019-arc-volume-prompts-canon-context.jsindex 0c5e8f702f..e9a574c157 100644--- a/scripts/migrations/019-arc-volume-prompts-canon-context.js+++ b/scripts/migrations/019-arc-volume-prompts-canon-context.js@@ -107,7 +107,7 @@ export default {` data.sample/prompts/stages/${filename}\n` +` against your current:\n` +` data/prompts/stages/${filename}\n` +- ` and add the new "World canon" block above the categories block.`,+ ` and add the new "World canon" block in the same position as in the sample template.`,);skipped++;continue;diff --git a/server/services/universeBuilderExpand.js b/server/services/universeBuilderExpand.jsindex d6a0d15e3d..bab90dce26 100644--- a/server/services/universeBuilderExpand.js+++ b/server/services/universeBuilderExpand.js@@ -224,12 +224,17 @@ const normalizeCategories = (raw) => {let variations = [];if (Array.isArray(node)) variations = node;else if (Array.isArray(node?.variations)) variations = node.variations;- // Forward the LLM-returned `kind` (if present) so sanitizeCategory can- // honor it. Without this passthrough, every custom bucket falls back to- // the WORLD_CATEGORY_DEFAULT_KINDS map (or `other`), and "kind"-tagged+ // Forward the LLM-returned `kind` (if present + valid) so sanitizeCategory+ // can honor it. Without this passthrough, every custom bucket falls back+ // to the WORLD_CATEGORY_DEFAULT_KINDS map (or `other`), and "kind"-tagged// buckets like `factions: { kind: 'characters' }` silently land under the// wrong canon trunk in the UI despite the prompt contract advertising it.- const rawKind = node && typeof node === 'object' && !Array.isArray(node) ? node.kind : undefined;+ // Clamp invalid LLM values (e.g. "people") at the boundary — drop them so+ // sanitizeCategory falls back to default. sanitizeCategory would clamp+ // again, but doing it here also defends the Zod route schema which+ // rejects unknown enum values on a subsequent save round-trip.+ const llmKind = node && typeof node === 'object' && !Array.isArray(node) ? node.kind : undefined;+ const rawKind = CATEGORY_KINDS.includes(llmKind) ? llmKind : undefined;out[key] = {...(rawKind !== undefined ? { kind: rawKind } : {}),// Clamp to the same per-category cap the route schema enforces (50)