@atolis-hq/corum 0.1.27 → 0.1.28
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.
- package/dist/src/web/server.js +33 -0
- package/package.json +1 -1
- package/web/app.jsx +193 -3
- package/web/style.css +109 -0
package/dist/src/web/server.js
CHANGED
|
@@ -384,6 +384,39 @@ export function createApp(graph, reloadEvents = createReloadEvents(), source, mu
|
|
|
384
384
|
res.status(500).json({ error: String(err) });
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
|
+
app.get('/api/stats', async (req, res) => {
|
|
388
|
+
let targetGraph = graph;
|
|
389
|
+
if (typeof req.query.ref === 'string' && multiCache) {
|
|
390
|
+
targetGraph = await getGraphForRef(req.query.ref, multiCache, graph);
|
|
391
|
+
}
|
|
392
|
+
const components = new Set();
|
|
393
|
+
for (const node of targetGraph.nodesById.values()) {
|
|
394
|
+
if (node.component)
|
|
395
|
+
components.add(node.component);
|
|
396
|
+
}
|
|
397
|
+
const nodesWithEdges = new Set();
|
|
398
|
+
const edgesByType = {
|
|
399
|
+
triggers: 0, produces: 0, reads: 0, calls: 0, implements: 0, 'maps-to': 0, 'derived-from': 0,
|
|
400
|
+
};
|
|
401
|
+
for (const edgeList of targetGraph.edgesByFrom.values()) {
|
|
402
|
+
for (const edge of edgeList) {
|
|
403
|
+
if (!GRAPH_SEMANTIC_EDGE_TYPES.has(edge.type))
|
|
404
|
+
continue;
|
|
405
|
+
edgesByType[edge.type]++;
|
|
406
|
+
nodesWithEdges.add(edge.from);
|
|
407
|
+
nodesWithEdges.add(edge.to);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const orphanNodeCount = [...targetGraph.nodesById.keys()]
|
|
411
|
+
.filter(id => !nodesWithEdges.has(id)).length;
|
|
412
|
+
res.json({
|
|
413
|
+
nodeCount: targetGraph.nodesById.size,
|
|
414
|
+
componentCount: components.size,
|
|
415
|
+
orphanNodeCount,
|
|
416
|
+
edgesByType,
|
|
417
|
+
diagnosticCount: targetGraph.diagnostics.length,
|
|
418
|
+
});
|
|
419
|
+
});
|
|
387
420
|
app.get('/api/cluster', async (req, res) => {
|
|
388
421
|
const nodeId = typeof req.query.nodeId === 'string' ? req.query.nodeId : undefined;
|
|
389
422
|
if (!nodeId) {
|
package/package.json
CHANGED
package/web/app.jsx
CHANGED
|
@@ -494,8 +494,189 @@ function BranchBar({ branches, branchResults, viewingRef, overlayRefs, overlayMo
|
|
|
494
494
|
);
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
-
function
|
|
498
|
-
return
|
|
497
|
+
function HeroCard({ value, label }) {
|
|
498
|
+
return (
|
|
499
|
+
<div className="hero-card">
|
|
500
|
+
<div className="hero-number">{value}</div>
|
|
501
|
+
<div className="hero-label">{label}</div>
|
|
502
|
+
</div>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function DashboardPage({ nodes, templates, gitMode, viewingRef, branches, branchResults }) {
|
|
507
|
+
const [stats, setStats] = useState(null);
|
|
508
|
+
const [branchDiff, setBranchDiff] = useState(null);
|
|
509
|
+
|
|
510
|
+
const defaultBranchRef = branches.find(b => b.isDefault)?.ref ?? null;
|
|
511
|
+
const isOnNonDefaultBranch = gitMode && viewingRef && defaultBranchRef && viewingRef !== defaultBranchRef;
|
|
512
|
+
|
|
513
|
+
useEffect(() => {
|
|
514
|
+
const refParam = viewingRef ? `?ref=${encodeURIComponent(viewingRef)}` : '';
|
|
515
|
+
fetch(`/api/stats${refParam}`)
|
|
516
|
+
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
|
517
|
+
.then(setStats)
|
|
518
|
+
.catch(() => setStats(null));
|
|
519
|
+
}, [viewingRef]);
|
|
520
|
+
|
|
521
|
+
useEffect(() => {
|
|
522
|
+
if (!isOnNonDefaultBranch) { setBranchDiff(null); return; }
|
|
523
|
+
fetch(`/api/overlay/${encodeURIComponent(viewingRef)}`)
|
|
524
|
+
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
|
525
|
+
.then(data => {
|
|
526
|
+
const added = (data.nodes || []).filter(n => n.ghostState === 'local').length;
|
|
527
|
+
const removed = (data.nodes || []).filter(n => n.ghostState === 'default-only').length;
|
|
528
|
+
setBranchDiff({ added, removed, defaultBranch: defaultBranchRef });
|
|
529
|
+
})
|
|
530
|
+
.catch(() => setBranchDiff(null));
|
|
531
|
+
}, [isOnNonDefaultBranch, viewingRef, defaultBranchRef]);
|
|
532
|
+
|
|
533
|
+
const componentCount = new Set(nodes.map(n => n.component).filter(Boolean)).size;
|
|
534
|
+
const nodeCount = nodes.length;
|
|
535
|
+
const totalEdges = stats ? Object.values(stats.edgesByType).reduce((a, b) => a + b, 0) : '…';
|
|
536
|
+
|
|
537
|
+
const templateMap = new Map(templates.map(t => [t.name, t]));
|
|
538
|
+
|
|
539
|
+
const nodesByTemplate = [...nodes.reduce((acc, node) => {
|
|
540
|
+
acc.set(node.template, (acc.get(node.template) ?? 0) + 1);
|
|
541
|
+
return acc;
|
|
542
|
+
}, new Map()).entries()].sort((a, b) => b[1] - a[1]);
|
|
543
|
+
|
|
544
|
+
const nodesByState = [...nodes.reduce((acc, node) => {
|
|
545
|
+
acc.set(node.state, (acc.get(node.state) ?? 0) + 1);
|
|
546
|
+
return acc;
|
|
547
|
+
}, new Map()).entries()].sort((a, b) => b[1] - a[1]);
|
|
548
|
+
|
|
549
|
+
const nodesByStability = [...nodes.reduce((acc, node) => {
|
|
550
|
+
acc.set(node.stability, (acc.get(node.stability) ?? 0) + 1);
|
|
551
|
+
return acc;
|
|
552
|
+
}, new Map()).entries()].sort((a, b) => b[1] - a[1]);
|
|
553
|
+
|
|
554
|
+
const edgeRows = stats
|
|
555
|
+
? Object.entries(stats.edgesByType).filter(([, count]) => count > 0).sort((a, b) => b[1] - a[1])
|
|
556
|
+
: [];
|
|
557
|
+
|
|
558
|
+
return (
|
|
559
|
+
<div className="content">
|
|
560
|
+
<div className="dashboard-hero">
|
|
561
|
+
<HeroCard value={componentCount} label="Components" />
|
|
562
|
+
<HeroCard value={nodeCount} label="Nodes" />
|
|
563
|
+
<HeroCard value={totalEdges} label="Edges" />
|
|
564
|
+
<HeroCard value={stats ? stats.orphanNodeCount : '…'} label="Orphan Nodes" />
|
|
565
|
+
</div>
|
|
566
|
+
|
|
567
|
+
{branchDiff && (
|
|
568
|
+
<div className="branch-diff-callout">
|
|
569
|
+
<span className="branch-diff-branch">⎇ {viewingRef}</span>
|
|
570
|
+
<span className="branch-diff-label">vs {branchDiff.defaultBranch}</span>
|
|
571
|
+
{branchDiff.added > 0 && <span className="branch-diff-added">+{branchDiff.added} added</span>}
|
|
572
|
+
{branchDiff.removed > 0 && <span className="branch-diff-removed">−{branchDiff.removed} removed</span>}
|
|
573
|
+
{branchDiff.added === 0 && branchDiff.removed === 0 && (
|
|
574
|
+
<span className="branch-diff-label">No changes</span>
|
|
575
|
+
)}
|
|
576
|
+
</div>
|
|
577
|
+
)}
|
|
578
|
+
|
|
579
|
+
<div className="dashboard-grid">
|
|
580
|
+
<div className="dashboard-panel">
|
|
581
|
+
<div className="card-head">Nodes by Type</div>
|
|
582
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
583
|
+
{nodesByTemplate.map(([name, count]) => {
|
|
584
|
+
const tmpl = templateMap.get(name);
|
|
585
|
+
const colour = tmpl?.ui?.colour ?? 'var(--ink-4)';
|
|
586
|
+
return (
|
|
587
|
+
<div key={name} className="stat-row">
|
|
588
|
+
<span className="stat-row-label">
|
|
589
|
+
<span className="stat-colour-dot" style={{ background: colour }} />
|
|
590
|
+
{tmpl?.ui?.displayName ?? name}
|
|
591
|
+
</span>
|
|
592
|
+
<span className="stat-row-value">{count}</span>
|
|
593
|
+
</div>
|
|
594
|
+
);
|
|
595
|
+
})}
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
<div className="dashboard-panel">
|
|
600
|
+
<div className="card-head">State Distribution</div>
|
|
601
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
602
|
+
{nodesByState.map(([state, count]) => (
|
|
603
|
+
<div key={state} className="stat-row">
|
|
604
|
+
<span className="stat-row-label"><StateTag state={state} /></span>
|
|
605
|
+
<span className="stat-row-value">{count}</span>
|
|
606
|
+
</div>
|
|
607
|
+
))}
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
|
|
611
|
+
<div className="dashboard-panel">
|
|
612
|
+
<div className="card-head">Edge Types</div>
|
|
613
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
614
|
+
{stats === null && <div className="label-sm">Loading…</div>}
|
|
615
|
+
{stats !== null && edgeRows.length === 0 && <div className="label-sm">No semantic edges.</div>}
|
|
616
|
+
{edgeRows.map(([type, count]) => (
|
|
617
|
+
<div key={type} className="stat-row">
|
|
618
|
+
<span className="stat-row-label">
|
|
619
|
+
<span className="tag" style={EDGE_TYPE_STYLES[type] ?? {}}>{type}</span>
|
|
620
|
+
</span>
|
|
621
|
+
<span className="stat-row-value">{count}</span>
|
|
622
|
+
</div>
|
|
623
|
+
))}
|
|
624
|
+
</div>
|
|
625
|
+
</div>
|
|
626
|
+
|
|
627
|
+
<div className="dashboard-panel">
|
|
628
|
+
<div className="card-head">Stability</div>
|
|
629
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
630
|
+
{nodesByStability.map(([stability, count]) => (
|
|
631
|
+
<div key={stability} className="stat-row">
|
|
632
|
+
<span className="stat-row-label"><StabilityTag stability={stability} /></span>
|
|
633
|
+
<span className="stat-row-value">{count}</span>
|
|
634
|
+
</div>
|
|
635
|
+
))}
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
|
|
639
|
+
<div className="dashboard-panel">
|
|
640
|
+
<div className="card-head">Diagnostics</div>
|
|
641
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
642
|
+
{stats === null && <div className="label-sm">Loading…</div>}
|
|
643
|
+
{stats !== null && stats.diagnosticCount > 0 && (
|
|
644
|
+
<span style={{ color: 'var(--warn)' }}>
|
|
645
|
+
{stats.diagnosticCount} load warning{stats.diagnosticCount !== 1 ? 's' : ''}
|
|
646
|
+
</span>
|
|
647
|
+
)}
|
|
648
|
+
{stats !== null && stats.diagnosticCount === 0 && (
|
|
649
|
+
<span style={{ color: 'var(--ok)' }}>No issues</span>
|
|
650
|
+
)}
|
|
651
|
+
</div>
|
|
652
|
+
</div>
|
|
653
|
+
|
|
654
|
+
{gitMode && (
|
|
655
|
+
<div className="dashboard-panel">
|
|
656
|
+
<div className="card-head">Branch Health</div>
|
|
657
|
+
<div className="card-body" style={{ padding: '12px 16px' }}>
|
|
658
|
+
{branchResults.map(result => (
|
|
659
|
+
<div key={result.ref} className="stat-row">
|
|
660
|
+
<span className="stat-row-label">
|
|
661
|
+
<Icon
|
|
662
|
+
name={result.status === 'loaded' ? 'circle-check' : 'circle-xmark'}
|
|
663
|
+
size={12}
|
|
664
|
+
/>
|
|
665
|
+
<span>{result.ref}</span>
|
|
666
|
+
</span>
|
|
667
|
+
{result.status === 'failed' && (
|
|
668
|
+
<span className="label-sm" style={{ color: 'var(--warn)', maxWidth: 200, textAlign: 'right' }}>
|
|
669
|
+
{result.diagnostics?.[0]?.message ?? result.error ?? 'failed'}
|
|
670
|
+
</span>
|
|
671
|
+
)}
|
|
672
|
+
</div>
|
|
673
|
+
))}
|
|
674
|
+
</div>
|
|
675
|
+
</div>
|
|
676
|
+
)}
|
|
677
|
+
</div>
|
|
678
|
+
</div>
|
|
679
|
+
);
|
|
499
680
|
}
|
|
500
681
|
|
|
501
682
|
function ComponentsPage() {
|
|
@@ -900,7 +1081,16 @@ function App() {
|
|
|
900
1081
|
} else if (error) {
|
|
901
1082
|
page = <div className="content"><p style={{ color: 'var(--warn)' }}>Error loading graph: {error}</p></div>;
|
|
902
1083
|
} else if (route.pathname === '/dashboard' || route.pathname === '/') {
|
|
903
|
-
page =
|
|
1084
|
+
page = (
|
|
1085
|
+
<DashboardPage
|
|
1086
|
+
nodes={nodes}
|
|
1087
|
+
templates={templates}
|
|
1088
|
+
gitMode={gitMode}
|
|
1089
|
+
viewingRef={viewingRef}
|
|
1090
|
+
branches={branches}
|
|
1091
|
+
branchResults={branchResults}
|
|
1092
|
+
/>
|
|
1093
|
+
);
|
|
904
1094
|
} else if (route.pathname === '/components') {
|
|
905
1095
|
page = <ComponentsPage />;
|
|
906
1096
|
} else if (route.pathname === '/node') {
|
package/web/style.css
CHANGED
|
@@ -1454,3 +1454,112 @@ button {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
|
|
1456
1456
|
.graph-nav-link:hover { color: var(--ink-2); }
|
|
1457
|
+
|
|
1458
|
+
/* ── Dashboard ────────────────────────────────────── */
|
|
1459
|
+
|
|
1460
|
+
.dashboard-hero {
|
|
1461
|
+
display: flex;
|
|
1462
|
+
gap: 16px;
|
|
1463
|
+
margin-bottom: 24px;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
.hero-card {
|
|
1467
|
+
flex: 1;
|
|
1468
|
+
background: var(--paper-2);
|
|
1469
|
+
border: 1px solid var(--rule);
|
|
1470
|
+
border-radius: var(--radius);
|
|
1471
|
+
padding: 20px 24px;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
.hero-number {
|
|
1475
|
+
font-size: 32px;
|
|
1476
|
+
font-weight: 700;
|
|
1477
|
+
line-height: 1;
|
|
1478
|
+
color: var(--ink);
|
|
1479
|
+
margin-bottom: 6px;
|
|
1480
|
+
font-family: 'Space Grotesk', system-ui, sans-serif;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
.hero-label {
|
|
1484
|
+
font-size: 11px;
|
|
1485
|
+
font-weight: 600;
|
|
1486
|
+
text-transform: uppercase;
|
|
1487
|
+
letter-spacing: 0.1em;
|
|
1488
|
+
color: var(--ink-3);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
.branch-diff-callout {
|
|
1492
|
+
display: flex;
|
|
1493
|
+
align-items: center;
|
|
1494
|
+
gap: 12px;
|
|
1495
|
+
padding: 10px 16px;
|
|
1496
|
+
background: var(--paper-2);
|
|
1497
|
+
border: 1px solid var(--rule);
|
|
1498
|
+
border-radius: var(--radius);
|
|
1499
|
+
margin-bottom: 24px;
|
|
1500
|
+
font-size: 12px;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
.branch-diff-branch {
|
|
1504
|
+
font-family: 'JetBrains Mono', ui-monospace, monospace;
|
|
1505
|
+
font-size: 11px;
|
|
1506
|
+
color: var(--ink-2);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
.branch-diff-label {
|
|
1510
|
+
color: var(--ink-3);
|
|
1511
|
+
font-size: 11px;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
.branch-diff-added {
|
|
1515
|
+
color: var(--ok);
|
|
1516
|
+
font-weight: 600;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
.branch-diff-removed {
|
|
1520
|
+
color: var(--warn);
|
|
1521
|
+
font-weight: 600;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
.dashboard-grid {
|
|
1525
|
+
display: grid;
|
|
1526
|
+
grid-template-columns: 1fr 1fr;
|
|
1527
|
+
gap: 16px;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
.dashboard-panel {
|
|
1531
|
+
overflow: hidden;
|
|
1532
|
+
border: 1px solid var(--rule-2);
|
|
1533
|
+
border-radius: 8px;
|
|
1534
|
+
background: var(--paper);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
.stat-row {
|
|
1538
|
+
display: flex;
|
|
1539
|
+
align-items: center;
|
|
1540
|
+
justify-content: space-between;
|
|
1541
|
+
gap: 8px;
|
|
1542
|
+
padding: 4px 0;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
.stat-row-label {
|
|
1546
|
+
display: flex;
|
|
1547
|
+
align-items: center;
|
|
1548
|
+
gap: 8px;
|
|
1549
|
+
color: var(--ink-2);
|
|
1550
|
+
font-size: 12px;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
.stat-row-value {
|
|
1554
|
+
font-weight: 600;
|
|
1555
|
+
font-size: 13px;
|
|
1556
|
+
color: var(--ink);
|
|
1557
|
+
flex-shrink: 0;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
.stat-colour-dot {
|
|
1561
|
+
width: 8px;
|
|
1562
|
+
height: 8px;
|
|
1563
|
+
border-radius: 50%;
|
|
1564
|
+
flex-shrink: 0;
|
|
1565
|
+
}
|