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

perf: load compact universe and series lists (#7041)

[._.]/ Adam Eivyd0bc0da68976
diff --git a/client/src/components/Layout.test.jsx b/client/src/components/Layout.test.jsx
index 5f2f3215eb..a9b7b2de8f 100644
--- a/client/src/components/Layout.test.jsx
+++ b/client/src/components/Layout.test.jsx
@@ -77,8 +77,8 @@ const featureMock = vi.hoisted(() => ({ features: null }));
vi.mock('../services/api', () => ({
getApps: vi.fn(() => Promise.resolve([])),
- listPipelineSeries: vi.fn(() => Promise.resolve([])),
- listUniverses: vi.fn(() => Promise.resolve([])),
+ listPipelineSeriesNames: vi.fn(() => Promise.resolve([])),
+ listUniverseNames: vi.fn(() => Promise.resolve([])),
getDailyActions: vi.fn(() => Promise.resolve({ actions: [] })),
getInstanceFeatures: vi.fn(() => Promise.resolve({ features: featureMock.features })),
}));
@@ -179,8 +179,8 @@ beforeEach(() => {
afterEach(() => {
vi.unstubAllGlobals();
- api.listPipelineSeries.mockResolvedValue([]);
- api.listUniverses.mockResolvedValue([]);
+ api.listPipelineSeriesNames.mockResolvedValue([]);
+ api.listUniverseNames.mockResolvedValue([]);
});
describe('Layout — pinned single nav rows', () => {
@@ -475,8 +475,8 @@ describe('Layout — Data Manager scroll mode', () => {
describe('Layout — dynamic third-level navigation', () => {
it('collapses and expands the Series and Universes children', async () => {
- api.listPipelineSeries.mockResolvedValue([{ id: 'series-1', name: 'Example Series' }]);
- api.listUniverses.mockResolvedValue([{ id: 'universe-1', name: 'Example Universe' }]);
+ api.listPipelineSeriesNames.mockResolvedValue([{ id: 'series-1', name: 'Example Series' }]);
+ api.listUniverseNames.mockResolvedValue([{ id: 'universe-1', name: 'Example Universe' }]);
await renderLayout('/media');
diff --git a/client/src/components/creative-director/PlanTab.jsx b/client/src/components/creative-director/PlanTab.jsx
index 1d7fdb4482..bdd796ba7a 100644
--- a/client/src/components/creative-director/PlanTab.jsx
+++ b/client/src/components/creative-director/PlanTab.jsx
@@ -10,8 +10,8 @@ import {
replanCreativeDirectorProject,
updateCreativeDirectorPlanStep,
} from '../../services/apiCreativeDirector.js';
-import { listUniverses } from '../../services/apiUniverseBuilder.js';
-import { listPipelineSeries } from '../../services/apiPipeline.js';
+import { listUniverseNames } from '../../services/apiUniverseBuilder.js';
+import { listPipelineSeriesNames } from '../../services/apiPipeline.js';
import {
annotatePlanSteps,
planCostSummary,
@@ -73,8 +73,8 @@ export default function PlanTab({ project, onProjectUpdate }) {
: EMPTY_DIRECTIVE);
setSearchParams((prev) => { const n = new URLSearchParams(prev); n.set('directive', 'edit'); return n; }, { replace: true });
// Lazy-load the pickers on open.
- if (!universes.length) listUniverses({ silent: true }).then((u) => setUniverses(Array.isArray(u) ? u : (u?.items || []))).catch(() => {});
- if (!series.length) listPipelineSeries({ silent: true }).then((s) => setSeries(Array.isArray(s) ? s : (s?.items || []))).catch(() => {});
+ if (!universes.length) listUniverseNames({ silent: true }).then((u) => setUniverses(Array.isArray(u) ? u : (u?.items || []))).catch(() => {});
+ if (!series.length) listPipelineSeriesNames({ silent: true }).then((s) => setSeries(Array.isArray(s) ? s : (s?.items || []))).catch(() => {});
}, [project.directive, setSearchParams, universes.length, series.length]);
const closeComposer = useCallback(() => {
diff --git a/client/src/components/creative-director/PlanTab.test.jsx b/client/src/components/creative-director/PlanTab.test.jsx
index 86abec321b..2ceb39d0a9 100644
--- a/client/src/components/creative-director/PlanTab.test.jsx
+++ b/client/src/components/creative-director/PlanTab.test.jsx
@@ -11,8 +11,8 @@ vi.mock('../../services/apiCreativeDirector.js', () => ({
replanCreativeDirectorProject: vi.fn(),
updateCreativeDirectorPlanStep: vi.fn(),
}));
-vi.mock('../../services/apiUniverseBuilder.js', () => ({ listUniverses: vi.fn(async () => []) }));
-vi.mock('../../services/apiPipeline.js', () => ({ listPipelineSeries: vi.fn(async () => []) }));
+vi.mock('../../services/apiUniverseBuilder.js', () => ({ listUniverseNames: vi.fn(async () => []) }));
+vi.mock('../../services/apiPipeline.js', () => ({ listPipelineSeriesNames: vi.fn(async () => []) }));
vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn(), info: vi.fn() } }));
import PlanTab from './PlanTab.jsx';
diff --git a/client/src/components/creative-director/VideoDraftDrawer.jsx b/client/src/components/creative-director/VideoDraftDrawer.jsx
index 4b32377da0..f0712ae137 100644
--- a/client/src/components/creative-director/VideoDraftDrawer.jsx
+++ b/client/src/components/creative-director/VideoDraftDrawer.jsx
@@ -5,8 +5,8 @@ import Drawer from '../Drawer.jsx';
import useDrawerTab from '../../hooks/useDrawerTab.js';
import toast from '../ui/Toast';
import { createCreativeDirectorProject, updateCreativeDirectorProject } from '../../services/apiCreativeDirector.js';
-import { listUniverses } from '../../services/apiUniverseBuilder.js';
-import { listPipelineSeries } from '../../services/apiPipeline.js';
+import { listUniverseNames } from '../../services/apiUniverseBuilder.js';
+import { listPipelineSeriesNames } from '../../services/apiPipeline.js';
import { listCatalogIngredients } from '../../services/apiCatalog.js';
import { listMusicEngines } from '../../services/apiMusic.js';
import { listTracks } from '../../services/apiTracks.js';
@@ -40,7 +40,7 @@ export default function VideoDraftDrawer({ open, onClose, project, onSaved, cata
listTracks({ silent: true }).then(data => setTracks(Array.isArray(data) ? data : data?.tracks || [])).catch(() => {});
listMusicEngines({ silent: true }).then(data => setEngines(data?.engines || [])).catch(() => {});
const rows = data => Array.isArray(data) ? data : data?.items || data?.series || data?.universes || [];
- Promise.all([listUniverses({ silent: true }), listPipelineSeries({ silent: true }), listCatalogIngredients({ limit: 100, silent: true })]).then(([u, s, c]) => setSourceOptions({ universe: rows(u), series: rows(s), catalog: rows(c) })).catch(() => toast.error('Unable to load source choices. Close and reopen to retry.'));
+ Promise.all([listUniverseNames({ silent: true }), listPipelineSeriesNames({ silent: true }), listCatalogIngredients({ limit: 100, silent: true })]).then(([u, s, c]) => setSourceOptions({ universe: rows(u), series: rows(s), catalog: rows(c) })).catch(() => toast.error('Unable to load source choices. Close and reopen to retry.'));
listVideoModels({ silent: true }).then(m => setModels(m || [])).catch(() => {});
}, [open, project?.id]);
const change = (key, value) => setForm(prev => ({ ...prev, [key]: value }));
diff --git a/client/src/components/creative-director/VideoDraftDrawer.test.jsx b/client/src/components/creative-director/VideoDraftDrawer.test.jsx
index a7fd42d779..9e9e72df8a 100644
--- a/client/src/components/creative-director/VideoDraftDrawer.test.jsx
+++ b/client/src/components/creative-director/VideoDraftDrawer.test.jsx
@@ -1,7 +1,7 @@
vi.mock('../../services/apiTracks.js', () => ({ listTracks: vi.fn(async () => []) }));
vi.mock('../../services/apiMusic.js', () => ({ listMusicEngines: vi.fn(() => Promise.resolve({ engines: [] })) }));
-vi.mock('../../services/apiUniverseBuilder.js', () => ({ listUniverses: vi.fn(() => Promise.resolve([])) }));
-vi.mock('../../services/apiPipeline.js', () => ({ listPipelineSeries: vi.fn(() => Promise.resolve([])) }));
+vi.mock('../../services/apiUniverseBuilder.js', () => ({ listUniverseNames: vi.fn(() => Promise.resolve([])) }));
+vi.mock('../../services/apiPipeline.js', () => ({ listPipelineSeriesNames: vi.fn(() => Promise.resolve([])) }));
vi.mock('../../services/apiCatalog.js', () => ({ listCatalogIngredients: vi.fn(() => Promise.resolve([])) }));
import { it, expect, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
diff --git a/client/src/components/imageGen/GalleryImagePicker.jsx b/client/src/components/imageGen/GalleryImagePicker.jsx
index f6e543f4ec..e69e33d085 100644
--- a/client/src/components/imageGen/GalleryImagePicker.jsx
+++ b/client/src/components/imageGen/GalleryImagePicker.jsx
@@ -25,7 +25,7 @@ import FilePickerButton from '../ui/FilePickerButton';
import MediaCard from '../media/MediaCard';
import { normalizeImage } from '../media/normalize';
import { listImageGallery, listMediaCollections } from '../../services/apiImageVideo';
-import { listUniverses } from '../../services/apiUniverseBuilder';
+import { listUniverseNames } from '../../services/apiUniverseBuilder';
import { uploadGalleryImage } from '../../services/apiSystem';
import {
readFileAsBase64, validateImageFile, JSON_UPLOAD_MAX_FILE_SIZE, UPLOAD_IMAGE_ACCEPT,
@@ -112,7 +112,7 @@ export default function GalleryImagePicker({
listMediaCollections({ silent: true })
.then((list) => { if (!cancelled) setCollections(Array.isArray(list) ? list : []); })
.catch(() => { if (!cancelled) setCollections([]); });
- listUniverses({ silent: true })
+ listUniverseNames({ silent: true })
.then((list) => { if (!cancelled) setUniverses(Array.isArray(list) ? list : []); })
.catch(() => { if (!cancelled) setUniverses([]); });
return () => { cancelled = true; };
@@ -124,7 +124,7 @@ export default function GalleryImagePicker({
const tokens = useMemo(() => tokenizeQuery(query), [query]);
// Universes are seeded from the images' own `universeId`/`universeName` stamps
- // so the group still populates when listUniverses fails; the fetched record
+ // so the group still populates when listUniverseNames fails; the fetched record
// only supplies a fresher display name for a universe that was renamed after
// the sidecar was written. Universes with no image here are dropped — a scope
// that can only ever yield an empty grid isn't worth an option row.
diff --git a/client/src/components/imageGen/GalleryImagePicker.test.jsx b/client/src/components/imageGen/GalleryImagePicker.test.jsx
index ed0eebb677..648dfccdd7 100644
--- a/client/src/components/imageGen/GalleryImagePicker.test.jsx
+++ b/client/src/components/imageGen/GalleryImagePicker.test.jsx
@@ -10,11 +10,11 @@ vi.mock('../../services/apiImageVideo', () => ({
listMediaCollections: (...args) => listMediaCollections(...args),
}));
-const listUniverses = vi.fn();
+const listUniverseNames = vi.fn();
// universeBuilderShared imports the WORLD_CATEGORY_* constants from this module,
// so the mock has to carry them or the shared lib loads with undefined values.
vi.mock('../../services/apiUniverseBuilder', () => ({
- listUniverses: (...args) => listUniverses(...args),
+ listUniverseNames: (...args) => listUniverseNames(...args),
WORLD_CATEGORIES: ['landscapes', 'environments', 'structures', 'vehicles'],
WORLD_CATEGORY_KEY_MAX: 64,
}));
@@ -66,8 +66,8 @@ describe('GalleryImagePicker', () => {
listImageGallery.mockResolvedValue(GALLERY);
listMediaCollections.mockReset();
listMediaCollections.mockResolvedValue(COLLECTIONS);
- listUniverses.mockReset();
- listUniverses.mockResolvedValue(UNIVERSES);
+ listUniverseNames.mockReset();
+ listUniverseNames.mockResolvedValue(UNIVERSES);
uploadGalleryImage.mockReset();
toast.error.mockReset();
});
@@ -300,7 +300,7 @@ describe('GalleryImagePicker', () => {
it('degrades to image-derived universes and no collections when those fetches fail', async () => {
listMediaCollections.mockRejectedValue(new Error('nope'));
- listUniverses.mockRejectedValue(new Error('nope'));
+ listUniverseNames.mockRejectedValue(new Error('nope'));
render(<GalleryImagePicker open onClose={vi.fn()} onSelect={vi.fn()} />);
await screen.findByAltText('a neon sunset');
@@ -317,7 +317,7 @@ describe('GalleryImagePicker', () => {
render(<GalleryImagePicker open onClose={vi.fn()} onSelect={vi.fn()} />);
await screen.findByAltText('a neon sunset');
expect(listMediaCollections).toHaveBeenCalledWith({ silent: true });
- expect(listUniverses).toHaveBeenCalledWith({ silent: true });
+ expect(listUniverseNames).toHaveBeenCalledWith({ silent: true });
});
it('skips malformed sidecar metadata instead of throwing while building options', async () => {
@@ -329,7 +329,7 @@ describe('GalleryImagePicker', () => {
{ filename: 'proto.png', path: '/data/images/proto.png', prompt: 'prototype key', entryCategory: 'constructor' },
]);
listMediaCollections.mockResolvedValue([{ id: 'col-1', name: 5, items: [{ kind: 'image', ref: 'ok.png' }] }]);
- listUniverses.mockResolvedValue([{ id: 'uni-a', name: 99 }]);
+ listUniverseNames.mockResolvedValue([{ id: 'uni-a', name: 99 }]);
render(<GalleryImagePicker open onClose={vi.fn()} onSelect={vi.fn()} />);
await screen.findByAltText('bad metadata');
@@ -360,7 +360,7 @@ describe('GalleryImagePicker', () => {
it('does not render the filter selects when nothing is filterable', async () => {
listImageGallery.mockResolvedValue([{ filename: 'plain.png', path: '/data/images/plain.png', prompt: 'plain' }]);
listMediaCollections.mockResolvedValue([]);
- listUniverses.mockResolvedValue([]);
+ listUniverseNames.mockResolvedValue([]);
render(<GalleryImagePicker open onClose={vi.fn()} onSelect={vi.fn()} />);
await screen.findByAltText('plain');
expect(screen.queryByLabelText(/universe or collection/i)).toBeNull();
diff --git a/client/src/hooks/useSidebarSeries.js b/client/src/hooks/useSidebarSeries.js
index e5b36646fc..6b1ff6697f 100644
--- a/client/src/hooks/useSidebarSeries.js
+++ b/client/src/hooks/useSidebarSeries.js
@@ -5,5 +5,5 @@ import { useFocusRefreshedList } from './useFocusRefreshedList.js';
// and refreshes on window focus (debounced 30s) so freshly-created or renamed
// series surface without a reload.
export function useSidebarSeries() {
- return useFocusRefreshedList(api.listPipelineSeries, 'pipeline-series');
+ return useFocusRefreshedList(api.listPipelineSeriesNames, 'pipeline-series');
}
diff --git a/client/src/hooks/useSidebarUniverses.js b/client/src/hooks/useSidebarUniverses.js
index fa8a561c4b..b61ae7e24b 100644
--- a/client/src/hooks/useSidebarUniverses.js
+++ b/client/src/hooks/useSidebarUniverses.js
@@ -5,5 +5,5 @@ import { useFocusRefreshedList } from './useFocusRefreshedList.js';
// refreshes on window focus (debounced 30s) so freshly-created or renamed
// universes surface without a reload.
export function useSidebarUniverses() {
- return useFocusRefreshedList(api.listUniverses, 'universes');
+ return useFocusRefreshedList(api.listUniverseNames, 'universes');
}
diff --git a/client/src/pages/Catalog.jsx b/client/src/pages/Catalog.jsx
index 9f1cffb347..aae2782bfa 100644
--- a/client/src/pages/Catalog.jsx
+++ b/client/src/pages/Catalog.jsx
@@ -30,8 +30,8 @@ import {
getCatalogFacets,
rerunCatalogMigration,
} from '../services/apiCatalog';
-import { listUniverses } from '../services/apiUniverseBuilder';
-import { listPipelineSeries } from '../services/apiPipeline';
+import { listUniverseNames } from '../services/apiUniverseBuilder';
+import { listPipelineSeriesNames } from '../services/apiPipeline';
import CatalogCard from '../components/catalog/CatalogCard';
import CatalogAlbum from '../components/catalog/CatalogAlbum';
import { CatalogTypesTab } from '../components/settings/CatalogTypesTab';
@@ -482,8 +482,8 @@ export default function Catalog() {
const loadPlaceTargets = useCallback(() => {
setPlaceTargetsLoading(true);
Promise.all([
- listUniverses({ silent: true }).catch(() => []),
- listPipelineSeries({ silent: true }).catch(() => []),
+ listUniverseNames({ silent: true }).catch(() => []),
+ listPipelineSeriesNames({ silent: true }).catch(() => []),
]).then(([universes, series]) => {
setPlaceTargets({
universes: (Array.isArray(universes) ? universes : []).map((u) => ({ refKind: 'universe', refId: u.id, label: u.name || '(untitled universe)' })),
diff --git a/client/src/pages/Catalog.test.jsx b/client/src/pages/Catalog.test.jsx
index c64e348533..8bcaf08c67 100644
--- a/client/src/pages/Catalog.test.jsx
+++ b/client/src/pages/Catalog.test.jsx
@@ -24,10 +24,10 @@ vi.mock('../services/apiCatalog', () => ({
// Bulk "Add to universe/series" sources its menu from the FULL live lists (so
// empty universes/series are valid destinations), not the facet arrays.
vi.mock('../services/apiUniverseBuilder', () => ({
- listUniverses: vi.fn(),
+ listUniverseNames: vi.fn(),
}));
vi.mock('../services/apiPipeline', () => ({
- listPipelineSeries: vi.fn(),
+ listPipelineSeriesNames: vi.fn(),
}));
vi.mock('../components/ui/Toast', () => ({
@@ -60,8 +60,8 @@ import {
rerunCatalogMigration,
} from '../services/apiCatalog';
import { listCatalogTypes } from '../services/apiCatalogTypes';
-import { listUniverses } from '../services/apiUniverseBuilder';
-import { listPipelineSeries } from '../services/apiPipeline';
+import { listUniverseNames } from '../services/apiUniverseBuilder';
+import { listPipelineSeriesNames } from '../services/apiPipeline';
import toast from '../components/ui/Toast';
const sample = [
@@ -97,8 +97,8 @@ beforeEach(() => {
linkCatalogIngredient.mockResolvedValue({ success: true });
getCatalogStats.mockResolvedValue({ total: 2, byType: { character: 1, place: 1 } });
getCatalogFacets.mockResolvedValue(sampleFacets);
- listUniverses.mockResolvedValue([{ id: 'u-1', name: 'Echo Saints' }]);
- listPipelineSeries.mockResolvedValue([{ id: 's-1', name: 'Season 1', universeId: 'u-1' }]);
+ listUniverseNames.mockResolvedValue([{ id: 'u-1', name: 'Echo Saints' }]);
+ listPipelineSeriesNames.mockResolvedValue([{ id: 's-1', name: 'Season 1', universeId: 'u-1' }]);
rerunCatalogMigration.mockResolvedValue({ stats: { promoted: 0 } });
// Default: system registry only (the hook merges with the static fallback).
listCatalogTypes.mockResolvedValue({ types: [] });
@@ -500,7 +500,7 @@ describe('Catalog page', () => {
it('lists empty (link-less) universes in the Add-to menu so they can be seeded', async () => {
// A brand-new universe with zero catalog links is absent from /facets but
// must still be a valid placement target.
- listUniverses.mockResolvedValue([
+ listUniverseNames.mockResolvedValue([
{ id: 'u-1', name: 'Echo Saints' },
{ id: 'u-empty', name: 'Fresh Empty Universe' },
]);
diff --git a/client/src/pages/CreativeDirector.jsx b/client/src/pages/CreativeDirector.jsx
index 07d963fa63..908a960af7 100644
--- a/client/src/pages/CreativeDirector.jsx
+++ b/client/src/pages/CreativeDirector.jsx
@@ -14,8 +14,8 @@ import {
} from '../services/apiCreativeDirector.js';
import { listCatalogIngredientsByIds } from '../services/apiCatalog.js';
import { listVideoModels } from '../services/apiImageVideo.js';
-import { listUniverses } from '../services/apiUniverseBuilder.js';
-import { listPipelineSeries } from '../services/apiPipeline.js';
+import { listUniverseNames } from '../services/apiUniverseBuilder.js';
+import { listPipelineSeriesNames } from '../services/apiPipeline.js';
import ModelSelect from '../components/ModelSelect';
import PageHeader from '../components/PageHeader';
import PageSkeleton from '../components/ui/PageSkeleton';
@@ -188,8 +188,8 @@ export default function CreativeDirector({ basePath = '/creative-director', brow
setDirectiveName('');
setDirectiveDraft(EMPTY_DIRECTIVE);
setSearchParams((prev) => { const n = new URLSearchParams(prev); n.set('new', 'directive'); return n; }, { replace: true });
- if (!universes.length) listUniverses({ silent: true }).then((u) => setUniverses(Array.isArray(u) ? u : (u?.items || []))).catch(() => {});
- if (!series.length) listPipelineSeries({ silent: true }).then((s) => setSeries(Array.isArray(s) ? s : (s?.items || []))).catch(() => {});
+ if (!universes.length) listUniverseNames({ silent: true }).then((u) => setUniverses(Array.isArray(u) ? u : (u?.items || []))).catch(() => {});
+ if (!series.length) listPipelineSeriesNames({ silent: true }).then((s) => setSeries(Array.isArray(s) ? s : (s?.items || []))).catch(() => {});
};
const closeDirective = () => {
setSearchParams((prev) => { const n = new URLSearchParams(prev); n.delete('new'); return n; }, { replace: true });
diff --git a/client/src/pages/CreativeDirector.test.jsx b/client/src/pages/CreativeDirector.test.jsx
index 02bb3f3db2..d390d09dbb 100644
--- a/client/src/pages/CreativeDirector.test.jsx
+++ b/client/src/pages/CreativeDirector.test.jsx
@@ -15,8 +15,8 @@ vi.mock('../services/apiCreativeDirector.js', () => ({
}));
vi.mock('../services/apiCatalog.js', () => ({ listCatalogIngredients: vi.fn(() => Promise.resolve([])), listCatalogIngredientsByIds: vi.fn(() => Promise.resolve([])) }));
vi.mock('../services/apiImageVideo.js', () => ({ listVideoModels: vi.fn(() => Promise.resolve([{ id: 'model-a', name: 'Model A' }])) }));
-vi.mock('../services/apiUniverseBuilder.js', () => ({ listUniverses: vi.fn(() => Promise.resolve([])) }));
-vi.mock('../services/apiPipeline.js', () => ({ listPipelineSeries: vi.fn(() => Promise.resolve([])) }));
+vi.mock('../services/apiUniverseBuilder.js', () => ({ listUniverseNames: vi.fn(() => Promise.resolve([])) }));
+vi.mock('../services/apiPipeline.js', () => ({ listPipelineSeriesNames: vi.fn(() => Promise.resolve([])) }));
vi.mock('../components/creative-director/CreativeDirectorModelsDrawer.jsx', () => ({ default: () => null }));
vi.mock('../components/ui/Toast', () => ({
default: { success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn() },
diff --git a/client/src/pages/FableLoom.jsx b/client/src/pages/FableLoom.jsx
index 75d1375896..a4013170f6 100644
--- a/client/src/pages/FableLoom.jsx
+++ b/client/src/pages/FableLoom.jsx
@@ -25,7 +25,7 @@ import { effectiveModelFor, effortAwareModelOptions } from '../utils/providers';
import { fieldClass, labelClass } from '../components/fableloom/fieldStyles';
import { LOOM_FORMATS, isTeleplayFormat, loomFormatLabel } from '../components/fableloom/loomFormats';
import {
- createLoom, deleteLoom, generateLoomSeriesPlan, listLooms, listPipelineSeries, listUniverses,
+ createLoom, deleteLoom, generateLoomSeriesPlan, listLooms, listPipelineSeriesNames, listUniverseNames,
} from '../services/api';
import { FABLELOOM_PARTICIPATION_MODES } from '../../../server/lib/fableLoomParticipation.js';
@@ -49,8 +49,8 @@ export default function FableLoom() {
useEffect(() => {
listLooms().then(setLooms).catch(() => setLooms([]));
- listUniverses({ silent: true }).then(setUniverses).catch(() => {});
- listPipelineSeries({ silent: true }).then(setSeries).catch(() => {});
+ listUniverseNames({ silent: true }).then(setUniverses).catch(() => {});
+ listPipelineSeriesNames({ silent: true }).then(setSeries).catch(() => {});
}, []);
const universeNames = useMemo(() => new Map(universes.map((u) => [u.id, u.name])), [universes]);
diff --git a/client/src/pages/FableLoom.test.jsx b/client/src/pages/FableLoom.test.jsx
index f82d2f238e..146d054074 100644
--- a/client/src/pages/FableLoom.test.jsx
+++ b/client/src/pages/FableLoom.test.jsx
@@ -9,8 +9,8 @@ vi.mock('../services/api', () => ({
deleteLoom: vi.fn(),
generateLoomSeriesPlan: vi.fn(),
getProviders: vi.fn(),
- listUniverses: vi.fn(),
- listPipelineSeries: vi.fn(),
+ listUniverseNames: vi.fn(),
+ listPipelineSeriesNames: vi.fn(),
}));
vi.mock('../components/sharing/SyncToPeerButton', () => ({
default: ({ recordKind, recordId }) => <button type="button">sync {recordKind} {recordId}</button>,
@@ -46,8 +46,8 @@ const renderPage = () => render(<MemoryRouter><FableLoom /></MemoryRouter>);
beforeEach(() => {
vi.clearAllMocks();
api.listLooms.mockResolvedValue(looms);
- api.listUniverses.mockResolvedValue([{ id: 'uni-1', name: 'Aria Verse' }]);
- api.listPipelineSeries.mockResolvedValue([]);
+ api.listUniverseNames.mockResolvedValue([{ id: 'uni-1', name: 'Aria Verse' }]);
+ api.listPipelineSeriesNames.mockResolvedValue([]);
api.getProviders.mockResolvedValue({
activeProvider: 'codex',
providers: [{
diff --git a/client/src/pages/Importer.jsx b/client/src/pages/Importer.jsx
index fc63ca135c..7f436eee5e 100644
--- a/client/src/pages/Importer.jsx
+++ b/client/src/pages/Importer.jsx
@@ -11,7 +11,7 @@ import ProviderModelSelector from '../components/ProviderModelSelector';
import useProviderModels from '../hooks/useProviderModels';
import { previewCanonFragments } from '../lib/canonPrompt';
import { resolveImporterDeepLink } from '../lib/importerDeepLink';
-import { listUniverses, listPipelineSeries } from '../services/api';
+import { listUniverseSummaries, listPipelineSeriesSummaries } from '../services/api';
import {
analyzeImport,
classifyImport,
@@ -124,8 +124,8 @@ export default function Importer() {
useEffect(() => {
let canceled = false;
Promise.all([
- listUniverses({ silent: true }).catch(() => []),
- listPipelineSeries({ silent: true }).catch(() => []),
+ listUniverseSummaries({ silent: true }).catch(() => []),
+ listPipelineSeriesSummaries({ silent: true }).catch(() => []),
]).then(([u, s]) => {
if (canceled) return;
setUniverses(Array.isArray(u) ? u : []);
diff --git a/client/src/pages/Pipeline.jsx b/client/src/pages/Pipeline.jsx
index 0c6200540a..262d3ae60d 100644
--- a/client/src/pages/Pipeline.jsx
+++ b/client/src/pages/Pipeline.jsx
@@ -21,12 +21,13 @@ import SyncBadge from '../components/sync/SyncBadge';
import { useSyncIntegrity, syncBadgeStatus } from '../hooks/useSyncIntegrity';
import {
listLooms,
- listPipelineSeries,
+ listPipelineSeriesSummaries,
createPipelineSeries,
deletePipelineSeries,
generateSeriesTitleLogo,
generateSeriesConcepts,
- listUniverses,
+ listUniverseNames,
+ getUniverse,
WORLD_LOGLINE_MAX,
WORLD_PREMISE_MAX,
WORLD_STYLE_NOTES_MAX,
@@ -71,6 +72,7 @@ export default function Pipeline() {
const sync = useSyncIntegrity('series');
const [creating, setCreating] = useState(false);
+ const [loadingUniverse, setLoadingUniverse] = useState(false);
const [generating, setGenerating] = useState(false);
const [showForm, setShowForm] = useState(false);
const [form, setForm] = useState(emptyForm);
@@ -92,10 +94,10 @@ export default function Pipeline() {
useEffect(() => {
Promise.all([
- listPipelineSeries().catch(() => []),
+ listPipelineSeriesSummaries({ silent: true }).catch(() => []),
// Universes are optional — failing the fetch should still let the user
// create a series without one. Surface the error as a quiet toast.
- listUniverses({ silent: true }).catch((err) => {
+ listUniverseNames({ silent: true }).catch((err) => {
toast.error(err.message || 'Failed to load universes');
return [];
}),
@@ -127,19 +129,24 @@ export default function Pipeline() {
}, { replace: true });
};
- const handleWorldChange = (universeId) => {
+ const worldRequestRef = useRef(0);
+ const handleWorldChange = async (universeId) => {
clearCandidates();
- if (!universeId) {
- setForm((f) => ({ ...f, universeId: '' }));
- return;
- }
- const w = universes.find((x) => x.id === universeId);
- if (!w) {
- setForm((f) => ({ ...f, universeId }));
- return;
- }
+ const request = ++worldRequestRef.current;
+ setLoadingUniverse(!!universeId);
+ setForm((f) => ({ ...f, universeId }));
+ if (!universeId) return;
+ // Only the selected universe needs a bible; do not hydrate the catalog on mount.
+ const w = await getUniverse(universeId, { silent: true }).catch((err) => {
+ if (request === worldRequestRef.current) toast.error(err.message || 'Failed to load universe');
+ return null;
+ });
+ if (request !== worldRequestRef.current) return;
+ setLoadingUniverse(false);
+ if (!w) return;
setForm((f) => {
- const next = { ...f, universeId };
+ if (f.universeId !== universeId) return f;
+ const next = { ...f };
for (const k of BIBLE_FIELDS) {
if (!f[k].trim()) next[k] = w[k] || '';
}
@@ -213,6 +220,7 @@ export default function Pipeline() {
const handleCreate = async (e) => {
e?.preventDefault();
+ if (loadingUniverse) return;
const name = form.name.trim();
if (!name) {
toast.error('Series name is required');
@@ -510,9 +518,9 @@ export default function Pipeline() {
<div className="flex gap-2">
<button
type="submit"
- disabled={creating || !form.universeId || !form.name.trim()}
+ disabled={creating || loadingUniverse || !form.universeId || !form.name.trim()}
className="inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-port-accent text-white text-sm font-medium disabled:opacity-50"
- title={!form.universeId ? 'Pick a universe to create the series' : undefined}
+ title={loadingUniverse ? 'Loading universe fields…' : !form.universeId ? 'Pick a universe to create the series' : undefined}
>
{creating ? <Loader2 size={14} className="animate-spin" /> : null}
Create
diff --git a/client/src/pages/Pipeline.loomBadge.test.jsx b/client/src/pages/Pipeline.loomBadge.test.jsx
index 6b8f50cb66..b40ba2fded 100644
--- a/client/src/pages/Pipeline.loomBadge.test.jsx
+++ b/client/src/pages/Pipeline.loomBadge.test.jsx
@@ -3,17 +3,17 @@ import { render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import Pipeline from './Pipeline';
-const listPipelineSeries = vi.fn();
-const listUniverses = vi.fn();
+const listPipelineSeriesSummaries = vi.fn();
+const listUniverseNames = vi.fn();
const listLooms = vi.fn();
vi.mock('../services/api', () => ({
- listPipelineSeries: (...a) => listPipelineSeries(...a),
+ listPipelineSeriesSummaries: (...a) => listPipelineSeriesSummaries(...a),
createPipelineSeries: vi.fn(),
deletePipelineSeries: vi.fn(),
generateSeriesTitleLogo: vi.fn(),
generateSeriesConcepts: vi.fn(),
- listUniverses: (...a) => listUniverses(...a),
+ listUniverseNames: (...a) => listUniverseNames(...a),
listLooms: (...a) => listLooms(...a),
WORLD_LOGLINE_MAX: 400,
WORLD_PREMISE_MAX: 2000,
@@ -42,8 +42,8 @@ const renderPage = () => render(
describe('Pipeline series list — branching-narrative badge', () => {
beforeEach(() => {
vi.clearAllMocks();
- listPipelineSeries.mockResolvedValue(SERIES);
- listUniverses.mockResolvedValue([]);
+ listPipelineSeriesSummaries.mockResolvedValue(SERIES);
+ listUniverseNames.mockResolvedValue([]);
listLooms.mockResolvedValue([
{ id: 'loom-1', seriesId: 'series-1' },
{ id: 'loom-2', seriesId: 'series-1' },
diff --git a/client/src/pages/Pipeline.responsive.test.jsx b/client/src/pages/Pipeline.responsive.test.jsx
index 581a294402..f61d3969b0 100644
--- a/client/src/pages/Pipeline.responsive.test.jsx
+++ b/client/src/pages/Pipeline.responsive.test.jsx
@@ -1,20 +1,22 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { fireEvent, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import Pipeline from './Pipeline';
-const listPipelineSeries = vi.fn();
-const listUniverses = vi.fn();
+const listPipelineSeriesSummaries = vi.fn();
+const listUniverseNames = vi.fn();
+const getUniverse = vi.fn();
const listLooms = vi.fn();
const listAuthors = vi.fn();
vi.mock('../services/api', () => ({
- listPipelineSeries: (...a) => listPipelineSeries(...a),
+ listPipelineSeriesSummaries: (...a) => listPipelineSeriesSummaries(...a),
createPipelineSeries: vi.fn(),
deletePipelineSeries: vi.fn(),
generateSeriesTitleLogo: vi.fn(),
generateSeriesConcepts: vi.fn(),
- listUniverses: (...a) => listUniverses(...a),
+ listUniverseNames: (...a) => listUniverseNames(...a),
+ getUniverse: (...a) => getUniverse(...a),
listLooms: (...a) => listLooms(...a),
listAuthors: (...a) => listAuthors(...a),
WORLD_LOGLINE_MAX: 400,
@@ -52,12 +54,36 @@ function renderPage() {
describe('Pipeline series list — mobile layout', () => {
beforeEach(() => {
vi.clearAllMocks();
- listPipelineSeries.mockResolvedValue([SERIES]);
- listUniverses.mockResolvedValue([]);
+ listPipelineSeriesSummaries.mockResolvedValue([SERIES]);
+ listUniverseNames.mockResolvedValue([]);
+ getUniverse.mockResolvedValue({});
listLooms.mockResolvedValue([]);
listAuthors.mockResolvedValue([]);
});
+ it('loads only the selected universe bible and ignores a stale selection response', async () => {
+ listUniverseNames.mockResolvedValue([{ id: 'u-a', name: 'World A' }, { id: 'u-b', name: 'World B' }]);
+ let resolveA;
+ getUniverse.mockImplementation((id) => id === 'u-a'
+ ? new Promise((resolve) => { resolveA = resolve; })
+ : Promise.resolve({ logline: 'World B logline', premise: 'World B premise', styleNotes: 'World B style' }));
+ renderPage();
+ fireEvent.click(await screen.findByRole('button', { name: 'New Series' }));
+ await screen.findByRole('option', { name: 'World A' });
+ expect(getUniverse).not.toHaveBeenCalled();
+ const select = screen.getByLabelText(/Universe \(required\)/);
+ fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'New story' } });
+ fireEvent.change(select, { target: { value: 'u-a' } });
+ expect(screen.getByRole('button', { name: 'Create', exact: true })).toBeDisabled();
+ fireEvent.change(select, { target: { value: 'u-b' } });
+ await waitFor(() => expect(screen.getByLabelText('Logline')).toHaveValue('World B logline'));
+ await act(async () => resolveA({ logline: 'Stale A', premise: 'Stale A' }));
+ expect(screen.getByLabelText('Logline')).toHaveValue('World B logline');
+ expect(screen.getByLabelText('Premise')).toHaveValue('World B premise');
+ expect(screen.getByRole('button', { name: 'Create', exact: true })).toBeEnabled();
+ expect(getUniverse).toHaveBeenCalledWith('u-b', { silent: true });
+ });
+
it('stacks the row below sm so the logline gets the full card width', async () => {
renderPage();
@@ -79,7 +105,7 @@ describe('Pipeline series list — mobile layout', () => {
});
it('directs an empty series form to the Create universes page', async () => {
- listPipelineSeries.mockResolvedValue([]);
+ listPipelineSeriesSummaries.mockResolvedValue([]);
renderPage();
fireEvent.click(await screen.findByRole('button', { name: 'New Series' }));
diff --git a/client/src/pages/StartStory.jsx b/client/src/pages/StartStory.jsx
index 26b0162de6..9674125969 100644
--- a/client/src/pages/StartStory.jsx
+++ b/client/src/pages/StartStory.jsx
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router';
import { Rocket, Lightbulb, FileInput, NotebookPen } from 'lucide-react';
-import { listUniverses } from '../services/api';
+import { listUniverseNames } from '../services/api';
import toast from '../components/ui/Toast';
// The "Start a Story" onramp (issue #1633, Phase 1). One clear front door that
@@ -55,7 +55,7 @@ export default function StartStory() {
// silent: the custom catch below owns the toast (AGENTS.md). A failed load
// just leaves the "use an existing universe" option empty — the onramp
// still works in "start fresh" mode.
- listUniverses({ silent: true })
+ listUniverseNames({ silent: true })
.catch((err) => {
toast.error(err?.message || 'Failed to load universes');
return [];
diff --git a/client/src/pages/StartStory.test.jsx b/client/src/pages/StartStory.test.jsx
index dc2e64324c..be1b3305ca 100644
--- a/client/src/pages/StartStory.test.jsx
+++ b/client/src/pages/StartStory.test.jsx
@@ -8,9 +8,9 @@ vi.mock('react-router', async (io) => {
return { ...actual, useNavigate: () => navigateMock };
});
-const listUniverses = vi.hoisted(() => vi.fn());
+const listUniverseNames = vi.hoisted(() => vi.fn());
vi.mock('../services/api', () => ({
- listUniverses: (...a) => listUniverses(...a),
+ listUniverseNames: (...a) => listUniverseNames(...a),
}));
const toastError = vi.hoisted(() => vi.fn());
@@ -22,7 +22,7 @@ describe('StartStory onramp', () => {
beforeEach(() => {
navigateMock.mockReset();
toastError.mockReset();
- listUniverses.mockReset().mockResolvedValue([
+ listUniverseNames.mockReset().mockResolvedValue([
{ id: 'u1', name: 'Alpha' },
{ id: 'u2', name: 'Beta' },
]);
@@ -80,7 +80,7 @@ describe('StartStory onramp', () => {
it('excludes untitled universes from the attach dropdown', async () => {
// The Importer matches universes by name, so an untitled one can't be an
// attach target — it must not appear as a selectable option.
- listUniverses.mockResolvedValueOnce([
+ listUniverseNames.mockResolvedValueOnce([
{ id: 'u1', name: 'Alpha' },
{ id: 'u2', name: '' },
{ id: 'u3', name: ' ' },
@@ -96,7 +96,7 @@ describe('StartStory onramp', () => {
});
it('surfaces a toast when the universe list fails to load', async () => {
- listUniverses.mockRejectedValueOnce(new Error('boom'));
+ listUniverseNames.mockRejectedValueOnce(new Error('boom'));
render(<StartStory />);
await waitFor(() => expect(toastError).toHaveBeenCalled());
});
diff --git a/client/src/pages/Universes.jsx b/client/src/pages/Universes.jsx
index e68584f7fd..eb639c8818 100644
--- a/client/src/pages/Universes.jsx
+++ b/client/src/pages/Universes.jsx
@@ -21,19 +21,11 @@ import SyncBadge from '../components/sync/SyncBadge';
import DuplicateGroup from '../components/sharing/DuplicateGroup';
import MergeModal from '../components/sharing/MergeModal';
import { timeAgo } from '../utils/formatters';
-import { listUniverses, deleteUniverse, listPipelineSeries, listMediaCollections, listUniverseDuplicates } from '../services/api';
+import { listUniverseSummaries, deleteUniverse, listPipelineSeriesSummaries, listMediaCollections, listUniverseDuplicates } from '../services/api';
import { useSyncIntegrity, syncBadgeStatus } from '../hooks/useSyncIntegrity';
import { useRecordMerge } from '../hooks/useRecordMerge';
import { useConfirmDelete } from '../hooks/useConfirmDelete';
-// Named canon entities across all trunks — the "Canon" column reflects the
-// characters/places/objects the user has registered, not the looser variation
-// buckets (which are render scratch space, not canon).
-const canonCount = (u) =>
- (Array.isArray(u?.characters) ? u.characters.length : 0) +
- (Array.isArray(u?.places) ? u.places.length : 0) +
- (Array.isArray(u?.objects) ? u.objects.length : 0);
-
// Build universeId → latest image filename from media collections. Mirrors
// resolveCover() in MediaCollections.jsx but trimmed: we only care about image
// items (videos don't render as a row thumbnail here) and the bucket is
@@ -56,17 +48,6 @@ const buildLatestImageByUniverse = (collections) => {
return out;
};
-// The universe's base style image — the subject-less "style probe" the detail
-// page (StyleProbeImage → EntryThumbSlot) shows. Mirror that component's
-// selection (last entry in `styleImageRefs`, no primaryImageRef concept here)
-// so the row thumbnail matches what the Universe Builder displays rather than
-// drifting to whatever the latest media-collection render happened to be (a
-// contact sheet, a character ref, etc.).
-const baseStyleImageRef = (u) => {
- const refs = Array.isArray(u?.styleImageRefs) ? u.styleImageRefs : [];
- return refs.length ? refs[refs.length - 1] : null;
-};
-
// 48px square thumbnail showing the universe's base style image, falling back
// to the latest image from its auto-managed media collection, then a Globe
// placeholder when neither exists (or hasn't loaded yet). The shared ImageThumb
@@ -133,7 +114,7 @@ export default function Universes() {
// Universes drive the page; resolve `loading` as soon as they land so a
// slow/hung series fetch can't keep the list stuck on "Loading…".
// silent: the custom catch below owns the error toast (AGENTS.md).
- listUniverses({ silent: true })
+ listUniverseSummaries({ silent: true })
.catch((err) => {
toast.error(err.message || 'Failed to load universes');
return [];
@@ -146,7 +127,7 @@ export default function Universes() {
// Series counts are a nice-to-have join, fetched independently — a failed
// or slow request should never block the universe list (counts just show
// 0). silent: swallowed to [] with no toast, so suppress request()'s.
- listPipelineSeries({ silent: true })
+ listPipelineSeriesSummaries({ silent: true })
.catch(() => [])
.then((s) => {
if (cancelled) return;
@@ -173,10 +154,10 @@ export default function Universes() {
// media folds into the survivor (thumbnails shift). Re-scan duplicates last so
// a folded group disappears from the banner.
const refresh = useCallback(() => {
- listUniverses({ silent: true })
+ listUniverseSummaries({ silent: true })
.then((u) => setUniverses(Array.isArray(u) ? u : []))
.catch((err) => toast.error(err.message || 'Failed to reload universes'));
- listPipelineSeries({ silent: true })
+ listPipelineSeriesSummaries({ silent: true })
.then((s) => setSeries(Array.isArray(s) ? s : []))
.catch(() => {});
listMediaCollections({ silent: true })
@@ -289,7 +270,7 @@ export default function Universes() {
<td className="px-4 py-3 align-top">
<div className="flex items-start gap-2 min-w-0">
<Link to={`/universes/${encodeURIComponent(u.id)}`} className="flex items-start gap-3 min-w-0 group flex-1">
- <UniverseThumb imageRef={baseStyleImageRef(u) || latestImageByUniverse.get(u.id)} />
+ <UniverseThumb imageRef={u.styleImageRef || latestImageByUniverse.get(u.id)} />
<div className="min-w-0 flex-1">
<div className="text-white font-medium flex items-center gap-2 flex-wrap group-hover:text-port-accent transition-colors">
<span>{u.name || '(untitled universe)'}</span>
@@ -306,7 +287,7 @@ export default function Universes() {
/>
</div>
</td>
- <td className="px-4 py-3 text-right whitespace-nowrap text-sm text-gray-300 font-mono">{canonCount(u)}</td>
+ <td className="px-4 py-3 text-right whitespace-nowrap text-sm text-gray-300 font-mono">{u.canonCount || 0}</td>
<td className="px-4 py-3 text-right whitespace-nowrap text-sm text-gray-300 font-mono">{seriesCountByUniverse[u.id] || 0}</td>
<td className="px-4 py-3 whitespace-nowrap text-xs text-gray-500">{timeAgo(u.updatedAt || u.createdAt)}</td>
<td className="px-4 py-3">
@@ -328,7 +309,7 @@ export default function Universes() {
<li key={u.id} className="p-3 bg-port-card border border-port-border rounded-lg">
<div className="flex items-start justify-between gap-3">
<Link to={`/universes/${encodeURIComponent(u.id)}`} className="flex items-start gap-3 flex-1 min-w-0">
- <UniverseThumb imageRef={baseStyleImageRef(u) || latestImageByUniverse.get(u.id)} />
+ <UniverseThumb imageRef={u.styleImageRef || latestImageByUniverse.get(u.id)} />
<div className="min-w-0 flex-1">
<div className="text-white font-medium flex items-center gap-2 flex-wrap">
<span>{u.name || '(untitled universe)'}</span>
@@ -338,7 +319,7 @@ export default function Universes() {
<div className="text-xs text-gray-500 mt-0.5 break-words">{u.logline}</div>
) : null}
<div className="flex items-center gap-3 mt-2 text-xs text-gray-500">
- <span className="inline-flex items-center gap-1"><Users size={12} /> {canonCount(u)} canon</span>
+ <span className="inline-flex items-center gap-1"><Users size={12} /> {u.canonCount || 0} canon</span>
<span className="inline-flex items-center gap-1"><WorkflowIcon size={12} /> {seriesCountByUniverse[u.id] || 0} series</span>
<span>{timeAgo(u.updatedAt || u.createdAt)}</span>
</div>
diff --git a/client/src/pages/Universes.test.jsx b/client/src/pages/Universes.test.jsx
index 3baeb26ef1..19f3f2a7ea 100644
--- a/client/src/pages/Universes.test.jsx
+++ b/client/src/pages/Universes.test.jsx
@@ -7,9 +7,9 @@ import { MemoryRouter } from 'react-router';
// buttons) that fetch on mount. Stub them so the test only exercises the
// duplicate-detection banner + merge flow added here.
vi.mock('../services/api', () => ({
- listUniverses: vi.fn(),
+ listUniverseSummaries: vi.fn(),
deleteUniverse: vi.fn(),
- listPipelineSeries: vi.fn(),
+ listPipelineSeriesSummaries: vi.fn(),
listMediaCollections: vi.fn(),
listUniverseDuplicates: vi.fn(),
previewUniverseMerge: vi.fn(),
@@ -42,11 +42,11 @@ const renderPage = () => render(<MemoryRouter><Universes /></MemoryRouter>);
beforeEach(() => {
vi.clearAllMocks();
- api.listUniverses.mockResolvedValue([
+ api.listUniverseSummaries.mockResolvedValue([
{ id: 'u-new', name: 'Clandestiny', createdAt: '2026-05-22T00:00:00Z', updatedAt: '2026-05-22T00:00:00Z' },
{ id: 'u-old', name: 'Clandestiny', createdAt: '2026-05-11T00:00:00Z', updatedAt: '2026-05-11T00:00:00Z' },
]);
- api.listPipelineSeries.mockResolvedValue([]);
+ api.listPipelineSeriesSummaries.mockResolvedValue([]);
api.listMediaCollections.mockResolvedValue([]);
api.listUniverseDuplicates.mockResolvedValue({ groups: [dupGroup] });
});
@@ -109,9 +109,9 @@ describe('Universes page — row thumbnail', () => {
api.listUniverseDuplicates.mockResolvedValue({ groups: [] });
});
- it('shows the base style image (last styleImageRef), matching the detail page', async () => {
- api.listUniverses.mockResolvedValue([
- { id: 'u1', name: 'Neon Expanse', styleImageRefs: ['old-style.png', 'base-style.png'], updatedAt: '2026-06-01T00:00:00Z' },
+ it('shows the projected canon count and base style image, matching the detail page', async () => {
+ api.listUniverseSummaries.mockResolvedValue([
+ { id: 'u1', name: 'Neon Expanse', styleImageRef: 'base-style.png', canonCount: 7, updatedAt: '2026-06-01T00:00:00Z' },
]);
// A media-collection image exists too, but the base style image wins.
api.listMediaCollections.mockResolvedValue([
@@ -121,15 +121,14 @@ describe('Universes page — row thumbnail', () => {
await waitFor(() => expect(screen.getAllByText('Neon Expanse').length).toBeGreaterThan(0));
const img = container.querySelector('img');
expect(img).toBeTruthy();
+ expect(screen.getAllByText('7').length).toBeGreaterThan(0);
expect(img.getAttribute('src')).toContain('base-style.png');
expect(img.getAttribute('src')).not.toContain('contact-sheet.png');
});
- it('treats an empty styleImageRefs array like a missing one and falls back to the media image', async () => {
- // Key-present-but-empty must behave like key-absent (the `refs.length` guard),
- // not crash on `refs[refs.length - 1]` (which would yield refs[-1] → undefined).
- api.listUniverses.mockResolvedValue([
- { id: 'u3', name: 'Void', styleImageRefs: [], updatedAt: '2026-06-01T00:00:00Z' },
+ it('falls back to the media image when the summary has no style image', async () => {
+ api.listUniverseSummaries.mockResolvedValue([
+ { id: 'u3', name: 'Void', styleImageRef: null, updatedAt: '2026-06-01T00:00:00Z' },
]);
api.listMediaCollections.mockResolvedValue([
{ universeId: 'u3', items: [{ kind: 'image', ref: 'media.png', addedAt: '2026-06-10T00:00:00Z' }] },
@@ -140,7 +139,7 @@ describe('Universes page — row thumbnail', () => {
});
it('falls back to the latest media-collection image when no base style image exists', async () => {
- api.listUniverses.mockResolvedValue([
+ api.listUniverseSummaries.mockResolvedValue([
{ id: 'u2', name: 'Reality', updatedAt: '2026-06-01T00:00:00Z' },
]);
api.listMediaCollections.mockResolvedValue([
diff --git a/client/src/services/README.md b/client/src/services/README.md
index 9fc47ff522..33de45225a 100644
--- a/client/src/services/README.md
+++ b/client/src/services/README.md
@@ -114,8 +114,8 @@ toasts on throw). **Custom catch ⇒ `silent: true`** — otherwise toasts fire
| `apiShell.js` | Shell sessions over HTTP: hand a photo (plus a message) to the agent TUI running in a session. Keystrokes/output stay on the `shell:*` socket protocol. |
| `apiThreejsModels.js` | Procedural Three.js model workspaces: gallery-image generation, refinement, source export, deletion, and the subject-family checklist options. |
| `apiImageTo3d.js` | Image-to-3D (`/3d`): selectable targets (TRELLIS.2) with host availability/install status, and per-image model records — create/list/get/generate/delete + GLB asset URL, the full-resolution OBJ download URL, and the AR Quick Look USDZ upload/download pair. |
-| `apiPipeline.js` | Pipeline (issues + stages + canon). |
-| `apiUniverseBuilder.js` | Universe Builder (generate + edit + commit). |
+| `apiPipeline.js` | Pipeline (issues + stages + canon; series names and index summaries). |
+| `apiUniverseBuilder.js` | Universe Builder (generate + edit + commit; names and index summaries). |
| `apiAuthors.js` | Author personas (name, writing style, bio, headshot description/style). |
| `apiArtists.js` | Music artist personas (name, genre, bio, musical style, portrait description/style). |
| `apiAlbums.js` | Music albums (title, artist FK + name, description, genre, release year, cover art, ordered track ids). |
diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.js
index 6c88de82f3..24cf39db5a 100644
--- a/client/src/services/apiPipeline.js
+++ b/client/src/services/apiPipeline.js
@@ -56,6 +56,8 @@ export const getPipelineConfig = (options = {}) => request('/pipeline/config', o
// ---- Series ----
// `options` lets a caller suppress request()'s auto-toast with `{ silent: true }`
// (e.g. an optional join that should fail quietly) — see AGENTS.md.
+export const listPipelineSeriesNames = (options = {}) => request('/pipeline/series/names', options);
+export const listPipelineSeriesSummaries = (options = {}) => request('/pipeline/series/summaries', options);
export const listPipelineSeries = (options = {}) => request('/pipeline/series', options);
export const getPipelineSeries = (id, options = {}) => request(`/pipeline/series/${encodeURIComponent(id)}`, options);
export const createPipelineSeries = (data, options = {}) => request('/pipeline/series', {
diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.js
index 1ddba1e70a..5e7be6ebda 100644
--- a/client/src/services/apiUniverseBuilder.js
+++ b/client/src/services/apiUniverseBuilder.js
@@ -60,6 +60,8 @@ export const waitForUniverseWrites = async (universeId, { timeoutMs = 15000 } =
// `options` lets a caller that owns its own error toast pass `{ silent: true }`
// so request() doesn't also toast — see AGENTS.md "Custom catch ⇒ silent: true".
+export const listUniverseNames = (options = {}) => request('/universe-builder/names', options);
+export const listUniverseSummaries = (options = {}) => request('/universe-builder/summaries', options);
export const listUniverses = (options = {}) => request('/universe-builder', options);
export const getUniverse = (id, options = {}) => request(`/universe-builder/${encodeURIComponent(id)}`, options);
export const exportUniverseMarkdown = (id, options = {}) => request(
diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.js
index afcc0c1a59..b63d1ad010 100644
--- a/server/routes/pipeline.test.js
+++ b/server/routes/pipeline.test.js
@@ -490,6 +490,28 @@ describe('pipeline routes', () => {
expect(nullUni.status).toBe(400);
});
+
+ it('serves series names and summary fields without changing the full list', async () => {
+ const app = makeApp();
+ const created = await request(app).post('/api/pipeline/series').send({
+ name: 'Projected', universeId: 'u-test', premise: 'A large bible',
+ logline: 'A city', issueCountTarget: 4, arc: { shape: 'man-in-hole', summary: 'Full arc' },
+ });
+ expect(created.status).toBe(201);
+ const names = await request(app).get('/api/pipeline/series/names');
+ expect(names.status).toBe(200);
+ expect(names.body).toEqual([{ id: created.body.id, name: 'Projected' }]);
+ const summaries = await request(app).get('/api/pipeline/series/summaries');
+ expect(summaries.status).toBe(200);
+ expect(summaries.body[0]).toMatchObject({
+ universeId: 'u-test', logline: 'A city', issueCountTarget: 4, arc: { shape: 'man-in-hole' },
+ });
+ expect(summaries.body[0]).not.toHaveProperty('premise');
+ expect(summaries.body[0].arc).not.toHaveProperty('summary');
+ const full = await request(app).get('/api/pipeline/series');
+ expect(full.body[0]).toMatchObject({ premise: 'A large bible', arc: { summary: 'Full arc' } });
+ });
+
it('GET /series preserves the bare array and supports bounded pagination', async () => {
const app = makeApp();
await request(app).post('/api/pipeline/series').send({ name: 'Alpha', universeId: 'u-test' });
diff --git a/server/routes/pipeline/series.js b/server/routes/pipeline/series.js
index 4021149a0e..1b2005f5a1 100644
--- a/server/routes/pipeline/series.js
+++ b/server/routes/pipeline/series.js
@@ -359,6 +359,14 @@ router.get('/series', asyncHandler(async (req, res) => {
res.json(paginateArray(series, req.query, { defaultLimit: 50, maxLimit: 500 }));
}));
+router.get('/series/names', asyncHandler(async (_req, res) => {
+ res.json(await seriesSvc.listSeriesNames());
+}));
+
+router.get('/series/summaries', asyncHandler(async (_req, res) => {
+ res.json(await seriesSvc.listSeriesSummaries());
+}));
+
router.post('/series', asyncHandler(async (req, res) => {
const body = validateRequest(seriesCreateSchema, req.body ?? {});
// Hierarchy invariant: every series belongs to exactly one universe. Enforce
diff --git a/server/routes/universeBuilder/crud.js b/server/routes/universeBuilder/crud.js
index 2fcd38254e..4ad008d6b2 100644
--- a/server/routes/universeBuilder/crud.js
+++ b/server/routes/universeBuilder/crud.js
@@ -132,6 +132,14 @@ router.get('/styles', asyncHandler(async (_req, res) => {
res.json(await svc.listUniverseStyles());
}));
+router.get('/names', asyncHandler(async (_req, res) => {
+ res.json(await svc.listUniverseNames());
+}));
+
+router.get('/summaries', asyncHandler(async (_req, res) => {
+ res.json(await svc.listUniverseSummaries());
+}));
+
router.get('/:id', asyncHandler(async (req, res) => {
// Read-by-id 404s are benign and high-volume: callers like LoraDatasetDetail
// speculatively fetch a dataset's `character.universeId` ({ silent: true }),
diff --git a/server/routes/universeBuilder/index.test.js b/server/routes/universeBuilder/index.test.js
index b5d62f0e25..aea56680e4 100644
--- a/server/routes/universeBuilder/index.test.js
+++ b/server/routes/universeBuilder/index.test.js
@@ -291,6 +291,27 @@ describe('universe-builder routes', () => {
mergeFieldsWithAIMock.mockReset();
});
+
+ it('serves names and summaries before the id route while keeping the full list', async () => {
+ const app = buildApp();
+ const created = await request(app).post('/api/universe-builder').send({
+ name: 'Projected', logline: 'A world', premise: 'A large bible',
+ styleImageRefs: ['first.png', 'latest.png'],
+ characters: [{ id: 'c-one', name: 'Ada' }],
+ });
+ expect(created.status).toBe(201);
+ const names = await request(app).get('/api/universe-builder/names');
+ expect(names.status).toBe(200);
+ expect(names.body).toEqual([{ id: created.body.id, name: 'Projected' }]);
+ const summaries = await request(app).get('/api/universe-builder/summaries');
+ expect(summaries.status).toBe(200);
+ expect(summaries.body[0]).toMatchObject({ canonCount: 1, styleImageRef: 'latest.png', logline: 'A world' });
+ expect(summaries.body[0]).not.toHaveProperty('characters');
+ expect(summaries.body[0]).not.toHaveProperty('premise');
+ const full = await request(app).get('/api/universe-builder');
+ expect(full.body[0]).toMatchObject({ premise: 'A large bible', characters: [{ name: 'Ada' }] });
+ });
+
it('GET / returns []', async () => {
const res = await request(buildApp()).get('/api/universe-builder');
expect(res.status).toBe(200);
diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.js
index ae63ffc12e..f9b82b6b64 100644
--- a/server/services/pipeline/series.js
+++ b/server/services/pipeline/series.js
@@ -711,6 +711,23 @@ export async function listSeries({ includeDeleted = false } = {}) {
return [...filtered].sort((a, b) => (b.updatedAt || '').localeCompare(a.updatedAt || ''));
}
+/** Lightweight sidebar/picker rows, sorted like the full series list. */
+export async function listSeriesNames() {
+ return (await store().listNames())
+ .filter((r) => isStr(r?.id) && r.id && trimTo(r.name, NAME_MAX))
+ .sort((a, b) => (b.updatedAt || '').localeCompare(a.updatedAt || '') || b.id.localeCompare(a.id))
+ .map((r) => ({ id: r.id, name: trimTo(r.name, NAME_MAX) }));
+}
+
+/** Index rows retain the displayed shape and cover without the story body. */
+export async function listSeriesSummaries() {
+ return (await store().listSummaries()).map(sanitizeSeries).filter(Boolean)
+ .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || b.id.localeCompare(a.id))
+ .map(({ id, name, universeId, logline, coverImage, origin, issueCountTarget, arc, createdAt, updatedAt }) =>
+ ({ id, name, universeId, logline, coverImage, origin, issueCountTarget,
+ arc: arc?.shape ? { shape: arc.shape } : null, createdAt, updatedAt }));
+}
+
export async function getSeries(id, { includeDeleted = false } = {}) {
const found = await store().loadOne(id);
if (!found) throw makeErr(`Series not found: ${id}`, ERR_NOT_FOUND);
diff --git a/server/services/pipeline/series.test.js b/server/services/pipeline/series.test.js
index e7cbe4d9fc..e24ae4e39d 100644
--- a/server/services/pipeline/series.test.js
+++ b/server/services/pipeline/series.test.js
@@ -64,6 +64,27 @@ describe('pipeline series service', () => {
__resetSubscriptionAdapter();
});
+
+ it('projects names and summaries while retaining full editor records and hiding tombstones', async () => {
+ await svc.createSeries({
+ name: 'Story', universeId: 'u-test', logline: 'A city goes silent.',
+ premise: 'The full premise', issueCountTarget: 4,
+ arc: { shape: 'man-in-hole', summary: 'A full arc' },
+ });
+ const removed = await svc.createSeries({ name: 'Removed' });
+ await svc.deleteSeries(removed.id);
+ const full = await svc.listSeries();
+ expect(await svc.listSeriesNames()).toEqual(full.map(({ id, name }) => ({ id, name })));
+ expect(await svc.listSeriesSummaries()).toEqual(full.map((s) => ({
+ id: s.id, name: s.name, universeId: s.universeId, logline: s.logline,
+ coverImage: s.coverImage, origin: s.origin, issueCountTarget: s.issueCountTarget,
+ arc: s.arc?.shape ? { shape: s.arc.shape } : null,
+ createdAt: s.createdAt, updatedAt: s.updatedAt,
+ })));
+ expect(full[0].premise).toBe('The full premise');
+ expect(full[0].arc.summary).toBe('A full arc');
+ });
+
it('listSeries returns [] for fresh state', async () => {
expect(await svc.listSeries()).toEqual([]);
});
diff --git a/server/services/pipeline/seriesStore/db.js b/server/services/pipeline/seriesStore/db.js
index 398fa21cbe..5e637e80d3 100644
--- a/server/services/pipeline/seriesStore/db.js
+++ b/server/services/pipeline/seriesStore/db.js
@@ -66,6 +66,28 @@ export async function listRaw() {
return rows.map((r) => r.data);
}
+/** Names and ordering only: no JSONB body is read for sidebar navigation. */
+export async function listNames() {
+ const { rows } = await query(
+ `SELECT id, name, to_char(updated_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') AS "updatedAt"
+ FROM pipeline_series WHERE deleted = FALSE`,
+ );
+ return rows;
+}
+
+/** Fields used by index rows and universe-scoped pickers, without arc/seasons. */
+export async function listSummaries() {
+ const { rows } = await query(
+ `SELECT id, name, universe_id AS "universeId",
+ data->>'logline' AS logline, data->>'coverImage' AS "coverImage",
+ data->'origin' AS origin, data->'issueCountTarget' AS "issueCountTarget",
+ jsonb_build_object('shape', data->'arc'->'shape') AS arc,
+ data->>'createdAt' AS "createdAt", data->>'updatedAt' AS "updatedAt"
+ FROM pipeline_series WHERE deleted = FALSE`,
+ );
+ return rows;
+}
+
/**
* Upsert one record. `data` is written verbatim (lossless); the typed mirror
* columns are bind-sanitized so a hand-edited/legacy record with a malformed
diff --git a/server/services/pipeline/seriesStore/db.test.js b/server/services/pipeline/seriesStore/db.test.js
index 4ef098503c..f7e959455d 100644
--- a/server/services/pipeline/seriesStore/db.test.js
+++ b/server/services/pipeline/seriesStore/db.test.js
@@ -56,6 +56,25 @@ describe.skipIf(!runDb)('pipeline series DB adapter round-trip', () => {
await close();
});
+
+ it('projects names and summary fields without transporting full arc or seasons', async () => {
+ await db.writeRaw('ser-live', S('ser-live', {
+ universeId: 'u-test', logline: 'A city', coverImage: 'cover.png', issueCountTarget: 4,
+ arc: { shape: 'man-in-hole', summary: 'Full arc' }, seasons: [{ name: 'Full season' }],
+ }));
+ await db.writeRaw('ser-deleted', S('ser-deleted', { deleted: true }));
+ const names = await db.listNames();
+ expect(names).toEqual([{ id: 'ser-live', name: 'ser-live', updatedAt: '2026-01-02T00:00:00.000Z' }]);
+ const summaries = await db.listSummaries();
+ expect(summaries).toHaveLength(1);
+ expect(summaries[0]).toMatchObject({
+ universeId: 'u-test', logline: 'A city', coverImage: 'cover.png', issueCountTarget: 4,
+ arc: { shape: 'man-in-hole' },
+ });
+ expect(summaries[0]).not.toHaveProperty('seasons');
+ expect(summaries[0]).not.toHaveProperty('data');
+ });
+
it('writes a record and reads it back verbatim', async () => {
const rec = S('ser-1', { universeId: 'u-1', seasons: [{ id: 'sea-1', number: 1 }], arc: { logline: 'x' } });
await db.writeRaw('ser-1', rec);
diff --git a/server/services/pipeline/seriesStore/store.js b/server/services/pipeline/seriesStore/store.js
index ef7e3020b1..659e912520 100644
--- a/server/services/pipeline/seriesStore/store.js
+++ b/server/services/pipeline/seriesStore/store.js
@@ -64,6 +64,11 @@ function makeFileBackend(dir, sanitizeRecord) {
});
return {
name: 'file',
+ listNames: async () => (await cs.loadAll()).filter((r) => !r.deleted)
+ .map(({ id, name, updatedAt }) => ({ id, name, updatedAt })),
+ listSummaries: async () => (await cs.loadAll()).filter((r) => !r.deleted)
+ .map(({ id, name, universeId, logline, coverImage, origin, issueCountTarget, arc, createdAt, updatedAt }) =>
+ ({ id, name, universeId, logline, coverImage, origin, issueCountTarget, arc: { shape: arc?.shape }, createdAt, updatedAt })),
readRaw: (id) => cs.loadOneRaw(id),
readOne: (id) => cs.loadOne(id),
listIds: () => cs.listIds(),
@@ -111,6 +116,8 @@ function makePgBackend(db, sanitizeRecord) {
listLiveIds: db.listLiveIds,
listTombstoneIdsBefore: db.listTombstoneIdsBefore,
listRaw: db.listRaw,
+ listNames: db.listNames,
+ listSummaries: db.listSummaries,
writeRaw: db.writeRaw,
deleteRaw: db.deleteRaw,
verify: async () => ({ ok: true, type: 'pipelineSeries', onDisk: null, expected: null,
@@ -175,6 +182,8 @@ function createFacade({ dir, sanitizeRecord }) {
if (typeof id !== 'string' || !ID_PATTERN.test(id)) return null;
return (await getBackend()).readRaw(id);
},
+ listNames: async () => (await getBackend()).listNames(),
+ listSummaries: async () => (await getBackend()).listSummaries(),
loadAll: async () => {
const raw = await (await getBackend()).listRaw();
return raw.map((r) => sanitizer(r)).filter((r) => r != null);
diff --git a/server/services/universeBuilder.test.js b/server/services/universeBuilder.test.js
index e2b71e31cf..a83a78c1d7 100644
--- a/server/services/universeBuilder.test.js
+++ b/server/services/universeBuilder.test.js
@@ -167,6 +167,29 @@ describe("universeBuilder service", () => {
expect(await svc.listUniverses()).toEqual([]);
});
+
+ it("lists compact names and index summaries without losing legacy canon counts", async () => {
+ await seedState({ universes: [
+ { id: 'u-live', name: 'Live', schemaVersion: 4, createdAt: '2026-01-02T00:00:00.000Z',
+ logline: 'A city', starterPrompt: 'A starting point', styleImageRefs: ['old.png', 'latest.png'],
+ characters: [{ id: 'c1', name: 'Ada' }], places: [{ id: 'p1', name: 'Port' }] },
+ { id: 'u-legacy', name: 'Legacy', schemaVersion: 3, createdAt: '2026-01-01T00:00:00.000Z',
+ categories: { characters: { variations: [{ id: 'v1', label: 'Scout', prompt: 'A scout' }] } } },
+ { id: 'u-deleted', name: 'Deleted', deleted: true },
+ ] });
+ const full = await svc.listUniverses();
+ expect(await svc.listUniverseNames()).toEqual(full.map(({ id, name }) => ({ id, name })));
+ const summaries = await svc.listUniverseSummaries();
+ expect(summaries).toEqual(full.map((u) => ({
+ id: u.id, name: u.name, logline: u.logline, starterPrompt: u.starterPrompt,
+ origin: u.origin, createdAt: u.createdAt, updatedAt: u.updatedAt,
+ canonCount: u.characters.length + u.places.length + u.objects.length,
+ styleImageRef: u.styleImageRefs.at(-1) || null,
+ })));
+ expect(summaries.find((u) => u.id === 'u-legacy').canonCount).toBe(1);
+ expect(summaries[0].styleImageRef).toBe('latest.png');
+ });
+
describe("listUniverseStyles", () => {
it("projects to style tokens only — no categories / canon / sheets", async () => {
const w = await seedWorld();
diff --git a/server/services/universeBuilder/crud.js b/server/services/universeBuilder/crud.js
index 3f3ceda238..724f6ea69c 100644
--- a/server/services/universeBuilder/crud.js
+++ b/server/services/universeBuilder/crud.js
@@ -78,6 +78,25 @@ export async function listUniverses({ includeDeleted = false } = {}) {
return [...filtered].sort((a, b) => (b.createdAt || '').localeCompare(a.createdAt || ''));
}
+/** Small index rows; the full-list API remains available to editors/export. */
+export async function listUniverseSummaries() {
+ const rows = await store().listSummaries();
+ return rows.flatMap((row) => {
+ const u = sanitizeTemplate(row.legacyRecord || row);
+ if (!u || u.deleted) return [];
+ return [{
+ id: u.id, name: u.name, logline: u.logline, starterPrompt: u.starterPrompt,
+ origin: u.origin, createdAt: u.createdAt, updatedAt: u.updatedAt,
+ canonCount: row.legacyRecord
+ ? u.characters.length + u.places.length + u.objects.length
+ : row.canonCount,
+ styleImageRef: row.legacyRecord
+ ? u.styleImageRefs.at(-1) || null
+ : sanitizeImageRefFilename(row.styleImageRef) || null,
+ }];
+ }).sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id.localeCompare(a.id));
+}
+
/**
* Every live universe as `{ id, name }` — a label and nothing else.
*
diff --git a/server/services/universeBuilder/db.js b/server/services/universeBuilder/db.js
index 8a5117a494..665aed611f 100644
--- a/server/services/universeBuilder/db.js
+++ b/server/services/universeBuilder/db.js
@@ -89,7 +89,37 @@ export async function listRaw() {
*/
export async function listNames() {
const { rows } = await query(
- `SELECT id, name, data->>'createdAt' AS "createdAt" FROM universes WHERE deleted = FALSE`,
+ `SELECT id, name, to_char(created_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') AS "createdAt" FROM universes WHERE deleted = FALSE`,
+ );
+ return rows;
+}
+
+/**
+ * Index projection. Only legacy canon layouts need the full sanitizer to fold
+ * category variations into canon; ordinary records return counts, not arrays.
+ */
+export async function listSummaries() {
+ const { rows } = await query(
+ `SELECT id, name,
+ data->>'logline' AS logline,
+ data->>'starterPrompt' AS "starterPrompt",
+ data->'origin' AS origin,
+ data->>'createdAt' AS "createdAt",
+ data->>'updatedAt' AS "updatedAt",
+ data->'styleImageRefs'->>-1 AS "styleImageRef",
+ (CASE WHEN jsonb_typeof(data->'characters') = 'array' THEN jsonb_array_length(data->'characters') ELSE 0 END
+ + CASE WHEN jsonb_typeof(data->'places') = 'array' THEN jsonb_array_length(data->'places') ELSE 0 END
+ + CASE WHEN jsonb_typeof(data->'objects') = 'array' THEN jsonb_array_length(data->'objects') ELSE 0 END) AS "canonCount",
+ CASE WHEN (CASE WHEN jsonb_typeof(data->'schemaVersion') = 'number'
+ THEN (data->>'schemaVersion')::numeric < 4 ELSE TRUE END)
+ OR EXISTS (
+ SELECT 1 FROM jsonb_object_keys(
+ CASE WHEN jsonb_typeof(data->'categories') = 'object' THEN data->'categories' ELSE '{}'::jsonb END
+ ) AS category(key)
+ WHERE key ~* '^[^a-z0-9]*characters?([^a-z0-9]|$)'
+ )
+ THEN data ELSE NULL END AS "legacyRecord"
+ FROM universes WHERE deleted = FALSE`,
);
return rows;
}
diff --git a/server/services/universeBuilder/db.test.js b/server/services/universeBuilder/db.test.js
index 2c8ee6410d..64eb80a6a6 100644
--- a/server/services/universeBuilder/db.test.js
+++ b/server/services/universeBuilder/db.test.js
@@ -72,6 +72,28 @@ describe.skipIf(!runDb)('universeBuilder DB adapter round-trip', () => {
await close();
});
+
+ it('projects names and index counts, with a compatibility fallback only for legacy canon', async () => {
+ await db.writeRaw('u-live', U('u-live', {
+ logline: 'A city', characters: [{ id: 'c1', name: 'Ada' }], places: [], objects: [],
+ styleImageRefs: ['old.png', 'last.png'], premise: 'Not a summary field',
+ }));
+ await db.writeRaw('u-legacy', U('u-legacy', { schemaVersion: 3, categories: {} }));
+ await db.writeRaw('u-deleted', U('u-deleted', { deleted: true }));
+ const names = await db.listNames();
+ expect(names.map((u) => u.id).sort()).toEqual(['u-legacy', 'u-live']);
+ expect(names.find((u) => u.id === 'u-live')).toEqual({
+ id: 'u-live', name: 'u-live', createdAt: '2026-01-01T00:00:00.000Z',
+ });
+ const summaries = await db.listSummaries();
+ expect(summaries).toHaveLength(2);
+ const live = summaries.find((u) => u.id === 'u-live');
+ expect(live).toMatchObject({ canonCount: 1, styleImageRef: 'last.png', logline: 'A city', legacyRecord: null });
+ expect(live).not.toHaveProperty('characters');
+ expect(live).not.toHaveProperty('premise');
+ expect(summaries.find((u) => u.id === 'u-legacy').legacyRecord.schemaVersion).toBe(3);
+ });
+
it('writes a record and reads it back verbatim', async () => {
const rec = U('u-1', { logline: 'a city', characters: [{ id: 'c1', name: 'Ada' }] });
await db.writeRaw('u-1', rec);
diff --git a/server/services/universeBuilder/store.js b/server/services/universeBuilder/store.js
index e87e33191a..0b3e8262dd 100644
--- a/server/services/universeBuilder/store.js
+++ b/server/services/universeBuilder/store.js
@@ -134,6 +134,7 @@ function makeFileBackend(dir) {
// reading them all (same constraint as countUniverses above). The `.map`
// is shape parity with db.listStyles, not a saving: both backends must
// hand the service the same row keys. Unordered — the service sorts.
+ listSummaries: async () => (await listRaw()).filter((r) => r && r.deleted !== true).map((legacyRecord) => ({ legacyRecord })),
listStyles: async () => {
const records = await listRaw();
return records
@@ -188,6 +189,7 @@ function makePgBackend(db) {
listRaw: db.listRaw,
countUniverses: db.countUniverses,
listNames: db.listNames,
+ listSummaries: db.listSummaries,
listStyles: db.listStyles,
writeRaw: db.writeRaw,
deleteRaw: db.deleteRaw,
@@ -249,6 +251,7 @@ function createFacade({ dir, sanitizeRecord }) {
listRaw: async () => (await getBackend()).listRaw(),
countUniverses: async (opts) => (await getBackend()).countUniverses(opts),
listNames: async () => (await getBackend()).listNames(),
+ listSummaries: async () => (await getBackend()).listSummaries(),
listStyles: async () => (await getBackend()).listStyles(),
loadOneRaw: async (id) => (await getBackend()).readRaw(id),
loadOne: async (id) => {