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

address review: 3 Copilot findings on v1.54.0 PR (iter 7) — 2 regressions

[._.]/ Adam Eivy12c59d40df08
diff --git a/client/src/components/worldBuilder/WorldPromptRefineModal.jsx b/client/src/components/worldBuilder/WorldPromptRefineModal.jsx
index f3de2d5bbb..de2cb22f29 100644
--- a/client/src/components/worldBuilder/WorldPromptRefineModal.jsx
+++ b/client/src/components/worldBuilder/WorldPromptRefineModal.jsx
@@ -85,9 +85,14 @@ export default function WorldPromptRefineModal({
compositeSheets: Array.isArray(compositeSheets) ? compositeSheets : [],
}), [starterPrompt, stylePrompt, negativePrompt, logline, premise, styleNotes, influences, categories, compositeSheets]);
+ // Pre-Expand drafts have starter category buckets in `originals.categories`
+ // (the WorldBuilder seeds them as empty objects so the UI can render the
+ // category editor), so checking `Object.keys.length > 0` would always be
+ // true and force the structure-aware path before the user has generated
+ // any actual variations. Count real variations instead.
const hasStructure = useMemo(() => (
- Object.keys(originals.categories).length > 0 ||
- originals.compositeSheets.length > 0
+ Object.values(originals.categories).some((cat) => (cat?.variations || []).length > 0)
+ || originals.compositeSheets.length > 0
), [originals.categories, originals.compositeSheets]);
const [feedback, setFeedback] = useState('');
@@ -123,12 +128,9 @@ export default function WorldPromptRefineModal({
const allTopLocked = WORLD_LOCKABLE_FIELDS.every((k) => locked[k]);
// The button stays enabled when there's *any* category variation or composite
// sheet present — the holistic refine flow can still tune unlocked structure
- // items even if every top-level bible field is locked.
- const hasRefinableStructure = (
- (categories && Object.values(categories).some((cat) => (cat?.variations || []).length > 0))
- || (Array.isArray(compositeSheets) && compositeSheets.length > 0)
- );
- const allLocked = allTopLocked && !hasRefinableStructure;
+ // items even if every top-level bible field is locked. Reuse the memoized
+ // hasStructure (counts real variations, not just category-key presence).
+ const allLocked = allTopLocked && !hasStructure;
const hasResult = Object.keys(refined).length > 0 || rationale !== '';
const canRefine = feedback.trim() && starterPrompt.trim() && selectedProviderId && !refining && !allLocked;
const canApply = hasResult && (refined.starterPrompt || '').trim();
diff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.js
index 03947ef320..020612e276 100644
--- a/server/lib/aiToolkit/validation.js
+++ b/server/lib/aiToolkit/validation.js
@@ -25,7 +25,9 @@ export const providerSchema = z.object({
});
export const runSchema = z.object({
- type: z.enum(['ai', 'command']),
+ // `type` defaults to 'ai' so the common case (AI run via /api/runs from
+ // RunnerPage / AIProviders / etc.) doesn't have to send it explicitly.
+ type: z.enum(['ai', 'command']).optional().default('ai'),
providerId: z.string().optional(),
model: z.string().optional(),
workspacePath: z.string().optional(),
diff --git a/server/services/worldBuilderExpand.js b/server/services/worldBuilderExpand.js
index 938ad15304..e73a67cb1c 100644
--- a/server/services/worldBuilderExpand.js
+++ b/server/services/worldBuilderExpand.js
@@ -355,8 +355,13 @@ export async function expandWorldTemplate({
`🌍 World Builder parsed JSON — keys=[${Object.keys(parsed || {}).join(",")}] categoryKeys=[${Object.keys(parsed?.categories || {}).join(",")}] compositeSheets=${Array.isArray(parsed?.compositeSheets) ? parsed.compositeSheets.length : 0}`,
);
+ // Distinguish "LLM omitted this key" (return null → client keeps draft)
+ // from "LLM returned ''" (return "" → client applies the clear). The
+ // client's pick helper in handleExpand treats null/undefined as absent
+ // and "" as an intentional value; emitting "" for both cases would
+ // clobber existing draft state on every response that misses a field.
const trimField = (value, max) =>
- typeof value === "string" ? value.trim().slice(0, max) : "";
+ typeof value === "string" ? value.trim().slice(0, max) : null;
const stylePrompt = trimField(parsed.stylePrompt, PROMPT_FRAGMENT_MAX);
const negativePrompt = trimField(parsed.negativePrompt, PROMPT_FRAGMENT_MAX);
const logline = trimField(parsed.logline, LOGLINE_MAX);