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([character-bible-simplify-followups]): copilot pass 2
[._.]/ Adam Eivy4c8734c2c62f
diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsxindex 97fcd13b50..2a38613cc1 100644--- a/client/src/components/pipeline/CanonCard.jsx+++ b/client/src/components/pipeline/CanonCard.jsx@@ -205,7 +205,10 @@ function WardrobeSection({ wardrobes, editable, onChange }) {// Mint a server-shaped `wd-<uuid>` client-side so the React key stays// stable across the pending → persisted promotion. Server `ensureId`// preserves any non-empty string, so this id round-trips unchanged.- const id = `wd-${(crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;+ // `globalThis.crypto` — bare `crypto?.…` ReferenceErrors when the+ // identifier is undeclared (e.g. some non-secure contexts); going+ // through `globalThis` short-circuits cleanly to the Date+Math fallback.+ const id = `wd-${(globalThis.crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;setPendingNew((prev) => [...prev, { id, name: '', description: '' }]);};diff --git a/client/src/components/pipeline/CanonCard.test.jsx b/client/src/components/pipeline/CanonCard.test.jsxindex ca168f9c54..9e7a603434 100644--- a/client/src/components/pipeline/CanonCard.test.jsx+++ b/client/src/components/pipeline/CanonCard.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi } from 'vitest';-import { render, screen } from '@testing-library/react';+import { render, screen, fireEvent } from '@testing-library/react';// CanonCard subscribes to live job progress via the socket-backed hook; the// chip-label code path doesn't touch it, but the hook would otherwise wire@@ -72,3 +72,56 @@ describe('CanonCard — "from series" provenance chip', () => {expect(screen.queryByText(/from ser-missing/)).not.toBeInTheDocument();});});++describe('CanonCard — wardrobe pending-row promotion', () => {+ const renderEditable = (onPatchEntry) => render(+ <CanonCard+ kind={kind}+ entry={{ ...baseEntry, wardrobes: [] }}+ onRender={() => {}}+ onPatchEntry={onPatchEntry}+ />,+ );++ it('promotes a pending wardrobe row on name blur with a client-minted wd-<uuid> id', () => {+ const onPatchEntry = vi.fn();+ renderEditable(onPatchEntry);+ fireEvent.click(screen.getByText(/Outfits/));+ fireEvent.click(screen.getByText(/Add outfit/));+ const nameInput = screen.getByPlaceholderText(/Outfit name/);+ fireEvent.change(nameInput, { target: { value: 'Wedding' } });+ fireEvent.blur(nameInput);+ expect(onPatchEntry).toHaveBeenCalledTimes(1);+ const [entryId, patch] = onPatchEntry.mock.calls[0];+ expect(entryId).toBe('ent-1');+ expect(patch.wardrobes).toHaveLength(1);+ expect(patch.wardrobes[0].name).toBe('Wedding');+ // Server-shaped id minted client-side — survives promotion verbatim.+ expect(patch.wardrobes[0].id).toMatch(/^wd-/);+ expect(patch.wardrobes[0].id).not.toMatch(/^pending-/);+ });++ it('does not promote when the user only types a description (name still empty)', () => {+ const onPatchEntry = vi.fn();+ renderEditable(onPatchEntry);+ fireEvent.click(screen.getByText(/Outfits/));+ fireEvent.click(screen.getByText(/Add outfit/));+ const descInput = screen.getByPlaceholderText(/What's the character wearing/);+ fireEvent.change(descInput, { target: { value: 'Cream linen' } });+ fireEvent.blur(descInput);+ // Description-only commits stay in the local pendingNew buffer — server+ // sanitizer would drop a nameless wardrobe row, so the parent never sees it.+ expect(onPatchEntry).not.toHaveBeenCalled();+ });++ it('does not promote on whitespace-only name', () => {+ const onPatchEntry = vi.fn();+ renderEditable(onPatchEntry);+ fireEvent.click(screen.getByText(/Outfits/));+ fireEvent.click(screen.getByText(/Add outfit/));+ const nameInput = screen.getByPlaceholderText(/Outfit name/);+ fireEvent.change(nameInput, { target: { value: ' ' } });+ fireEvent.blur(nameInput);+ expect(onPatchEntry).not.toHaveBeenCalled();+ });+});diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsxindex 4eff50b11f..bb2dcf0dd7 100644--- a/client/src/components/universe/CharacterDetailEditor.jsx+++ b/client/src/components/universe/CharacterDetailEditor.jsx@@ -246,7 +246,7 @@ export default function CharacterDetailEditor({ entry, onPatch, onExpand, expand// mints a fresh `<kind>-<uuid>` id under its own convention; without// that strip the sanitizer would round-trip the client prefix back onto// the persisted row.- const id = `pending-${section.key}-${(crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;+ const id = `pending-${section.key}-${(globalThis.crypto?.randomUUID?.() ?? Date.now().toString(36) + Math.random().toString(36).slice(2))}`;const blank = { id, ...Object.fromEntries(section.columns.map((c) => [c.name, ''])) };setPendingByList((prev) => ({...prev,diff --git a/client/src/components/universe/CharacterReferenceSheetPanel.jsx b/client/src/components/universe/CharacterReferenceSheetPanel.jsxindex cfbbe40d1a..cde8f411ca 100644--- a/client/src/components/universe/CharacterReferenceSheetPanel.jsx+++ b/client/src/components/universe/CharacterReferenceSheetPanel.jsx@@ -110,6 +110,13 @@ export default function CharacterReferenceSheetPanel({const handleGenerate = async () => {if (jobId || !universeId || !entry?.id) return;+ // Abort any in-flight HEAD poll from a previous render before kicking+ // off a new one. Without this a superseded render's poll could still+ // resolve and call `onSheetCompleted` with the stale filename — the+ // server-side supersede check skips the pointer stamp but the client+ // would have already swapped the displayed filename.+ pollAbortRef.current?.abort();+ pollAbortRef.current = null;const queued = await renderCharacterReferenceSheet(universeId, entry.id).catch((err) => { toast.error(err.message || 'Sheet render failed to start'); return null; });if (!queued?.jobId) return;diff --git a/server/lib/fileUtils.js b/server/lib/fileUtils.jsindex e4234a3cfa..8b940ff58d 100644--- a/server/lib/fileUtils.js+++ b/server/lib/fileUtils.js@@ -678,13 +678,18 @@ export function makePathResolver(getRoot, { extensions, cache = false } = {}) {const safe = basename(name);if (!safe || safe === '.' || safe === '..') return null;if (extRegex && !extRegex.test(safe)) return null;- const cacheKey = memo ? (mustExist ? `must:${safe}` : `nostat:${safe}`) : null;- if (memo && memo.has(cacheKey)) return memo.get(cacheKey);+ // Refresh the root cache BEFORE the memo lookup so a getRoot() that+ // suddenly returns a new value (e.g. a test re-mocks `PATHS.x` mid-run)+ // invalidates the memo too — otherwise the old root's cached+ // resolutions would shadow the new root forever.const root = getRoot();if (root !== _root) {_root = root;_rootAbsPrefix = resolvePath(root) + PATH_SEP;+ if (memo) memo.clear();}+ const cacheKey = memo ? (mustExist ? `must:${safe}` : `nostat:${safe}`) : null;+ if (memo && memo.has(cacheKey)) return memo.get(cacheKey);const localPath = resolvePath(join(root, safe));if (!localPath.startsWith(_rootAbsPrefix)) return null;if (!mustExist) {