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: hasEmbeddings flag only for similar edges, add graph/sync route tests
Adam Eivy70fae56cb087
diff --git a/server/routes/brain.test.js b/server/routes/brain.test.jsindex 2cd8ef780e..106b28ae69 100644--- a/server/routes/brain.test.js+++ b/server/routes/brain.test.js@@ -880,4 +880,51 @@ describe('Brain Routes', () => {expect(response.body.inboxLog.correction.newDestination).toBe('projects');});});++ // ===========================================================================+ // GRAPH+ // ===========================================================================++ describe('GET /api/brain/graph', () => {+ it('should return graph data', async () => {+ const mockGraph = { nodes: [{ id: '1', label: 'Test' }], edges: [], hasEmbeddings: false };+ getBrainGraphData.mockResolvedValue(mockGraph);++ const response = await request(app).get('/api/brain/graph');+ expect(response.status).toBe(200);+ expect(response.body.nodes).toHaveLength(1);+ expect(response.body.hasEmbeddings).toBe(false);+ });++ it('should return 500 when service throws', async () => {+ getBrainGraphData.mockRejectedValue(new Error('Graph build failed'));++ const response = await request(app).get('/api/brain/graph');+ expect(response.status).toBe(500);+ });+ });++ // ===========================================================================+ // SYNC+ // ===========================================================================++ describe('POST /api/brain/sync', () => {+ it('should return sync stats', async () => {+ const mockStats = { synced: 5, skipped: 2, errors: 0 };+ syncAllBrainData.mockResolvedValue(mockStats);++ const response = await request(app).post('/api/brain/sync');+ expect(response.status).toBe(200);+ expect(response.body.synced).toBe(5);+ expect(response.body.skipped).toBe(2);+ expect(response.body.errors).toBe(0);+ });++ it('should return 500 when sync fails', async () => {+ syncAllBrainData.mockRejectedValue(new Error('Sync failed'));++ const response = await request(app).post('/api/brain/sync');+ expect(response.status).toBe(500);+ });+ });});diff --git a/server/services/brainGraph.js b/server/services/brainGraph.jsindex 4fc7cc78ab..fe7eaaed67 100644--- a/server/services/brainGraph.js+++ b/server/services/brainGraph.js@@ -73,12 +73,14 @@ export async function getBrainGraphData() {const edgeKey = [brainSourceId, brainTargetId].sort().join('-');if (seenEdges.has(edgeKey)) continue;seenEdges.add(edgeKey);- hasEmbeddings = true;++ const mappedType = edge.type === 'linked' ? 'linked' : 'similar';+ if (mappedType === 'similar') hasEmbeddings = true;edges.push({source: brainSourceId,target: brainTargetId,- type: edge.type === 'linked' ? 'linked' : 'similar',+ type: mappedType,weight: edge.weight});}