@andespindola/brainlink 0.1.0-beta.5 → 0.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,6 +12,7 @@ const state = {
|
|
|
12
12
|
transform: { x: 0, y: 0, scale: 1 },
|
|
13
13
|
pointer: { x: 0, y: 0, down: false, dragNode: null, moved: false },
|
|
14
14
|
graphSignature: '',
|
|
15
|
+
graphStatus: '',
|
|
15
16
|
last: performance.now()
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -43,6 +44,22 @@ const elements = {
|
|
|
43
44
|
|
|
44
45
|
const agentQuery = () => state.agentId ? '?agent=' + encodeURIComponent(state.agentId) : ''
|
|
45
46
|
|
|
47
|
+
const setGraphStatus = text => {
|
|
48
|
+
state.graphStatus = text
|
|
49
|
+
elements.stats.textContent = text
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const handleGraphRefreshError = error => {
|
|
53
|
+
if (state.graphSignature) {
|
|
54
|
+
elements.stats.textContent = state.graphStatus
|
|
55
|
+
console.error(error)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
elements.stats.textContent = 'Failed to load graph'
|
|
60
|
+
console.error(error)
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
const graphTheme = {
|
|
47
64
|
node: '#aeb8c5',
|
|
48
65
|
nodeSelected: '#f3f7fb',
|
|
@@ -418,7 +435,7 @@ const loadGraph = async (options = { reset: false }) => {
|
|
|
418
435
|
state.nodes = layout.nodes
|
|
419
436
|
state.edges = layout.edges
|
|
420
437
|
const tags = new Set(graph.nodes.flatMap(node => node.tags))
|
|
421
|
-
|
|
438
|
+
setGraphStatus(state.agentId + ' · ' + graph.nodes.length + ' notes · ' + graph.edges.length + ' links · live')
|
|
422
439
|
elements.nodeCount.textContent = graph.nodes.length
|
|
423
440
|
elements.edgeCount.textContent = graph.edges.length
|
|
424
441
|
elements.tagCount.textContent = tags.size
|
|
@@ -441,10 +458,7 @@ const refreshGraphLoop = () => {
|
|
|
441
458
|
return
|
|
442
459
|
}
|
|
443
460
|
|
|
444
|
-
loadGraph().catch(
|
|
445
|
-
elements.stats.textContent = 'Failed to refresh graph'
|
|
446
|
-
console.error(error)
|
|
447
|
-
})
|
|
461
|
+
loadGraph().catch(handleGraphRefreshError)
|
|
448
462
|
|
|
449
463
|
tickCounter += 1
|
|
450
464
|
if (tickCounter % 3 === 0) {
|
|
@@ -470,9 +484,6 @@ document.addEventListener('visibilitychange', () => {
|
|
|
470
484
|
return
|
|
471
485
|
}
|
|
472
486
|
|
|
473
|
-
loadGraph({ reset: true }).catch(
|
|
474
|
-
elements.stats.textContent = 'Failed to refresh graph'
|
|
475
|
-
console.error(error)
|
|
476
|
-
})
|
|
487
|
+
loadGraph({ reset: true }).catch(handleGraphRefreshError)
|
|
477
488
|
})
|
|
478
489
|
`;
|
package/package.json
CHANGED