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: show database sync status on Instances page

Adam Eivyc0bf41dfa604
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0e4f52ebd8..d7866b8d9b 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,12 @@
## Added
+- Sync status indicators on Instances page showing brain and memory sync progress per peer
+- Self card displays local brain/memory sequence numbers
+- Each peer card shows cursor position vs remote max with synced/behind indicators
+- New `/api/instances/sync-status` endpoint exposes local sync sequences for peer probing
+- Probe now fetches remote peer's sync sequences to enable bidirectional sync awareness
+
## Changed
## Fixed
diff --git a/client/src/pages/Instances.jsx b/client/src/pages/Instances.jsx
index 9b3ad93987..30ac5efcdd 100644
--- a/client/src/pages/Instances.jsx
+++ b/client/src/pages/Instances.jsx
@@ -3,7 +3,8 @@ import {
Network, Plus, Trash2, RefreshCw, Edit3, Check, X,
Wifi, WifiOff, CircleDot,
Cpu, HardDrive, Activity, Bot, MonitorSmartphone, Tag,
- ArrowUpRight, ArrowDownLeft, ArrowLeftRight
+ ArrowUpRight, ArrowDownLeft, ArrowLeftRight,
+ Database, Brain, CheckCircle2, AlertCircle, Clock
} from 'lucide-react';
import toast from 'react-hot-toast';
import socket from '../services/socket';
@@ -82,7 +83,7 @@ function HealthSummary({ health, version }) {
);
}
-function SelfCard({ self, onUpdate }) {
+function SelfCard({ self, onUpdate, syncStatus }) {
const [editing, setEditing] = useState(false);
const [name, setName] = useState('');
@@ -136,6 +137,16 @@ function SelfCard({ self, onUpdate }) {
)}
</div>
<p className="text-xs text-gray-500 font-mono">{self.instanceId}</p>
+ {syncStatus?.local && (
+ <div className="mt-2 pt-2 border-t border-port-border/50 flex items-center gap-4 text-xs text-gray-400">
+ <span className="flex items-center gap-1.5">
+ <Brain size={12} /> Brain seq: {syncStatus.local.brainSeq}
+ </span>
+ <span className="flex items-center gap-1.5">
+ <Database size={12} /> Memory seq: {syncStatus.local.memorySeq}
+ </span>
+ </div>
+ )}
</div>
</div>
);
@@ -232,7 +243,78 @@ function DirectionBadge({ directions = [] }) {
return null;
}
-function PeerCard({ peer, onRefresh }) {
+function SyncStatusBadge({ label, icon: Icon, localSeq, peerSeq, cursorSeq }) {
+ // cursorSeq = how far we've pulled from them (our cursor for their data)
+ // localSeq = our local max seq for this data type
+ // peerSeq = their max seq for this data type (from their sync-status endpoint)
+
+ // "Inbound" = are we caught up with them? (our cursor vs their max)
+ const inboundSynced = peerSeq != null && cursorSeq != null && String(cursorSeq) === String(peerSeq);
+ const inboundBehind = peerSeq != null && cursorSeq != null && String(cursorSeq) !== String(peerSeq);
+
+ if (peerSeq == null && cursorSeq == null) return null;
+
+ return (
+ <div className="flex items-center gap-1.5 text-xs">
+ <Icon size={12} className="text-gray-500" />
+ <span className="text-gray-500">{label}:</span>
+ {peerSeq != null && (
+ <span className="flex items-center gap-0.5" title={`Our cursor: ${cursorSeq ?? 0} / Their max: ${peerSeq}`}>
+ {inboundSynced ? (
+ <CheckCircle2 size={11} className="text-port-success" />
+ ) : inboundBehind ? (
+ <AlertCircle size={11} className="text-port-warning" />
+ ) : (
+ <Clock size={11} className="text-gray-500" />
+ )}
+ <span className={inboundSynced ? 'text-port-success' : inboundBehind ? 'text-port-warning' : 'text-gray-400'}>
+ {cursorSeq ?? 0}/{peerSeq}
+ </span>
+ </span>
+ )}
+ </div>
+ );
+}
+
+function SyncStatusSection({ peer, syncStatus }) {
+ if (!syncStatus || !peer.instanceId) return null;
+
+ const cursor = syncStatus.cursors?.[peer.instanceId];
+ const remoteSyncSeqs = peer.remoteSyncSeqs;
+
+ // No sync data available at all
+ if (!cursor && !remoteSyncSeqs) return null;
+
+ return (
+ <div className="mt-2 pt-2 border-t border-port-border/50">
+ <div className="flex items-center gap-1.5 mb-1.5">
+ <Database size={12} className="text-gray-500" />
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-medium">Sync Status</span>
+ {cursor?.lastSyncAt && (
+ <span className="text-[10px] text-gray-600 ml-auto">{timeAgo(cursor.lastSyncAt)}</span>
+ )}
+ </div>
+ <div className="grid grid-cols-2 gap-x-3 gap-y-0.5">
+ <SyncStatusBadge
+ label="Brain"
+ icon={Brain}
+ localSeq={syncStatus.local?.brainSeq}
+ peerSeq={remoteSyncSeqs?.brainSeq}
+ cursorSeq={cursor?.brainSeq}
+ />
+ <SyncStatusBadge
+ label="Memory"
+ icon={Database}
+ localSeq={syncStatus.local?.memorySeq}
+ peerSeq={remoteSyncSeqs?.memorySeq}
+ cursorSeq={cursor?.memorySeq}
+ />
+ </div>
+ </div>
+ );
+}
+
+function PeerCard({ peer, onRefresh, syncStatus }) {
const [editingName, setEditingName] = useState(false);
const [name, setName] = useState('');
const [probing, setProbing] = useState(false);
@@ -359,6 +441,8 @@ function PeerCard({ peer, onRefresh }) {
Last seen: {timeAgo(peer.lastSeen)}
</div>
+ <SyncStatusSection peer={peer} syncStatus={syncStatus} />
+
<PeerAppsList apps={peer.lastApps} peerAddress={peer.address} />
{peer.status === 'online' && (
<PeerAgentsSection peerId={peer.id} peerName={peer.name} />
@@ -370,6 +454,7 @@ function PeerCard({ peer, onRefresh }) {
export default function Instances() {
const [self, setSelf] = useState(null);
const [peers, setPeers] = useState([]);
+ const [syncStatus, setSyncStatus] = useState(null);
const [loading, setLoading] = useState(true);
const fetchData = useCallback(async () => {
@@ -377,6 +462,7 @@ export default function Instances() {
if (data) {
setSelf(data.self);
setPeers(data.peers);
+ setSyncStatus(data.syncStatus ?? null);
}
setLoading(false);
}, []);
@@ -412,7 +498,7 @@ export default function Instances() {
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <SelfCard self={self} onUpdate={fetchData} />
+ <SelfCard self={self} onUpdate={fetchData} syncStatus={syncStatus} />
<AddPeerForm onAdd={fetchData} />
</div>
@@ -423,7 +509,7 @@ export default function Instances() {
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
{peers.map(peer => (
- <PeerCard key={peer.id} peer={peer} onRefresh={fetchData} />
+ <PeerCard key={peer.id} peer={peer} onRefresh={fetchData} syncStatus={syncStatus} />
))}
</div>
</div>
diff --git a/server/routes/instances.js b/server/routes/instances.js
index 5411942d4f..ecbce145aa 100644
--- a/server/routes/instances.js
+++ b/server/routes/instances.js
@@ -7,6 +7,7 @@
import { Router } from 'express';
import { z } from 'zod';
import * as instances from '../services/instances.js';
+import { getSyncStatus } from '../services/syncOrchestrator.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { DEFAULT_PEER_PORT } from '../lib/ports.js';
@@ -38,9 +39,18 @@ const querySchema = z.object({
// GET /api/instances — list self + all peers
router.get('/', asyncHandler(async (req, res) => {
- const self = await instances.getSelf();
- const peers = await instances.getPeers();
- res.json({ self, peers });
+ const [self, peers, syncStatus] = await Promise.all([
+ instances.getSelf(),
+ instances.getPeers(),
+ getSyncStatus()
+ ]);
+ res.json({ self, peers, syncStatus });
+}));
+
+// GET /api/instances/sync-status — local sync sequences (used by peers during probe)
+router.get('/sync-status', asyncHandler(async (req, res) => {
+ const status = await getSyncStatus();
+ res.json({ brainSeq: status.local.brainSeq, memorySeq: status.local.memorySeq });
}));
// GET /api/instances/self — get this instance's identity
diff --git a/server/services/instances.js b/server/services/instances.js
index 7d3e8444cf..1605937947 100644
--- a/server/services/instances.js
+++ b/server/services/instances.js
@@ -160,12 +160,13 @@ export async function probePeer(peer) {
const timeout = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);
const previousStatus = peer.status;
- let status, lastHealth, lastSeen, remoteInstanceId, remoteVersion, remoteApps;
+ let status, lastHealth, lastSeen, remoteInstanceId, remoteVersion, remoteApps, remoteSyncSeqs;
try {
- // Fetch health details and apps in parallel
- const [healthRes, appsRes] = await Promise.all([
+ // Fetch health details, apps, and sync status in parallel
+ const [healthRes, appsRes, syncRes] = await Promise.all([
fetch(`${baseUrl}/api/system/health/details`, { signal: controller.signal }),
- fetch(`${baseUrl}/api/apps`, { signal: controller.signal }).catch(() => null)
+ fetch(`${baseUrl}/api/apps`, { signal: controller.signal }).catch(() => null),
+ fetch(`${baseUrl}/api/instances/sync-status`, { signal: controller.signal }).catch(() => null)
]);
if (!healthRes.ok) throw new Error(`HTTP ${healthRes.status}`);
const json = await healthRes.json();
@@ -183,6 +184,9 @@ export async function probePeer(peer) {
overallStatus: a.overallStatus, uiPort: a.uiPort, apiPort: a.apiPort, type: a.type
})) ?? null;
}
+ if (syncRes?.ok) {
+ remoteSyncSeqs = await syncRes.json().catch(() => null);
+ }
} catch {
status = 'offline';
lastHealth = peer.lastHealth; // preserve last known
@@ -198,6 +202,7 @@ export async function probePeer(peer) {
entry.lastSeen = lastSeen;
entry.lastHealth = lastHealth;
entry.lastApps = remoteApps ?? entry.lastApps ?? null;
+ entry.remoteSyncSeqs = remoteSyncSeqs ?? entry.remoteSyncSeqs ?? null;
if (remoteInstanceId) entry.instanceId = remoteInstanceId;
if (status === 'online') entry.version = remoteVersion;
// Auto-update name from hostname if current name is just an IP address
diff --git a/server/services/syncOrchestrator.js b/server/services/syncOrchestrator.js
index 1a4db6585d..72e831ba4a 100644
--- a/server/services/syncOrchestrator.js
+++ b/server/services/syncOrchestrator.js
@@ -62,6 +62,23 @@ async function fetchPeer(peer, path) {
}
}
+// --- Status ---
+
+/**
+ * Get sync status: local sequences + per-peer cursors
+ */
+export async function getSyncStatus() {
+ const [brainSeq, memorySeq, cursors] = await Promise.all([
+ Promise.resolve(brainSyncLog.getCurrentSeq()),
+ memorySync.getMaxSequence(),
+ loadCursors()
+ ]);
+ return {
+ local: { brainSeq, memorySeq },
+ cursors
+ };
+}
+
// --- Sync logic ---
/**