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

feat: base style-probe image on a universe (Universe Builder + Story Builder)

Adam Eivy7212d23976f4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6522226635..23bbc35cfe 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -9,6 +9,7 @@ TBD
## Added
- **Unified Story Builder** (`/story-builder`): a new guided page that walks a story from idea → universe aesthetic → plot arc → reader map → characters → issues → production as one linear flow. Each step is LLM-assisted with an AI-refinement affordance and ends with an explicit lock before the next unlocks; going back to revise an earlier step soft-flags the downstream locked steps as "stale" (integrity gate) so nothing silently drifts — without destroying their content. The builder is a thin conductor over the existing Universe / Series / Issue records (no data duplication); heavy per-issue production hands off to the existing Pipeline issue page. Reachable from the sidebar (Create → Story Builder), ⌘K, and voice. The intro screen supports two intake modes: **start from a seed idea**, or **import a finished work** (comic script / screenplay / novel / short story) — the importer reverse-engineers it into a universe, arc, characters, and issues, then drops you into the wizard to review and lock each stage. An **AI provider/model picker** at the top of the builder (and the import tab) drives every operation — idea expand, aesthetic, arc, reader map, character refine, and the import analysis — persisted on the session so one selection applies throughout. The **characters step generates a styled preview image per character** (world style fused with the character descriptor, via the same render path as the Universe Builder) and shows it alongside each character so you can eyeball that the world and character styles read correctly together.
+- **Base style image (style probe)** on a universe: generate a canonical image from the raw style guide alone — style notes + the embrace/avoid influences as the positive/negative prompt, with no character or subject — to preview the world's base visual emphasis. Triggerable from both the Universe Builder (under the style/influences editor) and the Story Builder's Universe Aesthetic step; the result persists on the universe (`styleImageRefs`) so both surfaces share it.
- **Reader Map** on a series arc (`series.arc.readerMap`): a distinct audience-experience roadmap — hooks, payoffs, emotional beats, and cliffhangers across the arc — built on top of the Vonnegut story shape, separate from the protagonist arc. Generated and refined via the new Story Builder reader-map step (also preserved by arc regeneration).
## Changed
diff --git a/client/src/components/universe/StyleProbeImage.jsx b/client/src/components/universe/StyleProbeImage.jsx
new file mode 100644
index 0000000000..6952acef98
--- /dev/null
+++ b/client/src/components/universe/StyleProbeImage.jsx
@@ -0,0 +1,84 @@
+/**
+ * Base "style probe" image for a universe.
+ *
+ * Generates a canonical image from the RAW style guide — `styleNotes` + the
+ * influences embrace list (positive) and avoid list (negative) — with NO
+ * character/subject, so the user can see the world's base visual emphasis on
+ * its own. Reuses the same render path as canon renders (generateImage +
+ * EntryThumbSlot spinner/display) and persists the resulting filename onto the
+ * universe's `styleImageRefs[]` so it survives reload and shows in both the
+ * Universe Builder and the Story Builder aesthetic step.
+ */
+import { useState, useEffect } from 'react';
+import { generateImage, getSettings, updateUniverse } from '../../services/api';
+import { universeStylePreset } from '../../lib/universeStylePreset';
+import { pipelineImageCfgToRenderOpts, readPipelineImageSettings, PIPELINE_IMAGE_DEFAULTS } from '../../lib/pipelineImageDefaults';
+import EntryThumbSlot from './EntryThumbSlot';
+import toast from '../ui/Toast';
+
+// Build the subject-less probe prompt from the universe's raw style guide.
+// Positive = styleNotes prose + embrace tokens; negative = avoid tokens.
+export function buildStyleProbePrompt(universe) {
+ const preset = (universe && universeStylePreset(universe)) || { prompt: '', negativePrompt: '' };
+ const positive = [universe?.styleNotes?.trim(), preset.prompt].filter(Boolean).join('. ');
+ return { prompt: positive, negativePrompt: preset.negativePrompt || '' };
+}
+
+// True when there's enough style to make a meaningful probe.
+export function hasStyleForProbe(universe) {
+ const { prompt } = buildStyleProbePrompt(universe);
+ return Boolean(prompt.trim());
+}
+
+export default function StyleProbeImage({ universe, onUniverseChange, canRender = true }) {
+ const [imageCfg, setImageCfg] = useState(PIPELINE_IMAGE_DEFAULTS);
+ const [jobId, setJobId] = useState(null);
+
+ useEffect(() => {
+ getSettings({ silent: true })
+ .then((s) => setImageCfg(readPipelineImageSettings(s)))
+ .catch(() => {});
+ }, []);
+
+ const styleReady = hasStyleForProbe(universe);
+
+ const render = async () => {
+ if (!styleReady) { toast.error('Add style notes or influences before probing the base style'); return; }
+ const baseOpts = pipelineImageCfgToRenderOpts(imageCfg);
+ const probe = buildStyleProbePrompt(universe);
+ const queued = await generateImage(
+ { ...baseOpts, prompt: probe.prompt, negativePrompt: probe.negativePrompt || undefined },
+ { silent: true },
+ ).catch((err) => { toast.error(err?.message || 'Style render failed'); return null; });
+ if (!queued?.jobId) return;
+ setJobId(queued.jobId);
+ };
+
+ const onComplete = async (filename) => {
+ setJobId(null);
+ if (!filename || !universe?.id) return;
+ const next = [...(Array.isArray(universe.styleImageRefs) ? universe.styleImageRefs : []), filename];
+ const updated = await updateUniverse(universe.id, { styleImageRefs: next }, { silent: true })
+ .catch(() => null);
+ onUniverseChange?.(updated || { ...universe, styleImageRefs: next });
+ };
+
+ return (
+ <div className="flex items-start gap-3">
+ <EntryThumbSlot
+ imageRefs={universe?.styleImageRefs}
+ inFlightJobId={jobId}
+ onRender={render}
+ onComplete={onComplete}
+ canRender={canRender && Boolean(universe?.id) && styleReady}
+ alt="Base style"
+ size="lg"
+ />
+ <div className="text-xs text-gray-500 max-w-sm">
+ <div className="text-gray-300 font-medium mb-0.5">Base style image</div>
+ Rendered from the raw style guide + positive/negative influences with no subject — a quick read on the
+ world's base visual emphasis. {!styleReady && <span className="text-port-warning">Add style notes or influences first.</span>}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/universe/StyleProbeImage.test.jsx b/client/src/components/universe/StyleProbeImage.test.jsx
new file mode 100644
index 0000000000..4e02d0ef6e
--- /dev/null
+++ b/client/src/components/universe/StyleProbeImage.test.jsx
@@ -0,0 +1,38 @@
+import { describe, it, expect } from 'vitest';
+import { buildStyleProbePrompt, hasStyleForProbe } from './StyleProbeImage';
+
+describe('StyleProbeImage — buildStyleProbePrompt', () => {
+ it('fuses styleNotes (style guide) + embrace into positive, avoid into negative', () => {
+ const u = {
+ styleNotes: 'inky noir, heavy rain',
+ influences: { embrace: ['high contrast', 'cinematic'], avoid: ['bright', 'pastel'] },
+ };
+ const { prompt, negativePrompt } = buildStyleProbePrompt(u);
+ expect(prompt).toContain('inky noir');
+ expect(prompt).toContain('high contrast');
+ expect(prompt).toContain('cinematic');
+ expect(negativePrompt).toContain('bright');
+ expect(negativePrompt).toContain('pastel');
+ });
+
+ it('works with only influences (no styleNotes) and only styleNotes (no influences)', () => {
+ expect(buildStyleProbePrompt({ influences: { embrace: ['noir'], avoid: [] } }).prompt).toContain('noir');
+ expect(buildStyleProbePrompt({ styleNotes: 'watercolor' }).prompt).toContain('watercolor');
+ });
+
+ it('returns empty for a null / style-less universe', () => {
+ expect(buildStyleProbePrompt(null)).toEqual({ prompt: '', negativePrompt: '' });
+ expect(buildStyleProbePrompt({ influences: { embrace: [], avoid: [] } }).prompt).toBe('');
+ });
+});
+
+describe('StyleProbeImage — hasStyleForProbe', () => {
+ it('is true when there is any style guide or embrace influence', () => {
+ expect(hasStyleForProbe({ styleNotes: 'x' })).toBe(true);
+ expect(hasStyleForProbe({ influences: { embrace: ['noir'] } })).toBe(true);
+ });
+ it('is false with no style at all', () => {
+ expect(hasStyleForProbe(null)).toBe(false);
+ expect(hasStyleForProbe({ influences: { embrace: [], avoid: ['bright'] } })).toBe(false);
+ });
+});
diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsx
index d86341dccf..fd48fd5741 100644
--- a/client/src/pages/StoryBuilder.jsx
+++ b/client/src/pages/StoryBuilder.jsx
@@ -6,6 +6,7 @@ import { universeStylePreset } from '../lib/universeStylePreset';
import { descriptorForCanonEntry } from '../lib/canonPrompt';
import { pipelineImageCfgToRenderOpts, readPipelineImageSettings, PIPELINE_IMAGE_DEFAULTS } from '../lib/pipelineImageDefaults';
import EntryThumbSlot from '../components/universe/EntryThumbSlot';
+import StyleProbeImage from '../components/universe/StyleProbeImage';
import {
Sparkles, Lock, Unlock, Check, ChevronRight, ChevronLeft, AlertTriangle,
Plus, RefreshCw, Loader2, ExternalLink, Wand2,
@@ -451,6 +452,9 @@ function StepPanel({ session, universe, series, issues, stepId, locked, onChange
<FieldBlock label="Style notes" value={universe?.styleNotes} />
<FieldBlock label="Influences — embrace" value={(universe?.influences?.embrace || []).join(', ')} />
<FieldBlock label="Influences — avoid" value={(universe?.influences?.avoid || []).join(', ')} />
+ <div className="border-t border-port-border pt-3">
+ <StyleProbeImage universe={universe} onUniverseChange={() => onChanged()} canRender={!locked} />
+ </div>
<div className="flex items-center gap-2">
{!locked && genButton('Expand aesthetic', Boolean((universe?.premise || universe?.styleNotes || '').trim()))}
{universe?.id && (
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsx
index a17a815400..6cda4b2b6b 100644
--- a/client/src/pages/UniverseBuilder.jsx
+++ b/client/src/pages/UniverseBuilder.jsx
@@ -36,6 +36,7 @@ import ShareToButton from '../components/sharing/ShareToButton';
import SyncToPeerButton from '../components/sharing/SyncToPeerButton';
import OriginBadge from '../components/sharing/OriginBadge';
import UniverseCanonSection from '../components/universe/UniverseCanonSection';
+import StyleProbeImage from '../components/universe/StyleProbeImage';
import EntryCard from '../components/universe/EntryCard';
import EntryThumbSlot from '../components/universe/EntryThumbSlot';
import useMediaJobProgress from '../hooks/useMediaJobProgress';
@@ -3130,6 +3131,14 @@ function BibleTab({
locked={draft.locked}
onToggleLock={toggleLock}
/>
+ <div className="mt-4 pt-4 border-t border-port-border">
+ {/* StyleProbeImage persists styleImageRefs server-side itself; merge
+ only that field into the draft so unsaved style edits aren't lost. */}
+ <StyleProbeImage
+ universe={draft}
+ onUniverseChange={(updated) => updateDraft({ styleImageRefs: updated?.styleImageRefs || [] })}
+ />
+ </div>
</section>
</>
);
diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.js
index 80f041a6db..495e646db9 100644
--- a/server/routes/universeBuilder.js
+++ b/server/routes/universeBuilder.js
@@ -162,6 +162,8 @@ const createSchema = z.object({
categories: categoriesSchema.optional(),
compositeSheets: z.array(compositeSheetSchema).max(svc.COMPOSITE_SHEETS_MAX).optional(),
influences: influencesSchema.optional(),
+ // Base "style probe" render filenames — sanitized + capped server-side.
+ styleImageRefs: z.array(z.string().trim().min(1).max(500)).max(50).optional(),
locked: lockedSchema.optional(),
llm: llmSchema,
// Canon registries on POST (Phase B.4): writers-room promote, share-bucket
@@ -190,6 +192,8 @@ const patchSchema = z.object({
categories: categoriesSchema.optional(),
compositeSheets: z.array(compositeSheetSchema).max(svc.COMPOSITE_SHEETS_MAX).optional(),
influences: influencesSchema.optional(),
+ // Base "style probe" render filenames — sanitized + capped server-side.
+ styleImageRefs: z.array(z.string().trim().min(1).max(500)).max(50).optional(),
locked: lockedSchema.optional(),
llm: llmSchema,
// Canon writes — these flow through sanitizeBibleList server-side so
diff --git a/server/services/universeBuilder.js b/server/services/universeBuilder.js
index cbef791606..626bf884ce 100644
--- a/server/services/universeBuilder.js
+++ b/server/services/universeBuilder.js
@@ -775,6 +775,12 @@ const sanitizeTemplate = (raw) => {
categories,
compositeSheets,
influences,
+ // Base "style probe" renders — images generated from the raw style preset
+ // (influences embrace/avoid + styleNotes) with NO subject, so the user can
+ // see the world's base visual emphasis. Additive + regenerable; sanitized
+ // like canon imageRefs (dedupe + cap). Not wire-version-gated (low-stakes,
+ // one-click to regenerate if an older peer round-trips and strips it).
+ styleImageRefs: sanitizeEntryImageRefs(raw.styleImageRefs),
locked,
characters,
places,
@@ -911,6 +917,7 @@ export async function createUniverse(input = {}) {
categories: input.categories || {},
compositeSheets: input.compositeSheets || [],
influences: input.influences || {},
+ styleImageRefs: input.styleImageRefs || [],
locked: input.locked || {},
// Canon registries — let callers seed a universe at creation time
// (writers-room promote, share-bucket import). sanitizeTemplate runs
@@ -1069,6 +1076,8 @@ export async function updateUniverse(id, patchOrMutator = {}) {
const PATCHABLE_SCALARS = [
'name', 'starterPrompt',
'logline', 'premise', 'styleNotes', 'compositeSheets',
+ // Base style-probe render refs — patched wholesale (sanitizer re-caps).
+ 'styleImageRefs',
// Canon entity arrays — patched wholesale (the sanitizer reruns
// sanitizeBibleList so per-entry shape is enforced on every save).
'characters', 'places', 'objects',
diff --git a/server/services/universeBuilder.test.js b/server/services/universeBuilder.test.js
index 6e6a4675d8..89f40767cf 100644
--- a/server/services/universeBuilder.test.js
+++ b/server/services/universeBuilder.test.js
@@ -277,6 +277,20 @@ describe("universeBuilder service", () => {
expect(patched.influences.avoid).toEqual(w.influences.avoid);
});
+ it("persists styleImageRefs (base style-probe renders); dedupes on create + patches wholesale", async () => {
+ const w = await svc.createUniverse({ name: "Probe", styleImageRefs: ["a.png", "a.png", "b.png"] });
+ expect(w.styleImageRefs).toEqual(["a.png", "b.png"]); // dedupe via sanitizeEntryImageRefs
+ const patched = await svc.updateUniverse(w.id, { styleImageRefs: ["a.png", "b.png", "c.png"] });
+ expect(patched.styleImageRefs).toEqual(["a.png", "b.png", "c.png"]);
+ const fresh = await svc.getUniverse(w.id);
+ expect(fresh.styleImageRefs).toEqual(["a.png", "b.png", "c.png"]);
+ });
+
+ it("defaults styleImageRefs to [] when absent", async () => {
+ const w = await svc.createUniverse({ name: "NoProbe" });
+ expect(w.styleImageRefs).toEqual([]);
+ });
+
it("createUniverse trims bible fields to their max length", async () => {
const w = await seedWorld({
logline: "x".repeat(svc.LOGLINE_MAX + 50),