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: tighten validation + fix UI fallback gaps

Adam Eivy28484a03dab2
diff --git a/client/src/components/writers-room/AnalysisHistory.jsx b/client/src/components/writers-room/AnalysisHistory.jsx
index 72ad4ad5eb..5a36a90645 100644
--- a/client/src/components/writers-room/AnalysisHistory.jsx
+++ b/client/src/components/writers-room/AnalysisHistory.jsx
@@ -1,12 +1,15 @@
import { useEffect, useState } from 'react';
-import { AlertTriangle, Check, Clapperboard, FileSignature, Loader2, RotateCcw, Sparkles, Users } from 'lucide-react';
+import { AlertTriangle, Check, Clapperboard, FileSignature, Loader2, MapPin, RotateCcw, Sparkles, Users } from 'lucide-react';
import toast from '../ui/Toast';
import { listWritersRoomAnalyses, getWritersRoomAnalysis } from '../../services/apiWritersRoom';
import { timeAgo } from '../../utils/formatters';
import useMounted from '../../hooks/useMounted';
-const KIND_ICON = { evaluate: Sparkles, format: FileSignature, script: Clapperboard, characters: Users };
-const KIND_LABEL = { evaluate: 'Evaluate', format: 'Format', script: 'Adapt', characters: 'Characters' };
+// Icon + label maps must include every kind from `ANALYSIS_KINDS`. Adding a
+// new analysis kind without registering it here would render the history row
+// with the fallback (raw kind string), so keep these two maps in sync.
+const KIND_ICON = { evaluate: Sparkles, format: FileSignature, script: Clapperboard, characters: Users, settings: MapPin };
+const KIND_LABEL = { evaluate: 'Evaluate', format: 'Format', script: 'Adapt', characters: 'Characters', settings: 'Settings' };
const SEVERITY_COLOR = {
major: 'text-port-error border-port-error/40',
diff --git a/client/src/components/writers-room/StagePromptModelPicker.jsx b/client/src/components/writers-room/StagePromptModelPicker.jsx
index 38f4284464..551e245120 100644
--- a/client/src/components/writers-room/StagePromptModelPicker.jsx
+++ b/client/src/components/writers-room/StagePromptModelPicker.jsx
@@ -30,7 +30,14 @@ export default function StagePromptModelPicker({ stageName, label = 'Stage LLM',
const persist = async (next) => {
setSaving(true);
- setStage((prev) => ({ ...prev, ...next }));
+ // Snapshot previous stage so a non-OK response can roll back the
+ // optimistic update — otherwise the UI would keep showing a
+ // provider/model that wasn't actually persisted server-side.
+ let prevStage = null;
+ setStage((prev) => {
+ prevStage = prev;
+ return { ...prev, ...next };
+ });
const res = await fetch(`/api/prompts/${encodeURIComponent(stageName)}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
@@ -40,7 +47,10 @@ export default function StagePromptModelPicker({ stageName, label = 'Stage LLM',
}),
});
setSaving(false);
- if (!res.ok) toast.error(`Failed to save ${label}: ${await res.text().catch(() => res.statusText)}`);
+ if (!res.ok) {
+ setStage(prevStage);
+ toast.error(`Failed to save ${label}: ${await res.text().catch(() => res.statusText)}`);
+ }
};
// Hooks must run in the same order every render — keep useMemo above the
diff --git a/client/src/lib/composeStyledPrompt.js b/client/src/lib/composeStyledPrompt.js
index 1239600def..53cb838ad9 100644
--- a/client/src/lib/composeStyledPrompt.js
+++ b/client/src/lib/composeStyledPrompt.js
@@ -10,8 +10,12 @@ export function composeStyledPrompt(userPrompt, userNegative, preset) {
if (!preset) return { prompt, negativePrompt: negative };
const stylePart = (preset.prompt || '').trim();
const styleNeg = (preset.negativePrompt || '').trim();
+ // Avoid trailing ". " when only one of the two parts is non-empty so the
+ // composed prompt is clean and deterministic regardless of which input
+ // is missing.
+ const composedPrompt = stylePart && prompt ? `${stylePart}. ${prompt}` : (stylePart || prompt);
return {
- prompt: stylePart ? `${stylePart}. ${prompt}` : prompt,
+ prompt: composedPrompt,
negativePrompt: [negative, styleNeg].filter(Boolean).join(', '),
};
}
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index dc8bc3ef92..dd0090c110 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -17,7 +17,7 @@ import { join, basename } from 'path';
import { tmpdir } from 'os';
import { randomUUID } from 'crypto';
import { promisify } from 'util';
-import { ensureDir, PATHS, readJSONFile, atomicWrite } from '../../lib/fileUtils.js';
+import { ensureDir, PATHS, readJSONFile, atomicWrite, UUID_RE } from '../../lib/fileUtils.js';
import { ServerError } from '../../lib/errorHandler.js';
import { videoGenEvents } from './events.js';
import { broadcastSse, attachSseClient as attachSse, closeJobAfterDelay, PYTHON_NOISE_RE } from '../../lib/sseUtils.js';
@@ -486,12 +486,17 @@ export async function stitchVideos(videoIds) {
// missing-input / ffmpeg / file-system failure so the route can map it to
// a clean HTTP status.
export async function upscaleHistoryItem(historyId) {
+ // Validate the input arg first — failing here surfaces a clean 400 even if
+ // the history file happens to contain a record with a malformed id, and
+ // it short-circuits the loadHistory I/O for obviously-bogus requests.
+ // Use the shared strict UUID regex (the prior /^[a-f0-9-]{36}$/i pattern
+ // accepted non-UUID 36-char strings like all-hyphens).
+ if (typeof historyId !== 'string' || !UUID_RE.test(historyId)) {
+ throw new ServerError('Invalid history id', { status: 400, code: 'VALIDATION_ERROR' });
+ }
const history = await loadHistory();
const item = history.find((h) => h.id === historyId);
if (!item) throw new ServerError('Video not found', { status: 404, code: 'NOT_FOUND' });
- if (!/^[a-f0-9-]{36}$/i.test(item.id)) {
- throw new ServerError('Invalid history id', { status: 400, code: 'VALIDATION_ERROR' });
- }
if (item.upscaledFrom) {
throw new ServerError('Cannot upscale an already-upscaled video', { status: 400, code: 'ALREADY_UPSCALED' });
}