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
feat: Universe Canon UI — lock toggle, tag chips, from-series badge per card
[._.]/ Adam Eivy8147e80f4f61
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 09957dbd5f..a934924cae 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,26 @@## Added+- **Universe Canon page — lock toggle, tag chips, and "from series" badge on every card.**+ Phase 2a of the Universe-as-Canon UI. Each `CanonCard` (used on both the+ Universe Canon page and the per-series Nouns page) now renders:+ - A **Lock / Unlock** button (only on pages that pass `onToggleLock`; the+ Nouns page omits it since per-series canon doesn't have universe-level+ locks). When the entry is locked, the card border picks up the accent+ color, a `Locked` pill appears next to the name, the "AI: differentiate"+ button disables with an "Unlock to refine" tooltip, and the toggle button+ flips to "Unlock" with an unlock-icon glyph.+ - A `from series` badge (titled with the introducing series id) when the+ entry's `sourceSeriesId` is set — so a user scanning the universe+ immediately sees which canon came from prose extraction vs. universe+ expand or manual authorship.+ - A row of tag chips when `entry.tags[]` has items — surfaces the+ `landscape` / `vehicle` / etc. tags the categories→canon backfill+ stamps, plus any tags the user adds later.+ New client helper `setUniverseCanonLock(universeId, kind, entryId, locked)`+ calls the Phase 1 `PATCH /api/universe-builder/:id/canon/:kind/:entryId/lock`+ route. ESLint clean, Vite production build green.+- **Universe-as-Canon lock semantics — series-extracted canon arrives auto-locked.**Every canon entry on a universe (characters/settings/objects) can now carry a`locked: true` flag, plus `prompt`, `tags`, `source`, and `sourceSeriesId`diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsxindex 3eca151dad..44d51364bc 100644--- a/client/src/components/pipeline/CanonCard.jsx+++ b/client/src/components/pipeline/CanonCard.jsx@@ -8,7 +8,7 @@*/import { useEffect, useRef } from 'react';-import { Loader2, ImagePlus, WandSparkles } from 'lucide-react';+import { Loader2, ImagePlus, WandSparkles, Lock, Unlock } from 'lucide-react';import useMediaJobProgress from '../../hooks/useMediaJobProgress';import MediaJobThumb from './MediaJobThumb';@@ -20,9 +20,19 @@ export default function CanonCard({// Cross-reference usage: `[{ seriesId, seriesName, issueCount, issueIds }, ...]`// populated lazily by the Universe Canon page. Null while still loading.usage = null,+ // Optional — NounsStage omits this so per-series canon stays+ // unlockable-only at the universe level. Called with `(entryId, nextLocked)`.+ onToggleLock = null,+ togglingLock = false,}) {const description = kind.descFor(entry);const refs = Array.isArray(entry.imageRefs) ? entry.imageRefs : [];+ const locked = entry.locked === true;+ const tags = Array.isArray(entry.tags) ? entry.tags.filter(Boolean) : [];+ // Refine + Render guarded against locked entries — the server returns 409+ // on refine; UI surfaces that as a disabled button with an explanatory tip+ // so the user doesn't fire a doomed request.+ const refineBlockedByLock = locked && !!onToggleLock;// settledRef prevents duplicate completion callbacks under React 18// StrictMode's mount→cleanup→mount double-fire in dev. MediaJobThumb@@ -43,29 +53,67 @@ export default function CanonCard({}, [inFlightJobId, status, filename, error, entry.id, onJobCompleted, onJobFailed]);return (- <li className="rounded border border-port-border bg-port-bg/60 p-2">+ <li className={`rounded border bg-port-bg/60 p-2 ${locked ? 'border-port-accent/40' : 'border-port-border'}`}><div className="flex items-start gap-3"><div className="flex-1 min-w-0">- <div className="flex items-center gap-2">+ <div className="flex items-center gap-2 flex-wrap"><span className="text-sm text-white font-medium truncate">{entry.name}</span>{entry.aliases?.length ? (<span className="text-[10px] text-gray-500 truncate">aka {entry.aliases.join(', ')}</span>) : null}+ {locked ? (+ <span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-port-accent/15 text-port-accent text-[9px] uppercase tracking-wider">+ <Lock size={9} /> Locked+ </span>+ ) : null}+ {entry.sourceSeriesId ? (+ <span+ className="inline-flex items-center px-1.5 py-0.5 rounded bg-port-card border border-port-border text-[9px] uppercase tracking-wider text-gray-400"+ title={`Introduced by series ${entry.sourceSeriesId}`}+ >+ from series+ </span>+ ) : null}</div>+ {tags.length > 0 ? (+ <div className="flex items-center gap-1 mt-1 flex-wrap">+ {tags.map((tag) => (+ <span key={tag} className="px-1.5 py-0.5 rounded-full bg-port-card border border-port-border text-[9px] text-gray-400">+ {tag}+ </span>+ ))}+ </div>+ ) : null}<p className="text-xs text-gray-400 mt-1 line-clamp-3 whitespace-pre-wrap">{description || <em className="text-gray-600">No description yet.</em>}</p></div><div className="shrink-0 flex flex-col gap-1 items-stretch">+ {onToggleLock ? (+ <button+ type="button"+ onClick={() => onToggleLock(entry.id, !locked)}+ disabled={togglingLock}+ className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"+ title={locked+ ? `Unlock ${entry.name} so refine / differentiate / re-extract can modify it`+ : `Lock ${entry.name} so AI passes don't rewrite it`}+ >+ {togglingLock ? <Loader2 size={10} className="animate-spin" /> : (locked ? <Unlock size={10} /> : <Lock size={10} />)}+ {locked ? 'Unlock' : 'Lock'}+ </button>+ ) : null}{kind.key === 'characters' && onRefine ? (<buttontype="button"onClick={() => onRefine(entry.id)}- disabled={refining || refineDisabled}+ disabled={refining || refineDisabled || refineBlockedByLock}className="inline-flex items-center justify-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"- title={`Rewrite ${entry.name}'s description so they render distinct from every other character`}+ title={refineBlockedByLock+ ? `Unlock ${entry.name} to refine`+ : `Rewrite ${entry.name}'s description so they render distinct from every other character`}>{refining ? <Loader2 size={10} className="animate-spin" /> : <WandSparkles size={10} />}AI: differentiatediff --git a/client/src/pages/UniverseCanon.jsx b/client/src/pages/UniverseCanon.jsxindex a2b208a997..7c1a0b4f8f 100644--- a/client/src/pages/UniverseCanon.jsx+++ b/client/src/pages/UniverseCanon.jsx@@ -8,7 +8,7 @@* universe references.*/-import { useCallback, useEffect, useMemo, useState } from 'react';+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { Link, useParams } from 'react-router-dom';import {Library, Loader2, Users, MapPin, Package, Globe2, Wand2, ArrowLeft,@@ -21,6 +21,7 @@ import {differentiateUniverseCast,updateUniverse,getUniverseCanonUsage,+ setUniverseCanonLock,} from '../services/apiUniverseBuilder';import { generateImage, getSettings } from '../services/apiSystem';import { composeStyledPrompt } from '../lib/composeStyledPrompt';@@ -36,11 +37,11 @@ import {const KINDS = [{- key: 'characters', label: 'Characters', singular: 'character', icon: Users,+ key: 'characters', apiKind: 'character', label: 'Characters', singular: 'character', icon: Users,descFor: (c) => c.physicalDescription || c.description || '',},{- key: 'settings', label: 'Places', singular: 'place', icon: MapPin,+ key: 'settings', apiKind: 'setting', label: 'Places', singular: 'place', icon: MapPin,descFor: (s) => [s.description,s.palette ? `Palette: ${s.palette}` : '',@@ -48,7 +49,7 @@ const KINDS = [].filter(Boolean).join('. '),},{- key: 'objects', label: 'Objects', singular: 'object', icon: Package,+ key: 'objects', apiKind: 'object', label: 'Objects', singular: 'object', icon: Package,descFor: (o) => o.description || o.significance || '',},];@@ -62,6 +63,11 @@ export default function UniverseCanon() {const [renderingJobs, setRenderingJobs] = useState({});const [refiningId, setRefiningId] = useState(null);const [differentiating, setDifferentiating] = useState(false);+ const [togglingLockId, setTogglingLockId] = useState(null);+ // Ref mirrors togglingLockId for the reentrancy guard so handleToggleLock+ // keeps a stable identity across lock toggles — otherwise it would change+ // every time togglingLockId flips, re-rendering every KindSection + card.+ const togglingLockRef = useRef(null);const [extractText, setExtractText] = useState('');const [extractOpen, setExtractOpen] = useState(false);const [preview, setPreview] = useState(null);@@ -157,6 +163,19 @@ export default function UniverseCanon() {toast.success(`Differentiated ${result.touched}/${result.touched + result.skipped} characters — ${(result.rationale || '').slice(0, 140)}`);};+ const handleToggleLock = useCallback(async (kind, entryId, nextLocked) => {+ if (togglingLockRef.current) return;+ togglingLockRef.current = entryId;+ setTogglingLockId(entryId);+ const result = await setUniverseCanonLock(universeId, kind.apiKind, entryId, nextLocked)+ .catch((err) => { toast.error(err.message || 'Lock toggle failed'); return null; });+ togglingLockRef.current = null;+ if (mountedRef.current) setTogglingLockId(null);+ if (!result || !mountedRef.current) return;+ setUniverse(result.universe);+ toast.success(`${result.entry?.name || 'Entry'} ${nextLocked ? 'locked' : 'unlocked'}`);+ }, [universeId, mountedRef]);+const handleRefineCharacter = async (entryId) => {if (!universe || refiningId) return;setRefiningId(entryId);@@ -308,6 +327,8 @@ export default function UniverseCanon() {onPreview={openPreview}onRefine={handleRefineCharacter}refiningId={refiningId}+ onToggleLock={(entryId, nextLocked) => handleToggleLock(kind, entryId, nextLocked)}+ togglingLockId={togglingLockId}/>))}@@ -316,7 +337,7 @@ export default function UniverseCanon() {);}-function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId }) {+function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onToggleLock, togglingLockId }) {const Icon = kind.icon;return (<section className="rounded-lg border border-port-border bg-port-card/40">@@ -344,6 +365,8 @@ function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompletedrefining={refiningId === entry.id}refineDisabled={!!refiningId && refiningId !== entry.id}usage={usage?.[entry.id] || null}+ onToggleLock={onToggleLock}+ togglingLock={togglingLockId === entry.id}/>))}</ul>diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.jsindex 43efa8f669..29944426b6 100644--- a/client/src/services/apiUniverseBuilder.js+++ b/client/src/services/apiUniverseBuilder.js@@ -168,3 +168,13 @@ export const differentiateUniverseCast = (universeId, { providerId, model } = {}// issueCount }`. Read-only aggregation.export const getUniverseCanonUsage = (universeId) =>request(`/universe-builder/${encodeURIComponent(universeId)}/canon-usage`);++// Toggle the `locked` flag on a single canon entry. Locked entries are+// protected from AI rewrite paths (refine returns 409; differentiate skips+// them at apply time; re-extract appends evidence only). `kind` must be+// 'character' | 'setting' | 'object' (the singular BIBLE_KIND values).+export const setUniverseCanonLock = (universeId, kind, entryId, locked) =>+ request(`/universe-builder/${encodeURIComponent(universeId)}/canon/${encodeURIComponent(kind)}/${encodeURIComponent(entryId)}/lock`, {+ method: 'PATCH',+ body: JSON.stringify({ locked }),+ });