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
fix: read the universe list from a ref so brain-bridge ingests reach the Reality default
[._.]/ Adam Eivy41171b877094
diff --git a/client/src/pages/CatalogIngest.jsx b/client/src/pages/CatalogIngest.jsxindex e70171e19f..305f8cfde4 100644--- a/client/src/pages/CatalogIngest.jsx+++ b/client/src/pages/CatalogIngest.jsx@@ -117,7 +117,11 @@ export default function CatalogIngest() {const recorderRef = useRef(null);// "Catalogue into" — the universe every committed ingredient binds to// (#7615). Populated on mount; defaulted per-ingest in enterReviewFromResult.+ // Mirrored into a ref because the brain-bridge handoff runs from the+ // mount effect, whose closure would otherwise see the pre-load empty list+ // forever and never resolve the Reality default.const [universes, setUniverses] = useState([]);+ const universesRef = useRef([]);const [universeRef, setUniverseRef] = useState(UNASSIGNED_UNIVERSE);const brainHandledRef = useRef(false);// Creative inbox note ids handed off from the Brain batch-send. Once the@@ -138,7 +142,11 @@ export default function CatalogIngest() {// Load the "Catalogue into" options once. Best-effort — an empty list just// leaves Unassigned as the only choice.useEffect(() => {- listUniverseNames({ silent: true }).then((list) => setUniverses(Array.isArray(list) ? list : [])).catch(() => {});+ listUniverseNames({ silent: true }).then((list) => {+ const rows = Array.isArray(list) ? list : [];+ universesRef.current = rows;+ setUniverses(rows);+ }).catch(() => {});}, []);// Default the "Catalogue into" pick for a freshly-entered review phase.@@ -148,10 +156,11 @@ export default function CatalogIngest() {// Unassigned. `sourceKind` is one of 'paste' | 'url' | 'file' | 'voice' |// 'brain' | 'babble'.const defaultUniverseForSource = (sourceKind) => {- const reality = universes.find((u) => u.name === REALITY_UNIVERSE_NAME);+ const loaded = universesRef.current;+ const reality = loaded.find((u) => u.name === REALITY_UNIVERSE_NAME);if (FACTUAL_INGEST_KINDS.has(sourceKind)) return reality?.id || UNASSIGNED_UNIVERSE;const lastUsed = safeReadStorage(LAST_UNIVERSE_STORAGE_KEY);- if (lastUsed && (lastUsed === UNASSIGNED_UNIVERSE || universes.some((u) => u.id === lastUsed))) return lastUsed;+ if (lastUsed && (lastUsed === UNASSIGNED_UNIVERSE || loaded.some((u) => u.id === lastUsed))) return lastUsed;return reality?.id || UNASSIGNED_UNIVERSE;};diff --git a/client/src/pages/CatalogIngest.test.jsx b/client/src/pages/CatalogIngest.test.jsxindex 6a1036bd8c..7139384efe 100644--- a/client/src/pages/CatalogIngest.test.jsx+++ b/client/src/pages/CatalogIngest.test.jsx@@ -2,11 +2,12 @@ import { it, expect, vi } from 'vitest';import { render, screen, fireEvent, waitFor } from '@testing-library/react';import { MemoryRouter } from 'react-router';import CatalogIngest from './CatalogIngest';-import { createCatalogScrap, pruneCatalogScrap, commitCatalogScrapDraft } from '../services/apiCatalog';+import { createCatalogScrap, pruneCatalogScrap, commitCatalogScrapDraft, ingestCatalogBrain } from '../services/apiCatalog';+import { listUniverseNames } from '../services/apiUniverseBuilder';vi.mock('../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn() } }));vi.mock('../hooks/useProviderModels', () => ({ default: () => ({ providers: [], selectedProviderId: 'example-provider', selectedModel: 'example-model', availableModels: [], loading: false }) }));vi.mock('../components/ProviderModelSelector', () => ({ default: ({ onEffortChange }) => <button type="button" onClick={() => onEffortChange('high')}>High effort</button> }));-vi.mock('../services/apiCatalog', () => ({ createCatalogScrap: vi.fn(), pruneCatalogScrap: vi.fn(), commitCatalogScrapDraft: vi.fn() }));+vi.mock('../services/apiCatalog', () => ({ createCatalogScrap: vi.fn(), pruneCatalogScrap: vi.fn(), commitCatalogScrapDraft: vi.fn(), ingestCatalogBrain: vi.fn() }));vi.mock('../services/apiUniverseBuilder', () => ({ listUniverseNames: vi.fn().mockResolvedValue([]) }));it('prunes only on request, keeps the brainstorm, and saves edited selected suggestions', async () => {createCatalogScrap.mockResolvedValue({ scrap: { id: 'example-scrap' } });@@ -26,3 +27,35 @@ it('prunes only on request, keeps the brainstorm, and saves edited selected suggfireEvent.click(screen.getByRole('button', { name: /Commit/ }));await waitFor(() => expect(commitCatalogScrapDraft).toHaveBeenCalledWith('example-scrap', [expect.objectContaining({ name: 'The lost moon', type: 'idea' })], expect.anything()));});++// Regression (#7615): the brain-bridge handoff runs from the mount effect, so+// reading the universe list out of component STATE there captures the+// pre-load empty array and the capture-source Reality default never resolves —+// the select silently falls back to Unassigned, which is the exact unlinked+// outcome #7615 exists to stop. Hold the list in a ref so the mount-effect+// closure sees it.+it('defaults a brain-bridge ingest to the Reality universe even though it starts from the mount effect', async () => {+ listUniverseNames.mockResolvedValue([{ id: 'uni-other', name: 'Example Universe' }, { id: 'uni-reality', name: 'Reality' }]);+ // Resolves a macrotask later than the universe list — the real ordering,+ // where a tiny GET beats an LLM extraction by seconds.+ ingestCatalogBrain.mockImplementation(() => new Promise((resolve) => {+ setTimeout(() => resolve({ scrap: { id: 'brain-scrap' }, draft: { ideas: [{ name: 'Captured thought', summary: 'From the brain inbox.' }] } }), 0);+ }));+ commitCatalogScrapDraft.mockResolvedValue({ ingredients: [{ id: 'cat-idea-1' }] });++ render(+ <MemoryRouter initialEntries={[{ pathname: '/catalog/ingest', state: { brainIngest: { brainType: 'note', brainId: 'note-1', title: 'Captured' } } }]}>+ <CatalogIngest />+ </MemoryRouter>,+ );++ await screen.findByDisplayValue('Captured thought');+ expect(screen.getByLabelText('Catalogue into')).toHaveValue('uni-reality');++ fireEvent.click(screen.getByRole('button', { name: /Commit/ }));+ await waitFor(() => expect(commitCatalogScrapDraft).toHaveBeenCalledWith(+ 'brain-scrap',+ [expect.objectContaining({ name: 'Captured thought', type: 'idea' })],+ expect.objectContaining({ universeRef: 'uni-reality' }),+ ));+});