Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: add Docker/PostgreSQL availability handling across setup, UI, and health
Adam Eivy9a7e1edf08cc
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdnew file mode 100644index 0000000000..8477dd6a93--- /dev/null+++ b/.changelog/NEXT.md@@ -0,0 +1,15 @@+# Unreleased Changes++## Added++- PostgreSQL status in system health details endpoint (`/api/system/health/details`) with warnings when DB is disconnected or schema missing+- Backend status banners on CoS Memory and Brain Memory pages showing file-fallback warning with retry button+- `getMemoryBackendStatus` API client helper++## Changed++- `setup-db.js` now shows platform-specific Docker install/start instructions and prompts to continue when Docker is unavailable (TTY only; CI/piped scripts keep silent behavior)++## Fixed++## Removeddiff --git a/client/src/components/brain/tabs/MemoryTab.jsx b/client/src/components/brain/tabs/MemoryTab.jsxindex e9f21fe053..87b2e5f8ae 100644--- a/client/src/components/brain/tabs/MemoryTab.jsx+++ b/client/src/components/brain/tabs/MemoryTab.jsx@@ -10,7 +10,8 @@ import {ChevronDown,ChevronRight,CheckCircle2,- Search+ Search,+ AlertTriangle} from 'lucide-react';import toast from 'react-hot-toast';@@ -33,6 +34,7 @@ export default function MemoryTab({ onRefresh }) {const [addForm, setAddForm] = useState({});const [statusFilter, setStatusFilter] = useState('');const [searchQuery, setSearchQuery] = useState('');+ const [backendStatus, setBackendStatus] = useState(null);const fetchRecords = useCallback(async () => {setLoading(true);@@ -68,6 +70,14 @@ export default function MemoryTab({ onRefresh }) {fetchRecords();}, [fetchRecords]);+ const fetchBackendStatus = useCallback(() => {+ api.getMemoryBackendStatus().then(setBackendStatus).catch(() => null);+ }, []);++ useEffect(() => {+ fetchBackendStatus();+ }, [fetchBackendStatus]);+const handleSave = async () => {let result;switch (activeType) {@@ -553,6 +563,26 @@ export default function MemoryTab({ onRefresh }) {return (<div className="space-y-4">+ {/* Backend status banner */}+ {backendStatus?.backend === 'file' && (+ <div className="bg-port-warning/10 border border-port-warning/30 rounded-lg p-4 flex items-start gap-3">+ <AlertTriangle className="text-port-warning shrink-0 mt-0.5" size={20} />+ <div className="flex-1">+ <p className="text-port-warning font-medium">PostgreSQL unavailable — using file storage</p>+ {backendStatus.db?.error && (+ <p className="text-sm text-gray-400 mt-1">{backendStatus.db.error}</p>+ )}+ <p className="text-sm text-gray-500 mt-1">Semantic search and cross-instance sync are disabled.</p>+ </div>+ <button+ onClick={fetchBackendStatus}+ className="px-3 py-1.5 text-sm bg-port-warning/20 text-port-warning hover:bg-port-warning/30 rounded-lg transition-colors shrink-0"+ >+ Retry+ </button>+ </div>+ )}+{/* Type tabs */}<div className="flex items-center gap-2 flex-wrap">{MEMORY_TABS.map((tab) => {diff --git a/client/src/components/cos/tabs/MemoryTab.jsx b/client/src/components/cos/tabs/MemoryTab.jsxindex 0b51f53281..510c70aa0f 100644--- a/client/src/components/cos/tabs/MemoryTab.jsx+++ b/client/src/components/cos/tabs/MemoryTab.jsx@@ -1,6 +1,6 @@import { useState, useEffect, useCallback } from 'react';import { useSearchParams } from 'react-router-dom';-import { RefreshCw, Trash2, X, Check, XCircle, Pencil } from 'lucide-react';+import { RefreshCw, Trash2, X, Check, XCircle, Pencil, AlertTriangle } from 'lucide-react';import toast from 'react-hot-toast';import * as api from '../../../services/api';import { MEMORY_TYPES, MEMORY_TYPE_COLORS } from '../constants';@@ -30,6 +30,7 @@ export default function MemoryTab({ apps = [] }) {}, { replace: true });}, [setSearchParams]);const [embeddingStatus, setEmbeddingStatus] = useState(null);+ const [backendStatus, setBackendStatus] = useState(null);const [editingMemory, setEditingMemory] = useState(null);// Embedding provider/model configuration@@ -56,16 +57,18 @@ export default function MemoryTab({ apps = [] }) {const fetchData = useCallback(async () => {setLoading(true);- const [memoriesRes, pendingRes, statsRes, embRes] = await Promise.all([+ const [memoriesRes, pendingRes, statsRes, embRes, backendRes] = await Promise.all([api.getMemories({ limit: 100, ...filters }).catch(() => ({ memories: [] })),api.getMemories({ status: 'pending_approval', limit: 50 }).catch(() => ({ memories: [] })),api.getMemoryStats().catch(() => null),- api.getEmbeddingStatus().catch(() => null)+ api.getEmbeddingStatus().catch(() => null),+ api.getMemoryBackendStatus().catch(() => null)]);setMemories(memoriesRes.memories || []);setPendingMemories(pendingRes.memories || []);setStats(statsRes);setEmbeddingStatus(embRes);+ setBackendStatus(backendRes);setLoading(false);}, [filters]);@@ -106,6 +109,26 @@ export default function MemoryTab({ apps = [] }) {return (<div className="space-y-6">+ {/* Backend status banner */}+ {backendStatus?.backend === 'file' && (+ <div className="bg-port-warning/10 border border-port-warning/30 rounded-lg p-4 flex items-start gap-3">+ <AlertTriangle className="text-port-warning shrink-0 mt-0.5" size={20} />+ <div className="flex-1">+ <p className="text-port-warning font-medium">PostgreSQL unavailable — using file storage</p>+ {backendStatus.db?.error && (+ <p className="text-sm text-gray-400 mt-1">{backendStatus.db.error}</p>+ )}+ <p className="text-sm text-gray-500 mt-1">Semantic search and cross-instance sync are disabled.</p>+ </div>+ <button+ onClick={fetchData}+ className="px-3 py-1.5 text-sm bg-port-warning/20 text-port-warning hover:bg-port-warning/30 rounded-lg transition-colors shrink-0"+ >+ Retry+ </button>+ </div>+ )}+{/* Header */}<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3"><div>diff --git a/client/src/services/api.js b/client/src/services/api.jsindex 9ba782a3b7..516423577b 100644--- a/client/src/services/api.js+++ b/client/src/services/api.js@@ -845,6 +845,7 @@ export const consolidateMemories = (options = {}) => request('/memory/consolidatbody: JSON.stringify(options)});export const getEmbeddingStatus = () => request('/memory/embeddings/status');+export const getMemoryBackendStatus = () => request('/memory/backend/status', { silent: true });export const approveMemory = (id) => request(`/memory/${id}/approve`, { method: 'POST' });export const rejectMemory = (id) => request(`/memory/${id}/reject`, { method: 'POST' });diff --git a/scripts/setup-db.js b/scripts/setup-db.jsindex c1898783a1..6b41006579 100644--- a/scripts/setup-db.js+++ b/scripts/setup-db.js@@ -11,6 +11,7 @@*/import { execFileSync } from 'child_process';+import { createInterface } from 'readline';import { dirname, join } from 'path';import { fileURLToPath } from 'url';@@ -78,26 +79,76 @@ function waitForHealth(maxAttempts = 30) {return false;}+// Platform-specific Docker install/start hints+function getDockerHints(issue) {+ const platform = process.platform;+ const hints = { install: '', start: '' };++ if (platform === 'darwin') {+ hints.install = 'Install Docker Desktop: https://www.docker.com/products/docker-desktop/';+ hints.start = 'Open Docker Desktop or run: open -a Docker';+ } else if (platform === 'win32') {+ hints.install = 'Install Docker Desktop: https://www.docker.com/products/docker-desktop/';+ hints.start = 'Start Docker Desktop from the Start menu';+ } else {+ hints.install = 'Install Docker Engine: https://docs.docker.com/engine/install/';+ hints.start = 'Start Docker: sudo systemctl start docker';+ }++ return issue === 'not_installed' ? hints.install : hints.start;+}++// Prompt user to continue without Docker (TTY only)+function promptContinue(message, hint) {+ return new Promise((resolve) => {+ // Non-TTY (CI, piped scripts) — skip silently+ if (!process.stdin.isTTY) {+ console.log(`⏭️ ${message}`);+ console.log(` ${hint}`);+ console.log(' Memory system will use file-based JSON storage');+ resolve(true);+ return;+ }++ console.log(`⚠️ ${message}`);+ console.log(` ${hint}`);+ console.log('');++ const rl = createInterface({ input: process.stdin, output: process.stdout });+ rl.question(' Continue without Docker (file-based storage)? [Y/n] ', (answer) => {+ rl.close();+ const trimmed = answer.trim().toLowerCase();+ // Default is Y (continue)+ resolve(trimmed === '' || trimmed === 'y' || trimmed === 'yes');+ });+ });+}++async function handleDockerUnavailable(message, issue) {+ const hint = getDockerHints(issue);+ const shouldContinue = await promptContinue(message, hint);++ if (shouldContinue) {+ console.log(' Memory system will use file-based JSON storage');+ process.exit(0);+ } else {+ console.log(' Exiting — install/start Docker and try again');+ process.exit(1);+ }+}+console.log('🗄️ Setting up PostgreSQL + pgvector...');if (!hasDocker()) {- console.log('⏭️ Docker not found — skipping database setup');- console.log(' Memory system will use file-based JSON storage');- console.log(' Install Docker to enable PostgreSQL: https://docs.docker.com/get-docker/');- process.exit(0);+ await handleDockerUnavailable('Docker not found — skipping database setup', 'not_installed');}if (!isDockerRunning()) {- console.log('⏭️ Docker daemon not running — skipping database setup');- console.log(' Memory system will use file-based JSON storage');- console.log(' Start Docker Desktop or run: sudo systemctl start docker');- process.exit(0);+ await handleDockerUnavailable('Docker daemon not running — skipping database setup', 'not_running');}if (!hasCompose()) {- console.log('⏭️ docker compose not available — skipping database setup');- console.log(' Memory system will use file-based JSON storage');- process.exit(0);+ await handleDockerUnavailable('docker compose not available — skipping database setup', 'not_installed');}if (isContainerRunning()) {diff --git a/server/routes/systemHealth.js b/server/routes/systemHealth.jsindex 0b20a20cd7..259b1423bc 100644--- a/server/routes/systemHealth.js+++ b/server/routes/systemHealth.js@@ -4,6 +4,7 @@ import { listProcesses } from '../services/pm2.js';import * as apps from '../services/apps.js';import * as cos from '../services/cos.js';import { getSelf } from '../services/instances.js';+import { checkHealth } from '../lib/db.js';const router = Router();@@ -27,11 +28,12 @@ router.get('/health/details', async (req, res) => {const startTime = Date.now();// Gather data in parallel- const [pm2Processes, allApps, cosStatus, self] = await Promise.all([+ const [pm2Processes, allApps, cosStatus, self, dbHealth] = await Promise.all([listProcesses().catch(() => []),apps.getAllApps({ includeArchived: false }).catch(() => []),cos.getStatus().catch(() => null),- getSelf().catch(() => null)+ getSelf().catch(() => null),+ checkHealth().catch(() => ({ connected: false, hasSchema: false, error: 'Health check failed' }))]);// System metrics@@ -89,6 +91,14 @@ router.get('/health/details', async (req, res) => {warnings.push({ type: 'restarts', message: `${processStats.totalRestarts} total restarts` });}+ if (!dbHealth.connected) {+ if (overallHealth !== 'critical') overallHealth = 'warning';+ warnings.push({ type: 'database', message: `PostgreSQL disconnected${dbHealth.error ? `: ${dbHealth.error}` : ''}` });+ } else if (!dbHealth.hasSchema) {+ if (overallHealth !== 'critical') overallHealth = 'warning';+ warnings.push({ type: 'database', message: 'PostgreSQL connected but schema missing' });+ }+// CoS statusconst cosInfo = cosStatus ? {running: cosStatus.running,@@ -147,7 +157,8 @@ router.get('/health/details', async (req, res) => {},processes: processStats,apps: appStats,- cos: cosInfo+ cos: cosInfo,+ database: dbHealth});});