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(pipeline): clean-plate render mode for settings (Cluster A — A4)
[._.]/ Adam Eivyd2062b863269
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 920fdd427e..bcc57f5651 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,26 @@## Added+- **Clean-plate render mode for settings (Cluster A — A4).** Setting canon+ cards get a "Clean plate" button next to the existing "Render reference"+ affordance. Clicking it builds a no-people prompt variant — prefixed with+ "Empty location, no characters, no people, edge-to-edge composition"+ plus the setting's INT/EXT + time-of-day metadata in parentheses+ ("interior, night") — and dispatches through the same image-gen path as+ the regular reference render. The result lands in `imageRefs[]` like any+ other rendered ref; the user can then pin it as primary so downstream+ pipelines treat it as the location's canonical background plate. The+ composer + negative prompt live in a new `client/src/lib/cleanPlatePrompt.js`+ module (`composeCleanPlatePrompt(setting, userNegative) → { prompt,+ negativePrompt }`) so the Universe Canon and Nouns Stage call sites stay+ symmetrical. Touches:+ `client/src/lib/cleanPlatePrompt.js` (new + tests),+ `client/src/components/pipeline/CanonCard.jsx` (per-setting Clean plate+ button + `onRenderCleanPlate` callback),+ `client/src/pages/UniverseCanon.jsx` + `client/src/components/pipeline/stages/NounsStage.jsx`+ (handler that styles the plate prompt through the universe's+ stylePrompt + dispatches `generateImage`).+- **Canon entries: primary reference image (Cluster A — A3/A4/A5).** Everycharacter, place, and object canon entry gains an optional`primaryImageRef: filename | null` slot that pins one of its rendereddiff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsxindex 1af20a9ce2..40c3736fbe 100644--- a/client/src/components/pipeline/CanonCard.jsx+++ b/client/src/components/pipeline/CanonCard.jsx@@ -8,7 +8,7 @@*/import { useEffect, useRef, useState } from 'react';-import { Loader2, ImagePlus, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, ChevronDown, ChevronRight, Star } from 'lucide-react';+import { Loader2, ImagePlus, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, ChevronDown, ChevronRight, Star, Square } from 'lucide-react';import useMediaJobProgress from '../../hooks/useMediaJobProgress';import MediaJobThumb from './MediaJobThumb';@@ -220,6 +220,9 @@ export default function CanonCard({// Optional — when provided + kind is settings, surfaces inline chip pickers// for `intExt` / `timeOfDay`. Called with `(entryId, { intExt?, timeOfDay? })`.onPatchEntry = null,+ // Optional — settings-only "Render clean plate" affordance. Called with+ // `(entry)` so the parent can build the no-people prompt variant.+ onRenderCleanPlate = null,}) {const description = kind.descFor(entry);const refs = Array.isArray(entry.imageRefs) ? entry.imageRefs : [];@@ -353,6 +356,20 @@ export default function CanonCard({{inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <ImagePlus size={10} />}Render reference</button>+ {kind.key === 'settings' && onRenderCleanPlate ? (+ <button+ type="button"+ onClick={() => onRenderCleanPlate(entry)}+ disabled={!description.trim() || !!inFlightJobId}+ 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={description.trim()+ ? `Render an empty-location plate for ${entry.name} — no people, edge-to-edge`+ : 'Add a description first'}+ >+ {inFlightJobId ? <Loader2 size={10} className="animate-spin" /> : <Square size={10} />}+ Clean plate+ </button>+ ) : null}</div></div>{(refs.length > 0 || inFlightJobId) ? (diff --git a/client/src/components/pipeline/stages/NounsStage.jsx b/client/src/components/pipeline/stages/NounsStage.jsxindex 0667223c80..631bc3ee77 100644--- a/client/src/components/pipeline/stages/NounsStage.jsx+++ b/client/src/components/pipeline/stages/NounsStage.jsx@@ -33,6 +33,7 @@ import {matchCharactersInText, matchSettingsInText, matchObjectsInText,} from '../../../lib/scenePrompt';import { composeStyledPrompt } from '../../../lib/composeStyledPrompt';+import { composeCleanPlatePrompt } from '../../../lib/cleanPlatePrompt';import useMounted from '../../../hooks/useMounted';import CanonCard from '../CanonCard';import MediaPreview from '../../media/MediaPreview';@@ -244,6 +245,28 @@ export default function NounsStage({ issue, series }) {toast.success(`Rendering reference for ${entry.name}`);};+ const handleRenderCleanPlate = async (entry) => {+ if (!entry?.description?.trim()) {+ toast.error(`Add a description before generating a clean plate for ${entry.name}`);+ return;+ }+ const baseOpts = pipelineImageCfgToRenderOpts(imageCfg);+ const plate = composeCleanPlatePrompt(entry, baseOpts.negativePrompt || '');+ const styled = composeStyledPrompt(+ plate.prompt,+ plate.negativePrompt,+ universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,+ );+ const queued = await generateImage({+ ...baseOpts,+ prompt: styled.prompt,+ negativePrompt: styled.negativePrompt || undefined,+ }).catch((err) => { toast.error(err.message || 'Clean plate render failed'); return null; });+ if (!queued?.jobId || !mountedRef.current) return;+ setRenderingJobs((prev) => ({ ...prev, [entry.id]: queued.jobId }));+ toast.success(`Rendering clean plate for ${entry.name}`);+ };+// Pin a freshly-completed render onto the universe's imageRefs[]. Server// replaces the full kind list on PATCH, so we send the entire kind array// with this entry mutated. Single-user app — no race.@@ -366,6 +389,7 @@ export default function NounsStage({ issue, series }) {onRefine={handleRefineCharacter}refiningCharacterId={refiningCharacterId}onPatchEntry={(entryId, patch) => handlePatchEntry(kind, entryId, patch)}+ onRenderCleanPlate={handleRenderCleanPlate}/>))}@@ -383,7 +407,7 @@ export default function NounsStage({ issue, series }) {);}-function KindSection({ kind, all, prose, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningCharacterId, onPatchEntry }) {+function KindSection({ kind, all, prose, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningCharacterId, onPatchEntry, onRenderCleanPlate }) {const Icon = kind.icon;const inIssue = useMemo(() => kind.match(prose, all), [prose, all, kind]);const inIssueIds = useMemo(() => new Set(inIssue.map((e) => e.id || e.name)), [inIssue]);@@ -428,6 +452,7 @@ function KindSection({ kind, all, prose, renderingJobs, onRender, onJobCompletedrefining={refiningCharacterId === entry.id}refineDisabled={!!refiningCharacterId && refiningCharacterId !== entry.id}onPatchEntry={onPatchEntry}+ onRenderCleanPlate={onRenderCleanPlate}/>))}</ul>@@ -455,6 +480,7 @@ function KindSection({ kind, all, prose, renderingJobs, onRender, onJobCompletedrefining={refiningCharacterId === entry.id}refineDisabled={!!refiningCharacterId && refiningCharacterId !== entry.id}onPatchEntry={onPatchEntry}+ onRenderCleanPlate={onRenderCleanPlate}/>))}</ul>diff --git a/client/src/lib/cleanPlatePrompt.js b/client/src/lib/cleanPlatePrompt.jsnew file mode 100644index 0000000000..ab546d0e76--- /dev/null+++ b/client/src/lib/cleanPlatePrompt.js@@ -0,0 +1,43 @@+/**+ * Clean-plate prompt builder for setting canon entries (Cluster A — A4).+ *+ * A "clean plate" is the production-art term for an empty-location reference+ * shot — no people, no foreground props — used as a background plate for+ * downstream composite work. For PortOS it's a specialized variant of the+ * existing setting reference render: same model + size + style, but a+ * prompt prefix that strips character / action references and a negative+ * prompt that explicitly excludes people.+ *+ * Output mirrors `composeStyledPrompt`: `{ prompt, negativePrompt }`.+ */++const CLEAN_PLATE_PREFIX = 'Empty location, no characters, no people, edge-to-edge composition';+const CLEAN_PLATE_NEGATIVE = 'people, characters, faces, hands, figures, person';++export function composeCleanPlatePrompt(setting, userNegative = '') {+ if (!setting || typeof setting !== 'object') {+ return { prompt: CLEAN_PLATE_PREFIX, negativePrompt: CLEAN_PLATE_NEGATIVE };+ }+ // INT/EXT + time-of-day stamp the lighting/composition cues the diffusion+ // model actually weights; redundant with description sometimes but cheap.+ const intExt = setting.intExt === 'INT' ? 'interior' : setting.intExt === 'EXT' ? 'exterior' : '';+ const tod = typeof setting.timeOfDay === 'string' && setting.timeOfDay ? setting.timeOfDay : '';+ const meta = [intExt, tod].filter(Boolean).join(', ');+ const descParts = [+ setting.description?.trim() || '',+ setting.palette?.trim() ? `Palette: ${setting.palette.trim()}.` : '',+ setting.recurringDetails?.trim() || '',+ ].filter(Boolean);+ const promptSegs = [+ CLEAN_PLATE_PREFIX,+ meta ? `(${meta})` : '',+ descParts.join(' '),+ ].filter(Boolean);+ const negative = [userNegative.trim(), CLEAN_PLATE_NEGATIVE].filter(Boolean).join(', ');+ return {+ prompt: promptSegs.join('. '),+ negativePrompt: negative,+ };+}++export { CLEAN_PLATE_PREFIX, CLEAN_PLATE_NEGATIVE };diff --git a/client/src/lib/cleanPlatePrompt.test.js b/client/src/lib/cleanPlatePrompt.test.jsnew file mode 100644index 0000000000..15ddd0b2ab--- /dev/null+++ b/client/src/lib/cleanPlatePrompt.test.js@@ -0,0 +1,57 @@+import { describe, it, expect } from 'vitest';+import { composeCleanPlatePrompt, CLEAN_PLATE_PREFIX, CLEAN_PLATE_NEGATIVE } from './cleanPlatePrompt.js';++describe('composeCleanPlatePrompt', () => {+ it('returns the prefix + negative even for an empty setting', () => {+ const out = composeCleanPlatePrompt({});+ expect(out.prompt).toContain(CLEAN_PLATE_PREFIX);+ expect(out.negativePrompt).toContain('people');+ });++ it('handles a fully-populated setting', () => {+ const out = composeCleanPlatePrompt({+ name: 'The Foundry',+ slugline: 'INT. BAR — NIGHT',+ description: 'cramped chrome bar with broken neon',+ palette: 'amber, sodium yellow',+ recurringDetails: 'broken jukebox in the corner',+ intExt: 'INT',+ timeOfDay: 'night',+ });+ expect(out.prompt).toContain(CLEAN_PLATE_PREFIX);+ expect(out.prompt).toContain('interior, night');+ expect(out.prompt).toContain('cramped chrome bar');+ expect(out.prompt).toContain('Palette: amber, sodium yellow');+ expect(out.prompt).toContain('broken jukebox');+ });++ it('omits the metadata parenthetical when both intExt + timeOfDay are null', () => {+ const out = composeCleanPlatePrompt({+ description: 'a generic place',+ intExt: null,+ timeOfDay: null,+ });+ expect(out.prompt).not.toContain('(');+ expect(out.prompt).toContain('a generic place');+ });++ it('emits only the present half when one of intExt / timeOfDay is set', () => {+ const intOnly = composeCleanPlatePrompt({ description: 'x', intExt: 'EXT' });+ expect(intOnly.prompt).toContain('(exterior)');+ expect(intOnly.prompt).not.toContain('(exterior,');+ const todOnly = composeCleanPlatePrompt({ description: 'x', timeOfDay: 'dawn' });+ expect(todOnly.prompt).toContain('(dawn)');+ expect(todOnly.prompt).not.toContain('interior');+ expect(todOnly.prompt).not.toContain('exterior');+ });++ it('appends the clean-plate negatives after the user negatives', () => {+ const out = composeCleanPlatePrompt({ description: 'x' }, 'blurry, low quality');+ expect(out.negativePrompt).toBe(`blurry, low quality, ${CLEAN_PLATE_NEGATIVE}`);+ });++ it('handles malformed input without throwing', () => {+ expect(composeCleanPlatePrompt(null).prompt).toBe(CLEAN_PLATE_PREFIX);+ expect(composeCleanPlatePrompt('not an object').prompt).toBe(CLEAN_PLATE_PREFIX);+ });+});diff --git a/client/src/pages/UniverseCanon.jsx b/client/src/pages/UniverseCanon.jsxindex 41a17cdc3d..acd432ae38 100644--- a/client/src/pages/UniverseCanon.jsx+++ b/client/src/pages/UniverseCanon.jsx@@ -25,6 +25,7 @@ import {} from '../services/apiUniverseBuilder';import { generateImage, getSettings } from '../services/apiSystem';import { composeStyledPrompt } from '../lib/composeStyledPrompt';+import { composeCleanPlatePrompt } from '../lib/cleanPlatePrompt';import { useAsyncAction } from '../hooks/useAsyncAction';import useMounted from '../hooks/useMounted';import CanonCard from '../components/pipeline/CanonCard';@@ -211,6 +212,31 @@ export default function UniverseCanon() {toast.success(`Rendering reference for ${entry.name}`);};+ const handleRenderCleanPlate = async (entry) => {+ if (!entry?.description?.trim()) {+ toast.error(`Add a description before generating a clean plate for ${entry.name}`);+ return;+ }+ const baseOpts = pipelineImageCfgToRenderOpts(imageCfg);+ const plate = composeCleanPlatePrompt(entry, baseOpts.negativePrompt || '');+ // Layer the universe style on top of the clean-plate composition so+ // the empty-location render shares the visual language of the+ // populated reference renders.+ const styled = composeStyledPrompt(+ plate.prompt,+ plate.negativePrompt,+ universe ? { prompt: universe.stylePrompt, negativePrompt: universe.negativePrompt } : null,+ );+ const queued = await generateImage({+ ...baseOpts,+ prompt: styled.prompt,+ negativePrompt: styled.negativePrompt || undefined,+ }).catch((err) => { toast.error(err.message || 'Clean plate render failed'); return null; });+ if (!queued?.jobId || !mountedRef.current) return;+ setRenderingJobs((prev) => ({ ...prev, [entry.id]: queued.jobId }));+ toast.success(`Rendering clean plate for ${entry.name}`);+ };+const handleRefCompleted = useCallback(async (kindKey, entryId, filename) => {if (!filename || !universe) return;setRenderingJobs((prev) => {@@ -345,6 +371,7 @@ export default function UniverseCanon() {onToggleLock={(entryId, nextLocked) => handleToggleLock(kind, entryId, nextLocked)}togglingLockId={togglingLockId}onPatchEntry={(entryId, patch) => handlePatchEntry(kind, entryId, patch)}+ onRenderCleanPlate={handleRenderCleanPlate}/>))}@@ -353,7 +380,7 @@ export default function UniverseCanon() {);}-function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onToggleLock, togglingLockId, onPatchEntry }) {+function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate }) {const Icon = kind.icon;return (<section className="rounded-lg border border-port-border bg-port-card/40">@@ -384,6 +411,7 @@ function KindSection({ kind, all, usage, renderingJobs, onRender, onJobCompletedonToggleLock={onToggleLock}togglingLock={togglingLockId === entry.id}onPatchEntry={onPatchEntry}+ onRenderCleanPlate={onRenderCleanPlate}/>))}</ul>