@atolis-hq/corum 0.1.26 → 0.1.27

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.
@@ -343,6 +343,47 @@ export function createApp(graph, reloadEvents = createReloadEvents(), source, mu
343
343
  });
344
344
  res.json(nodes);
345
345
  });
346
+ const GRAPH_EXCLUDED_TEMPLATES = new Set([
347
+ 'Schema', 'EnumDefinition', 'Field', 'EnumValue', 'Mapping',
348
+ ]);
349
+ const GRAPH_SEMANTIC_EDGE_TYPES = new Set([
350
+ 'triggers', 'produces', 'reads', 'calls', 'implements', 'maps-to', 'derived-from',
351
+ ]);
352
+ app.get('/api/graph', async (req, res) => {
353
+ try {
354
+ let targetGraph = graph;
355
+ if (typeof req.query.ref === 'string' && multiCache) {
356
+ targetGraph = await getGraphForRef(req.query.ref, multiCache, graph);
357
+ }
358
+ const nodes = [];
359
+ for (const node of targetGraph.nodesById.values()) {
360
+ if (GRAPH_EXCLUDED_TEMPLATES.has(node.template))
361
+ continue;
362
+ nodes.push({
363
+ id: node.id,
364
+ template: node.template,
365
+ component: node.component,
366
+ state: node.state,
367
+ stability: node.stability,
368
+ });
369
+ }
370
+ const nodeIds = new Set(nodes.map(n => n.id));
371
+ const edges = [];
372
+ for (const edgeList of targetGraph.edgesByFrom.values()) {
373
+ for (const edge of edgeList) {
374
+ if (!GRAPH_SEMANTIC_EDGE_TYPES.has(edge.type))
375
+ continue;
376
+ if (!nodeIds.has(edge.from) || !nodeIds.has(edge.to))
377
+ continue;
378
+ edges.push({ id: edge.id, from: edge.from, to: edge.to, type: edge.type });
379
+ }
380
+ }
381
+ res.json({ nodes, edges });
382
+ }
383
+ catch (err) {
384
+ res.status(500).json({ error: String(err) });
385
+ }
386
+ });
346
387
  app.get('/api/cluster', async (req, res) => {
347
388
  const nodeId = typeof req.query.nodeId === 'string' ? req.query.nodeId : undefined;
348
389
  if (!nodeId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
package/web/app.jsx CHANGED
@@ -92,6 +92,7 @@ function NavRail({ activeSection, onSection, debugMode, onDebugMode }) {
92
92
  const items = [
93
93
  { id: 'dashboard', icon: 'grip', label: 'Dashboard' },
94
94
  { id: 'components', icon: 'circle-nodes', label: 'Models' },
95
+ { id: 'graph', icon: 'diagram-project', label: 'Graph' },
95
96
  ];
96
97
 
97
98
  return (
@@ -501,7 +502,7 @@ function ComponentsPage() {
501
502
  return <div className="content"><h1>Components</h1></div>;
502
503
  }
503
504
 
504
- function EdgePanel({ inbound, outbound, allNodes, templates, onNavigate }) {
505
+ function EdgePanel({ inbound, outbound, allNodes, templates, onNavigate, viewingRef }) {
505
506
  const { useState: useLocalState } = React;
506
507
  const [open, setOpen] = useLocalState(() => {
507
508
  try { return localStorage.getItem('corum:edgePanelOpen') === 'true'; } catch { return false; }
@@ -536,6 +537,14 @@ function EdgePanel({ inbound, outbound, allNodes, templates, onNavigate }) {
536
537
  <span style={{ fontWeight: 500, fontSize: 13 }}>{name}</span>
537
538
  {node && <StateTag state={node.state} />}
538
539
  {node && <StabilityTag stability={node.stability} />}
540
+ <button
541
+ className="graph-nav-link"
542
+ title="View in graph"
543
+ onClick={e => { e.stopPropagation(); navigate(buildRoute({ pathname: '/graph', params: { focus: linkedNodeId }, branch: viewingRef })); }}
544
+ style={{ marginLeft: 'auto' }}
545
+ >
546
+ <Icon name="diagram-project" size={11} />
547
+ </button>
539
548
  </div>
540
549
  );
541
550
  }
@@ -638,6 +647,14 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
638
647
  <TemplateBadge name={templateDisplayName(template)} colour={colour} />
639
648
  <StateTag state={root.state} />
640
649
  <StabilityTag stability={root.stability} />
650
+ <button
651
+ className="graph-nav-link"
652
+ onClick={() => navigate(buildRoute({ pathname: '/graph', params: { focus: root.id }, branch: viewingRef }))}
653
+ title="View in graph"
654
+ >
655
+ <Icon name="diagram-project" size={11} />
656
+ <span>Graph</span>
657
+ </button>
641
658
  </div>
642
659
  <div className="label-sm mono">{root.id}</div>
643
660
  </div>
@@ -648,6 +665,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
648
665
  allNodes={[root, ...descendants, ...includedNodes]}
649
666
  templates={templates}
650
667
  onNavigate={onNavigate}
668
+ viewingRef={viewingRef}
651
669
  />
652
670
 
653
671
  <div className="meta-strip">
@@ -844,7 +862,7 @@ function App() {
844
862
  const activeNodeId = route.pathname === '/node' ? route.params.get('id') : null;
845
863
  const activeSection = activeNodeId ? 'components' : (route.pathname.slice(1) || 'dashboard');
846
864
  const navTree = useMemo(() => buildNavTree(nodes, templates), [nodes, templates]);
847
- const showTree = activeSection === 'components' || activeNodeId;
865
+ const showTree = (activeSection === 'components' || activeNodeId) && activeSection !== 'graph';
848
866
  const activeOverlayRefs = useMemo(() =>
849
867
  overlayMode === 'single' ? [] :
850
868
  overlayMode === 'consolidated' ? branches.filter(branch => branch.ref !== viewingRef).map(branch => branch.ref) :
@@ -897,6 +915,14 @@ function App() {
897
915
  compact={!debugMode}
898
916
  />
899
917
  );
918
+ } else if (route.pathname === '/graph') {
919
+ page = (
920
+ <window.CorumGraph.GraphView
921
+ route={route}
922
+ viewingRef={viewingRef}
923
+ templates={templates}
924
+ />
925
+ );
900
926
  } else {
901
927
  page = <div className="content"><p className="label-sm">Page not found.</p></div>;
902
928
  }
@@ -0,0 +1,74 @@
1
+ /* Pure graph utility functions — browser globals + Node require() compatible. */
2
+
3
+ function getDisplayName(nodeId) {
4
+ return nodeId.split('.').pop();
5
+ }
6
+
7
+ function buildComponentMap(nodes, edges) {
8
+ const componentCounts = new Map();
9
+ for (const node of nodes) {
10
+ componentCounts.set(node.component, (componentCounts.get(node.component) ?? 0) + 1);
11
+ }
12
+
13
+ const componentNodes = [...componentCounts.entries()].map(([component, count]) => ({
14
+ id: component,
15
+ component,
16
+ count,
17
+ }));
18
+
19
+ const nodeById = new Map(nodes.map(n => [n.id, n]));
20
+ const compEdgeMap = new Map();
21
+ for (const edge of edges) {
22
+ const fromNode = nodeById.get(edge.from);
23
+ const toNode = nodeById.get(edge.to);
24
+ if (!fromNode || !toNode) continue;
25
+ if (fromNode.component === toNode.component) continue;
26
+ const key = `${fromNode.component}__${toNode.component}`;
27
+ if (!compEdgeMap.has(key)) compEdgeMap.set(key, { from: fromNode.component, to: toNode.component, types: new Set() });
28
+ compEdgeMap.get(key).types.add(edge.type);
29
+ }
30
+
31
+ const componentEdges = [...compEdgeMap.entries()].map(([key, entry]) => ({
32
+ id: key,
33
+ from: entry.from,
34
+ to: entry.to,
35
+ types: [...entry.types],
36
+ }));
37
+
38
+ return { nodes: componentNodes, edges: componentEdges };
39
+ }
40
+
41
+ function buildFocusGraph(focalNodeId, nodes, edges, depth) {
42
+ const nodeById = new Map(nodes.map(n => [n.id, n]));
43
+ const visited = new Set([focalNodeId]);
44
+ const queue = [{ id: focalNodeId, d: 0 }];
45
+
46
+ while (queue.length > 0) {
47
+ const { id, d } = queue.shift();
48
+ if (d >= depth) continue;
49
+ for (const edge of edges) {
50
+ let neighborId = null;
51
+ if (edge.from === id) neighborId = edge.to;
52
+ else if (edge.to === id) neighborId = edge.from;
53
+ if (!neighborId || visited.has(neighborId) || !nodeById.has(neighborId)) continue;
54
+ visited.add(neighborId);
55
+ queue.push({ id: neighborId, d: d + 1 });
56
+ }
57
+ }
58
+
59
+ return {
60
+ nodes: [...visited].map(id => nodeById.get(id)).filter(Boolean),
61
+ edges: edges.filter(e => visited.has(e.from) && visited.has(e.to)),
62
+ };
63
+ }
64
+
65
+ function applyEdgeTypeFilter(edges, visibleTypes) {
66
+ return edges.filter(e => visibleTypes.has(e.type));
67
+ }
68
+
69
+ if (typeof module !== 'undefined' && module.exports) {
70
+ module.exports = { buildComponentMap, buildFocusGraph, applyEdgeTypeFilter, getDisplayName };
71
+ }
72
+ if (typeof window !== 'undefined') {
73
+ window.CorumGraphUtils = { buildComponentMap, buildFocusGraph, applyEdgeTypeFilter, getDisplayName };
74
+ }
@@ -0,0 +1,63 @@
1
+ // run with: node web/graph-utils.test.js
2
+ const { buildComponentMap, buildFocusGraph, applyEdgeTypeFilter, getDisplayName } = require('./graph-utils.js');
3
+
4
+ (async () => {
5
+
6
+ let passed = 0, failed = 0;
7
+ function assert(condition, name) {
8
+ if (condition) { console.log(` ✓ ${name}`); passed++; }
9
+ else { console.error(` ✗ ${name}`); failed++; }
10
+ }
11
+
12
+ const nodes = [
13
+ { id: 'orders.DomainModel.order', template: 'DomainModel', component: 'orders', state: 'agreed', stability: 'stable' },
14
+ { id: 'orders.RestAPI.ordersApi', template: 'RestAPI', component: 'orders', state: 'agreed', stability: 'stable' },
15
+ { id: 'payments.DomainModel.payment', template: 'DomainModel', component: 'payments', state: 'proposed', stability: 'unstable' },
16
+ { id: 'payments.RestAPI.paymentsApi', template: 'RestAPI', component: 'payments', state: 'proposed', stability: 'unstable' },
17
+ ];
18
+
19
+ const edges = [
20
+ { id: 'e1', from: 'orders.RestAPI.ordersApi', to: 'orders.DomainModel.order', type: 'reads' },
21
+ { id: 'e2', from: 'orders.RestAPI.ordersApi', to: 'payments.RestAPI.paymentsApi', type: 'calls' },
22
+ { id: 'e3', from: 'payments.RestAPI.paymentsApi', to: 'payments.DomainModel.payment', type: 'reads' },
23
+ ];
24
+
25
+ // getDisplayName
26
+ assert(getDisplayName('orders.DomainModel.order') === 'order', 'getDisplayName returns last segment');
27
+ assert(getDisplayName('payments.RestAPI.paymentsApi') === 'paymentsApi', 'getDisplayName handles nested id');
28
+
29
+ // buildComponentMap
30
+ const cm = buildComponentMap(nodes, edges);
31
+ assert(cm.nodes.length === 2, 'buildComponentMap: one node per component');
32
+ assert(cm.nodes.every(n => typeof n.count === 'number' && n.count > 0), 'buildComponentMap: nodes have count');
33
+ const cmOrders = cm.nodes.find(n => n.id === 'orders');
34
+ assert(cmOrders?.count === 2, 'buildComponentMap: orders has 2 nodes');
35
+ assert(cm.edges.length === 1, 'buildComponentMap: one cross-component edge');
36
+ assert(cm.edges[0].from === 'orders' && cm.edges[0].to === 'payments', 'buildComponentMap: edge direction correct');
37
+ assert(cm.edges[0].types.includes('calls'), 'buildComponentMap: edge types collected');
38
+ const sameCmEdges = buildComponentMap(nodes, [{ id: 'x', from: 'orders.DomainModel.order', to: 'orders.RestAPI.ordersApi', type: 'reads' }]);
39
+ assert(sameCmEdges.edges.length === 0, 'buildComponentMap: intra-component edges excluded');
40
+
41
+ // buildFocusGraph - depth 1
42
+ const focus1 = buildFocusGraph('orders.RestAPI.ordersApi', nodes, edges, 1);
43
+ assert(focus1.nodes.some(n => n.id === 'orders.RestAPI.ordersApi'), 'buildFocusGraph depth=1: includes focal node');
44
+ assert(focus1.nodes.some(n => n.id === 'orders.DomainModel.order'), 'buildFocusGraph depth=1: includes 1-hop neighbour (via reads)');
45
+ assert(focus1.nodes.some(n => n.id === 'payments.RestAPI.paymentsApi'), 'buildFocusGraph depth=1: includes 1-hop neighbour (via calls)');
46
+ assert(!focus1.nodes.some(n => n.id === 'payments.DomainModel.payment'), 'buildFocusGraph depth=1: excludes 2-hop neighbour');
47
+ assert(focus1.edges.length === 2, 'buildFocusGraph depth=1: includes only edges within visible nodes');
48
+
49
+ // buildFocusGraph - depth Infinity
50
+ const focusAll = buildFocusGraph('orders.RestAPI.ordersApi', nodes, edges, Infinity);
51
+ assert(focusAll.nodes.length === 4, 'buildFocusGraph depth=Infinity: includes all reachable nodes');
52
+ assert(focusAll.edges.length === 3, 'buildFocusGraph depth=Infinity: includes all reachable edges');
53
+
54
+ // applyEdgeTypeFilter
55
+ const filtered = applyEdgeTypeFilter(edges, new Set(['reads']));
56
+ assert(filtered.length === 2, 'applyEdgeTypeFilter: keeps only matching type');
57
+ assert(filtered.every(e => e.type === 'reads'), 'applyEdgeTypeFilter: all results have correct type');
58
+ const none = applyEdgeTypeFilter(edges, new Set([]));
59
+ assert(none.length === 0, 'applyEdgeTypeFilter: empty set returns nothing');
60
+
61
+ console.log(`\n${passed} passed, ${failed} failed`);
62
+ if (failed > 0) process.exit(1);
63
+ })();
package/web/graph.jsx ADDED
@@ -0,0 +1,441 @@
1
+ /* Graph view: interactive three-level canvas using React Flow + Dagre. */
2
+
3
+ const { useState, useEffect, useMemo, useCallback, useRef } = React;
4
+ const { navigate, Icon, TemplateBadge, StateTag, StabilityTag } = window.CorumPrimitives;
5
+ const { buildRoute, parseRoute } = window.CorumRouter;
6
+ const { buildComponentMap, buildFocusGraph, applyEdgeTypeFilter, getDisplayName } = window.CorumGraphUtils;
7
+
8
+ const RF = window.ReactFlow;
9
+ const ReactFlowCanvas = RF.ReactFlow || RF.default;
10
+ const { MiniMap, Background, useNodesState, useEdgesState, MarkerType, ReactFlowProvider } = RF;
11
+
12
+ const EDGE_STYLES = {
13
+ 'triggers': { stroke: '#b45309', strokeWidth: 1.5 },
14
+ 'produces': { stroke: '#0f766e', strokeWidth: 1.5 },
15
+ 'calls': { stroke: '#6d28d9', strokeWidth: 1.5 },
16
+ 'implements': { stroke: '#475569', strokeWidth: 1.5 },
17
+ 'reads': { stroke: '#1d4ed8', strokeWidth: 1.5 },
18
+ 'maps-to': { stroke: '#be185d', strokeWidth: 1.5 },
19
+ 'derived-from': { stroke: '#6b7280', strokeWidth: 1.5, strokeDasharray: '5,5' },
20
+ };
21
+
22
+ const EDGE_PILL_STYLES = {
23
+ 'triggers': { background: '#fef3c7', color: '#b45309' },
24
+ 'produces': { background: '#ccfbf1', color: '#0f766e' },
25
+ 'calls': { background: '#ede9fe', color: '#6d28d9' },
26
+ 'implements': { background: '#f1f5f9', color: '#475569' },
27
+ 'reads': { background: '#dbeafe', color: '#1d4ed8' },
28
+ 'maps-to': { background: '#fce7f3', color: '#be185d' },
29
+ 'derived-from': { background: '#f3f4f6', color: '#6b7280' },
30
+ };
31
+
32
+ const ALL_EDGE_TYPES = ['triggers', 'produces', 'reads', 'calls', 'implements', 'maps-to', 'derived-from'];
33
+
34
+ const NODE_W = 210;
35
+ const NODE_H = 88;
36
+ const COMP_W = 180;
37
+ const COMP_H = 72;
38
+
39
+ function loadVisibleEdgeTypes() {
40
+ try {
41
+ const stored = localStorage.getItem('corum:graphEdgeTypes');
42
+ if (stored) return new Set(JSON.parse(stored));
43
+ } catch {}
44
+ return new Set(ALL_EDGE_TYPES);
45
+ }
46
+
47
+ function saveVisibleEdgeTypes(types) {
48
+ try { localStorage.setItem('corum:graphEdgeTypes', JSON.stringify([...types])); } catch {}
49
+ }
50
+
51
+ function computeLayout(rfNodes, rfEdges, nodeW, nodeH) {
52
+ if (!rfNodes.length) return rfNodes;
53
+ const g = new dagre.graphlib.Graph();
54
+ g.setDefaultEdgeLabel(() => ({}));
55
+ g.setGraph({ rankdir: 'LR', nodesep: 50, ranksep: 80 });
56
+ rfNodes.forEach(n => g.setNode(n.id, { width: nodeW, height: nodeH }));
57
+ rfEdges.forEach(e => g.setEdge(e.source, e.target));
58
+ dagre.layout(g);
59
+ return rfNodes.map(n => {
60
+ const pos = g.node(n.id);
61
+ return { ...n, position: { x: pos.x - nodeW / 2, y: pos.y - nodeH / 2 } };
62
+ });
63
+ }
64
+
65
+ function makeRFEdge(edge, edgeStyles) {
66
+ const style = edgeStyles[edge.type] || { stroke: '#a8acb5', strokeWidth: 1.5 };
67
+ return {
68
+ id: edge.id,
69
+ source: edge.from,
70
+ target: edge.to,
71
+ label: edge.type,
72
+ labelStyle: { fontSize: 10, fill: style.stroke },
73
+ labelBgStyle: { fill: 'var(--paper)', fillOpacity: 0.85 },
74
+ style: { stroke: style.stroke, strokeWidth: style.strokeWidth, strokeDasharray: style.strokeDasharray },
75
+ markerEnd: { type: MarkerType.ArrowClosed, color: style.stroke, width: 14, height: 14 },
76
+ type: 'default',
77
+ };
78
+ }
79
+
80
+ function buildRFNodesForNodes(graphNodes, templateMap, onNodeClick, viewingRef) {
81
+ return graphNodes.map(n => {
82
+ const tmpl = templateMap.get(n.template);
83
+ const colour = tmpl?.ui?.colour ?? 'var(--ink-4)';
84
+ return {
85
+ id: n.id,
86
+ type: 'nodeCard',
87
+ position: { x: 0, y: 0 },
88
+ data: {
89
+ nodeId: n.id,
90
+ label: getDisplayName(n.id),
91
+ component: n.component,
92
+ templateLabel: tmpl?.ui?.displayName ?? n.template,
93
+ colour,
94
+ state: n.state,
95
+ stability: n.stability,
96
+ onClick: () => onNodeClick(n.id),
97
+ viewingRef,
98
+ },
99
+ };
100
+ });
101
+ }
102
+
103
+ function buildRFEdgesForEdges(edges, visibleEdgeTypes) {
104
+ return applyEdgeTypeFilter(edges, visibleEdgeTypes).map(e => makeRFEdge(e, EDGE_STYLES));
105
+ }
106
+
107
+ // Level 1: component card node
108
+ function ComponentCardNode({ data }) {
109
+ return (
110
+ <div className="graph-component-card" onClick={data.onClick}>
111
+ <RF.Handle type="target" position={RF.Position.Left} style={{ opacity: 0 }} />
112
+ <div className="graph-component-card-name">{data.label}</div>
113
+ <div className="graph-component-card-count">{data.count} {data.count === 1 ? 'node' : 'nodes'}</div>
114
+ <RF.Handle type="source" position={RF.Position.Right} style={{ opacity: 0 }} />
115
+ </div>
116
+ );
117
+ }
118
+
119
+ // Level 2/3: node card node
120
+ function NodeCardNode({ data }) {
121
+ const colour = data.colour ?? 'var(--ink-4)';
122
+ return (
123
+ <div className="graph-node-card" onClick={data.onClick}>
124
+ <RF.Handle type="target" position={RF.Position.Left} style={{ opacity: 0 }} />
125
+ <div className="graph-node-card-bar" style={{ background: colour }} />
126
+ <div className="graph-node-card-header">
127
+ <TemplateBadge name={data.templateLabel} colour={colour} />
128
+ <StateTag state={data.state} />
129
+ </div>
130
+ <div className="graph-node-card-body">
131
+ <div className="graph-node-card-name" title={data.nodeId}>{data.label}</div>
132
+ <div className="graph-node-card-component">{data.component}</div>
133
+ </div>
134
+ <div className="graph-node-card-footer">
135
+ <StabilityTag stability={data.stability} />
136
+ <button
137
+ className="graph-node-card-link"
138
+ title="View node details"
139
+ onClick={e => { e.stopPropagation(); navigate(buildRoute({ pathname: '/node', params: { id: data.nodeId }, branch: data.viewingRef })); }}
140
+ >
141
+ <Icon name="arrow-up-right-from-square" size={11} />
142
+ </button>
143
+ </div>
144
+ <RF.Handle type="source" position={RF.Position.Right} style={{ opacity: 0 }} />
145
+ </div>
146
+ );
147
+ }
148
+
149
+ const nodeTypes = { componentCard: ComponentCardNode, nodeCard: NodeCardNode };
150
+
151
+ function GraphBreadcrumb({ level, selectedComponent, focalNodeId, onNavigateToRoot, onNavigateToComponent }) {
152
+ return (
153
+ <div className="graph-breadcrumb">
154
+ <button className="graph-breadcrumb-item" onClick={onNavigateToRoot}>Graph</button>
155
+ {(level === 'interior' || level === 'focus') && selectedComponent && (
156
+ <>
157
+ <span className="graph-breadcrumb-sep">/</span>
158
+ {level === 'interior'
159
+ ? <span className="graph-breadcrumb-current">{selectedComponent}</span>
160
+ : <button className="graph-breadcrumb-item" onClick={() => onNavigateToComponent(selectedComponent)}>{selectedComponent}</button>
161
+ }
162
+ </>
163
+ )}
164
+ {level === 'focus' && focalNodeId && (
165
+ <>
166
+ <span className="graph-breadcrumb-sep">/</span>
167
+ <span className="graph-breadcrumb-current">{getDisplayName(focalNodeId)}</span>
168
+ </>
169
+ )}
170
+ </div>
171
+ );
172
+ }
173
+
174
+ function GraphToolbar({ visibleEdgeTypes, onToggleEdgeType, showMinimap, onToggleMinimap, onResetLayout, level, depth, onDepth, allNodes, focalNodeId, onFocalNode }) {
175
+ const [searchQuery, setSearchQuery] = useState('');
176
+ const [searchOpen, setSearchOpen] = useState(false);
177
+ const searchRef = useRef(null);
178
+
179
+ const searchResults = useMemo(() => {
180
+ if (!searchQuery.trim()) return [];
181
+ const q = searchQuery.toLowerCase();
182
+ return allNodes
183
+ .filter(n => n.id.toLowerCase().includes(q))
184
+ .slice(0, 8);
185
+ }, [searchQuery, allNodes]);
186
+
187
+ useEffect(() => {
188
+ if (!searchOpen) return;
189
+ function handleClick(e) {
190
+ if (searchRef.current && !searchRef.current.contains(e.target)) setSearchOpen(false);
191
+ }
192
+ document.addEventListener('mousedown', handleClick);
193
+ return () => document.removeEventListener('mousedown', handleClick);
194
+ }, [searchOpen]);
195
+
196
+ return (
197
+ <div className="graph-toolbar">
198
+ {ALL_EDGE_TYPES.map(type => {
199
+ const active = visibleEdgeTypes.has(type);
200
+ const pill = EDGE_PILL_STYLES[type] || {};
201
+ return (
202
+ <span
203
+ key={type}
204
+ className={`graph-edge-pill${active ? '' : ' inactive'}`}
205
+ style={active ? pill : {}}
206
+ onClick={() => onToggleEdgeType(type)}
207
+ >
208
+ {type}
209
+ </span>
210
+ );
211
+ })}
212
+ <div className="graph-toolbar-sep" />
213
+ {level === 'focus' && (
214
+ <>
215
+ <div className="graph-depth-seg">
216
+ {[['1', 1], ['2', 2], ['∞', Infinity]].map(([label, val]) => (
217
+ <button
218
+ key={label}
219
+ className={`graph-depth-item${depth === val ? ' active' : ''}`}
220
+ onClick={() => onDepth(val)}
221
+ >
222
+ {label}
223
+ </button>
224
+ ))}
225
+ </div>
226
+ <div className="graph-focus-search" ref={searchRef}>
227
+ <input
228
+ className="graph-focus-search-input"
229
+ placeholder="Focus node..."
230
+ value={searchQuery}
231
+ onChange={e => { setSearchQuery(e.target.value); setSearchOpen(true); }}
232
+ onFocus={() => setSearchOpen(true)}
233
+ />
234
+ {searchOpen && searchResults.length > 0 && (
235
+ <div className="graph-focus-search-dropdown">
236
+ {searchResults.map(n => (
237
+ <div
238
+ key={n.id}
239
+ className={`graph-focus-search-item${n.id === focalNodeId ? ' selected' : ''}`}
240
+ onClick={() => { onFocalNode(n.id); setSearchQuery(''); setSearchOpen(false); }}
241
+ >
242
+ <span style={{ fontWeight: 500 }}>{getDisplayName(n.id)}</span>
243
+ <span style={{ color: 'var(--ink-3)', fontSize: 10, marginLeft: 4 }}>{n.component}</span>
244
+ </div>
245
+ ))}
246
+ </div>
247
+ )}
248
+ </div>
249
+ <div className="graph-toolbar-sep" />
250
+ </>
251
+ )}
252
+ <button className="graph-toolbar-btn" onClick={onResetLayout}>Reset layout</button>
253
+ <button className={`graph-toolbar-btn${showMinimap ? ' active' : ''}`} onClick={onToggleMinimap}>Minimap</button>
254
+ </div>
255
+ );
256
+ }
257
+
258
+ function GraphView({ route, viewingRef, templates }) {
259
+ const [graphData, setGraphData] = useState(null);
260
+ const [error, setError] = useState(null);
261
+ const [visibleEdgeTypes, setVisibleEdgeTypes] = useState(loadVisibleEdgeTypes);
262
+ const [showMinimap, setShowMinimap] = useState(false);
263
+ const [depth, setDepth] = useState(1);
264
+ const [layoutKey, setLayoutKey] = useState(0);
265
+ const [rfNodes, setRfNodes, onNodesChange] = useNodesState([]);
266
+ const [rfEdges, setRfEdges, onEdgesChange] = useEdgesState([]);
267
+
268
+ // Derive level and selection from URL
269
+ const selectedComponent = route.params.get('component') ?? null;
270
+ const focalNodeId = route.params.get('focus') ?? null;
271
+ const level = focalNodeId ? 'focus' : selectedComponent ? 'interior' : 'component';
272
+
273
+ const navToRoot = useCallback(() => {
274
+ navigate(buildRoute({ pathname: '/graph', params: {}, branch: viewingRef }));
275
+ }, [viewingRef]);
276
+
277
+ const navToComponent = useCallback(component => {
278
+ navigate(buildRoute({ pathname: '/graph', params: { component }, branch: viewingRef }));
279
+ }, [viewingRef]);
280
+
281
+ const navToFocus = useCallback(nodeId => {
282
+ const params = { focus: nodeId };
283
+ if (selectedComponent) params.component = selectedComponent;
284
+ navigate(buildRoute({ pathname: '/graph', params, branch: viewingRef }));
285
+ }, [viewingRef, selectedComponent]);
286
+
287
+ useEffect(() => {
288
+ setGraphData(null);
289
+ setError(null);
290
+ const refParam = viewingRef ? `?ref=${encodeURIComponent(viewingRef)}` : '';
291
+ fetch(`/api/graph${refParam}`)
292
+ .then(r => r.ok ? r.json() : Promise.reject(r.status))
293
+ .then(setGraphData)
294
+ .catch(err => setError(String(err)));
295
+ }, [viewingRef]);
296
+
297
+ const templateMap = useMemo(() => new Map((templates ?? []).map(t => [t.name, t])), [templates]);
298
+
299
+ const templateColour = useCallback(templateName => {
300
+ return templateMap.get(templateName)?.ui?.colour ?? 'var(--ink-4)';
301
+ }, [templateMap]);
302
+
303
+ // Level 1: component map
304
+ const level1 = useMemo(() => {
305
+ if (!graphData) return null;
306
+ const { nodes: cmNodes, edges: cmEdges } = buildComponentMap(graphData.nodes, graphData.edges);
307
+ const filteredCmEdges = cmEdges.filter(e => e.types.some(t => visibleEdgeTypes.has(t)));
308
+ const rfN = cmNodes.map(n => ({
309
+ id: n.id,
310
+ type: 'componentCard',
311
+ position: { x: 0, y: 0 },
312
+ data: { label: n.component, count: n.count, onClick: () => navToComponent(n.component) },
313
+ }));
314
+ const rfE = filteredCmEdges.map(e => {
315
+ const repType = e.types.find(t => visibleEdgeTypes.has(t)) ?? e.types[0];
316
+ return {
317
+ ...makeRFEdge({ ...e, type: repType }, EDGE_STYLES),
318
+ label: e.types.join(', '),
319
+ };
320
+ });
321
+ return { rfN: computeLayout(rfN, rfE, COMP_W, COMP_H), rfE };
322
+ }, [graphData, visibleEdgeTypes, layoutKey, navToComponent]);
323
+
324
+ useEffect(() => {
325
+ if (level !== 'component' || !level1) return;
326
+ setRfNodes(level1.rfN);
327
+ setRfEdges(level1.rfE);
328
+ }, [level, level1]);
329
+
330
+ // Level 2: component interior
331
+ const level2 = useMemo(() => {
332
+ if (!graphData || !selectedComponent) return null;
333
+ const compNodes = graphData.nodes.filter(n => n.component === selectedComponent);
334
+ const compNodeIds = new Set(compNodes.map(n => n.id));
335
+ const internalEdges = graphData.edges.filter(e => compNodeIds.has(e.from) && compNodeIds.has(e.to));
336
+ const crossEdges = graphData.edges.filter(e =>
337
+ (compNodeIds.has(e.from) && !compNodeIds.has(e.to)) ||
338
+ (!compNodeIds.has(e.from) && compNodeIds.has(e.to))
339
+ );
340
+ const externalNodeIds = new Set([
341
+ ...crossEdges.map(e => e.from).filter(id => !compNodeIds.has(id)),
342
+ ...crossEdges.map(e => e.to).filter(id => !compNodeIds.has(id)),
343
+ ]);
344
+ const externalNodes = graphData.nodes.filter(n => externalNodeIds.has(n.id));
345
+ const allVisibleNodes = [...compNodes, ...externalNodes];
346
+ const allVisibleEdges = [...internalEdges, ...crossEdges];
347
+ const rfN = buildRFNodesForNodes(allVisibleNodes, templateMap, navToFocus, viewingRef);
348
+ const rfE = buildRFEdgesForEdges(allVisibleEdges, visibleEdgeTypes).map(e => {
349
+ const isCross = crossEdges.some(ce => ce.id === e.id);
350
+ return isCross ? { ...e, style: { ...e.style, opacity: 0.45 }, labelStyle: { ...e.labelStyle, opacity: 0.45 } } : e;
351
+ });
352
+ return { rfN: computeLayout(rfN, rfE, NODE_W, NODE_H), rfE };
353
+ }, [graphData, selectedComponent, visibleEdgeTypes, templateMap, layoutKey, navToFocus]);
354
+
355
+ useEffect(() => {
356
+ if (level !== 'interior' || !level2) return;
357
+ setRfNodes(level2.rfN);
358
+ setRfEdges(level2.rfE);
359
+ }, [level, level2]);
360
+
361
+ // Level 3: node focus
362
+ const level3 = useMemo(() => {
363
+ if (!graphData || !focalNodeId) return null;
364
+ const { nodes: focusNodes, edges: focusEdges } = buildFocusGraph(
365
+ focalNodeId, graphData.nodes, graphData.edges, depth
366
+ );
367
+ const rfN = buildRFNodesForNodes(focusNodes, templateMap, nodeId => {
368
+ navigate(buildRoute({ pathname: '/graph', params: { focus: nodeId }, branch: viewingRef }));
369
+ }, viewingRef);
370
+ const rfE = buildRFEdgesForEdges(focusEdges, visibleEdgeTypes);
371
+ const layoutedN = computeLayout(rfN, rfE, NODE_W, NODE_H);
372
+ return {
373
+ rfN: layoutedN.map(n => n.id === focalNodeId
374
+ ? { ...n, style: { outline: '2px solid var(--accent)', outlineOffset: '2px', borderRadius: 'var(--radius)' } }
375
+ : n
376
+ ),
377
+ rfE,
378
+ };
379
+ }, [graphData, focalNodeId, depth, visibleEdgeTypes, templateMap, layoutKey, viewingRef]);
380
+
381
+ useEffect(() => {
382
+ if (level !== 'focus' || !level3) return;
383
+ setRfNodes(level3.rfN);
384
+ setRfEdges(level3.rfE);
385
+ }, [level, level3]);
386
+
387
+ function handleToggleEdgeType(type) {
388
+ setVisibleEdgeTypes(prev => {
389
+ const next = new Set(prev);
390
+ next.has(type) ? next.delete(type) : next.add(type);
391
+ saveVisibleEdgeTypes(next);
392
+ return next;
393
+ });
394
+ }
395
+
396
+ if (!graphData && !error) return <div className="graph-section"><p className="label-sm" style={{ padding: 24 }}>Loading graph...</p></div>;
397
+ if (error) return <div className="graph-section"><p style={{ color: 'var(--warn)', padding: 24 }}>Error loading graph: {error}</p></div>;
398
+
399
+ return (
400
+ <div className="graph-section">
401
+ <GraphBreadcrumb
402
+ level={level}
403
+ selectedComponent={selectedComponent}
404
+ focalNodeId={focalNodeId}
405
+ onNavigateToRoot={navToRoot}
406
+ onNavigateToComponent={navToComponent}
407
+ />
408
+ <GraphToolbar
409
+ visibleEdgeTypes={visibleEdgeTypes}
410
+ onToggleEdgeType={handleToggleEdgeType}
411
+ showMinimap={showMinimap}
412
+ onToggleMinimap={() => setShowMinimap(v => !v)}
413
+ onResetLayout={() => setLayoutKey(k => k + 1)}
414
+ level={level}
415
+ depth={depth}
416
+ onDepth={setDepth}
417
+ allNodes={graphData?.nodes ?? []}
418
+ focalNodeId={focalNodeId}
419
+ onFocalNode={navToFocus}
420
+ />
421
+ <div className="graph-canvas-wrap">
422
+ <ReactFlowProvider>
423
+ <ReactFlowCanvas
424
+ nodes={rfNodes}
425
+ edges={rfEdges}
426
+ onNodesChange={onNodesChange}
427
+ onEdgesChange={onEdgesChange}
428
+ nodeTypes={nodeTypes}
429
+ fitView
430
+ proOptions={{ hideAttribution: true }}
431
+ >
432
+ <Background />
433
+ {showMinimap && <MiniMap />}
434
+ </ReactFlowCanvas>
435
+ </ReactFlowProvider>
436
+ </div>
437
+ </div>
438
+ );
439
+ }
440
+
441
+ window.CorumGraph = { GraphView };
package/web/index.html CHANGED
@@ -10,6 +10,7 @@
10
10
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
11
11
  <link rel="stylesheet" href="style.css" />
12
12
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" />
13
+ <link rel="stylesheet" href="https://unpkg.com/reactflow@11.11.4/dist/style.css" crossorigin="anonymous" />
13
14
  <script>
14
15
  window.CorumPlugins = {};
15
16
  </script>
@@ -19,11 +20,15 @@
19
20
 
20
21
  <script src="https://unpkg.com/react@18.3.1/umd/react.production.min.js" crossorigin="anonymous"></script>
21
22
  <script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js" crossorigin="anonymous"></script>
23
+ <script src="https://unpkg.com/dagre@0.8.5/dist/dagre.min.js" crossorigin="anonymous"></script>
24
+ <script src="https://unpkg.com/reactflow@11.11.4/dist/umd/index.js" crossorigin="anonymous"></script>
22
25
  <script src="https://unpkg.com/@babel/standalone@7.29.0/babel.min.js" crossorigin="anonymous"></script>
23
26
  <script src="nav.js"></script>
24
27
  <script src="router.js"></script>
28
+ <script src="graph-utils.js"></script>
25
29
  <script type="text/babel" src="primitives.jsx"></script>
26
30
  <script type="text/babel" src="search.jsx"></script>
31
+ <script type="text/babel" src="graph.jsx"></script>
27
32
  <script type="text/babel">
28
33
  fetch('/api/plugins')
29
34
  .then(response => response.ok ? response.json() : [])
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
package/web/router.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
- var KNOWN_PATHS = new Set(['/dashboard', '/components', '/node']);
4
+ var KNOWN_PATHS = new Set(['/dashboard', '/components', '/node', '/graph']);
5
5
 
6
6
  function parseRoute(hash) {
7
7
  var raw = (hash || '').replace(/^#/, '') || '/dashboard';
package/web/style.css CHANGED
@@ -981,3 +981,476 @@ button {
981
981
  font-size: 13px;
982
982
  text-align: center;
983
983
  }
984
+
985
+ /* ── Graph Canvas ─────────────────────────────────── */
986
+
987
+ .graph-section {
988
+ display: flex;
989
+ flex-direction: column;
990
+ flex: 1;
991
+ min-width: 0;
992
+ min-height: 0;
993
+ overflow: hidden;
994
+ }
995
+
996
+ .graph-breadcrumb {
997
+ display: flex;
998
+ align-items: center;
999
+ gap: 4px;
1000
+ padding: 8px 16px;
1001
+ border-bottom: 1px solid var(--rule);
1002
+ font-size: 12px;
1003
+ flex-shrink: 0;
1004
+ background: var(--paper-2);
1005
+ }
1006
+
1007
+ .graph-breadcrumb-item {
1008
+ background: none;
1009
+ border: none;
1010
+ color: var(--accent);
1011
+ cursor: pointer;
1012
+ font: inherit;
1013
+ font-size: 12px;
1014
+ padding: 0;
1015
+ }
1016
+
1017
+ .graph-breadcrumb-item:hover { text-decoration: underline; }
1018
+
1019
+ .graph-breadcrumb-sep {
1020
+ color: var(--ink-4);
1021
+ }
1022
+
1023
+ .graph-breadcrumb-current {
1024
+ color: var(--ink);
1025
+ font-weight: 500;
1026
+ }
1027
+
1028
+ .graph-toolbar {
1029
+ display: flex;
1030
+ align-items: center;
1031
+ flex-wrap: wrap;
1032
+ gap: 6px;
1033
+ padding: 8px 16px;
1034
+ border-bottom: 1px solid var(--rule);
1035
+ flex-shrink: 0;
1036
+ background: var(--paper);
1037
+ }
1038
+
1039
+ .graph-edge-pill {
1040
+ display: inline-flex;
1041
+ align-items: center;
1042
+ padding: 2px 8px;
1043
+ border-radius: 999px;
1044
+ font-size: 11px;
1045
+ font-weight: 600;
1046
+ cursor: pointer;
1047
+ user-select: none;
1048
+ border: 1px solid transparent;
1049
+ transition: opacity 0.15s;
1050
+ }
1051
+
1052
+ .graph-edge-pill.inactive {
1053
+ background: var(--paper-3) !important;
1054
+ color: var(--ink-4) !important;
1055
+ opacity: 0.6;
1056
+ }
1057
+
1058
+ .graph-toolbar-sep {
1059
+ width: 1px;
1060
+ height: 20px;
1061
+ background: var(--rule-2);
1062
+ flex-shrink: 0;
1063
+ }
1064
+
1065
+ .graph-toolbar-btn {
1066
+ padding: 3px 10px;
1067
+ border: 1px solid var(--rule-2);
1068
+ border-radius: 4px;
1069
+ background: var(--paper);
1070
+ color: var(--ink-2);
1071
+ cursor: pointer;
1072
+ font: inherit;
1073
+ font-size: 11px;
1074
+ font-weight: 500;
1075
+ }
1076
+
1077
+ .graph-toolbar-btn:hover { background: var(--paper-2); }
1078
+ .graph-toolbar-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
1079
+
1080
+ .graph-depth-seg {
1081
+ display: flex;
1082
+ gap: 1px;
1083
+ background: var(--rule);
1084
+ border-radius: 4px;
1085
+ overflow: hidden;
1086
+ }
1087
+
1088
+ .graph-depth-item {
1089
+ padding: 3px 8px;
1090
+ background: var(--paper);
1091
+ color: var(--ink-2);
1092
+ cursor: pointer;
1093
+ font: inherit;
1094
+ font-size: 11px;
1095
+ border: none;
1096
+ }
1097
+
1098
+ .graph-depth-item.active {
1099
+ background: var(--accent);
1100
+ color: #fff;
1101
+ font-weight: 600;
1102
+ }
1103
+
1104
+ .graph-focus-search {
1105
+ position: relative;
1106
+ }
1107
+
1108
+ .graph-focus-search-input {
1109
+ padding: 4px 10px;
1110
+ border: 1px solid var(--rule-2);
1111
+ border-radius: 4px;
1112
+ background: var(--paper);
1113
+ color: var(--ink);
1114
+ font: inherit;
1115
+ font-size: 11px;
1116
+ outline: none;
1117
+ width: 180px;
1118
+ }
1119
+
1120
+ .graph-focus-search-input:focus { border-color: var(--accent); }
1121
+
1122
+ .graph-focus-search-dropdown {
1123
+ position: absolute;
1124
+ top: calc(100% + 4px);
1125
+ left: 0;
1126
+ z-index: 100;
1127
+ background: var(--paper);
1128
+ border: 1px solid var(--rule-2);
1129
+ border-radius: 6px;
1130
+ box-shadow: 0 4px 16px rgba(0,0,0,0.12);
1131
+ min-width: 280px;
1132
+ overflow: hidden;
1133
+ }
1134
+
1135
+ .graph-focus-search-item {
1136
+ display: flex;
1137
+ align-items: center;
1138
+ gap: 8px;
1139
+ padding: 7px 12px;
1140
+ cursor: pointer;
1141
+ font-size: 12px;
1142
+ }
1143
+
1144
+ .graph-focus-search-item:hover,
1145
+ .graph-focus-search-item.selected {
1146
+ background: var(--paper-2);
1147
+ }
1148
+
1149
+ .graph-canvas-wrap {
1150
+ flex: 1;
1151
+ min-height: 0;
1152
+ position: relative;
1153
+ }
1154
+
1155
+ .graph-component-card {
1156
+ width: 180px;
1157
+ height: 72px;
1158
+ display: flex;
1159
+ flex-direction: column;
1160
+ justify-content: center;
1161
+ padding: 12px 14px;
1162
+ background: var(--paper);
1163
+ border: 1.5px solid var(--rule-2);
1164
+ border-radius: 8px;
1165
+ cursor: pointer;
1166
+ box-shadow: 0 1px 4px rgba(0,0,0,0.06);
1167
+ transition: box-shadow 0.15s, border-color 0.15s;
1168
+ }
1169
+
1170
+ .graph-component-card:hover {
1171
+ border-color: var(--accent);
1172
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
1173
+ }
1174
+
1175
+ .graph-component-card-name {
1176
+ font-size: 13px;
1177
+ font-weight: 600;
1178
+ color: var(--ink);
1179
+ margin-bottom: 3px;
1180
+ }
1181
+
1182
+ /* ── Graph view ── */
1183
+
1184
+ .graph-section {
1185
+ flex: 1;
1186
+ display: flex;
1187
+ flex-direction: column;
1188
+ overflow: hidden;
1189
+ min-height: 0;
1190
+ }
1191
+
1192
+ .graph-breadcrumb {
1193
+ display: flex;
1194
+ align-items: center;
1195
+ gap: 6px;
1196
+ padding: 8px 16px;
1197
+ font-size: 12px;
1198
+ color: var(--ink-3);
1199
+ background: var(--paper);
1200
+ border-bottom: 1px solid var(--rule);
1201
+ flex-shrink: 0;
1202
+ }
1203
+
1204
+ .graph-breadcrumb-item {
1205
+ color: var(--ink-3);
1206
+ cursor: pointer;
1207
+ background: none;
1208
+ border: none;
1209
+ font: inherit;
1210
+ font-size: 12px;
1211
+ padding: 0;
1212
+ }
1213
+
1214
+ .graph-breadcrumb-item:hover { color: var(--ink); }
1215
+
1216
+ .graph-breadcrumb-sep { color: var(--ink-4); }
1217
+
1218
+ .graph-breadcrumb-current { color: var(--ink); font-weight: 600; }
1219
+
1220
+ .graph-toolbar {
1221
+ display: flex;
1222
+ align-items: center;
1223
+ gap: 6px;
1224
+ padding: 8px 16px;
1225
+ background: var(--paper);
1226
+ border-bottom: 1px solid var(--rule);
1227
+ flex-shrink: 0;
1228
+ flex-wrap: wrap;
1229
+ }
1230
+
1231
+ .graph-canvas-wrap {
1232
+ flex: 1;
1233
+ position: relative;
1234
+ min-height: 0;
1235
+ }
1236
+
1237
+ /* Node cards (Levels 2 & 3) */
1238
+ .graph-node-card {
1239
+ background: var(--paper);
1240
+ border: 1.5px solid var(--rule-2);
1241
+ border-radius: var(--radius);
1242
+ width: 210px;
1243
+ font-size: 12px;
1244
+ cursor: pointer;
1245
+ overflow: visible;
1246
+ position: relative;
1247
+ transition: box-shadow 0.12s;
1248
+ }
1249
+
1250
+ .graph-node-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
1251
+
1252
+ .graph-node-card-bar {
1253
+ width: 3px;
1254
+ position: absolute;
1255
+ left: 0;
1256
+ top: 0;
1257
+ bottom: 0;
1258
+ border-radius: var(--radius) 0 0 var(--radius);
1259
+ }
1260
+
1261
+ .graph-node-card-header {
1262
+ display: flex;
1263
+ align-items: center;
1264
+ gap: 5px;
1265
+ padding: 6px 8px 4px 10px;
1266
+ }
1267
+
1268
+ .graph-node-card-body { padding: 2px 8px 4px 10px; }
1269
+
1270
+ .graph-node-card-name {
1271
+ font-weight: 600;
1272
+ font-size: 13px;
1273
+ color: var(--ink);
1274
+ white-space: nowrap;
1275
+ overflow: hidden;
1276
+ text-overflow: ellipsis;
1277
+ max-width: 180px;
1278
+ }
1279
+
1280
+ .graph-node-card-component {
1281
+ font-size: 10px;
1282
+ color: var(--ink-3);
1283
+ margin-top: 1px;
1284
+ white-space: nowrap;
1285
+ overflow: hidden;
1286
+ text-overflow: ellipsis;
1287
+ }
1288
+
1289
+ .graph-node-card-footer {
1290
+ display: flex;
1291
+ align-items: center;
1292
+ justify-content: space-between;
1293
+ padding: 3px 8px 5px 10px;
1294
+ border-top: 1px solid var(--rule);
1295
+ margin-top: 3px;
1296
+ }
1297
+
1298
+ .graph-node-card-link {
1299
+ color: var(--ink-4);
1300
+ cursor: pointer;
1301
+ font-size: 11px;
1302
+ background: none;
1303
+ border: none;
1304
+ padding: 0;
1305
+ line-height: 1;
1306
+ display: flex;
1307
+ align-items: center;
1308
+ }
1309
+
1310
+ .graph-node-card-link:hover { color: var(--ink-2); }
1311
+
1312
+ /* Component cards (Level 1) */
1313
+ .graph-component-card {
1314
+ background: var(--paper);
1315
+ border: 1.5px solid var(--rule-2);
1316
+ border-radius: var(--radius);
1317
+ width: 180px;
1318
+ padding: 14px 16px;
1319
+ cursor: pointer;
1320
+ transition: box-shadow 0.12s, border-color 0.12s;
1321
+ position: relative;
1322
+ }
1323
+
1324
+ .graph-component-card:hover {
1325
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
1326
+ border-color: var(--ink-4);
1327
+ }
1328
+
1329
+ .graph-component-card-name { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 4px; }
1330
+
1331
+ .graph-component-card-count { font-size: 11px; color: var(--ink-3); }
1332
+
1333
+ /* Edge type toggle pills */
1334
+ .graph-edge-pill {
1335
+ display: inline-flex;
1336
+ align-items: center;
1337
+ padding: 3px 9px;
1338
+ border-radius: 999px;
1339
+ font-size: 11px;
1340
+ font-weight: 500;
1341
+ cursor: pointer;
1342
+ border: 1.5px solid transparent;
1343
+ user-select: none;
1344
+ transition: opacity 0.1s;
1345
+ white-space: nowrap;
1346
+ }
1347
+
1348
+ .graph-edge-pill.inactive {
1349
+ background: transparent !important;
1350
+ color: var(--ink-3) !important;
1351
+ border-color: var(--rule-2) !important;
1352
+ }
1353
+
1354
+ .graph-toolbar-sep {
1355
+ width: 1px;
1356
+ height: 20px;
1357
+ background: var(--rule);
1358
+ flex-shrink: 0;
1359
+ }
1360
+
1361
+ /* Depth segmented control */
1362
+ .graph-depth-seg {
1363
+ display: flex;
1364
+ border: 1px solid var(--rule-2);
1365
+ border-radius: var(--radius);
1366
+ overflow: hidden;
1367
+ }
1368
+
1369
+ .graph-depth-item {
1370
+ padding: 3px 10px;
1371
+ font-size: 11px;
1372
+ font-weight: 500;
1373
+ cursor: pointer;
1374
+ background: none;
1375
+ border: none;
1376
+ border-right: 1px solid var(--rule-2);
1377
+ color: var(--ink-3);
1378
+ font: inherit;
1379
+ }
1380
+
1381
+ .graph-depth-item:last-child { border-right: none; }
1382
+ .graph-depth-item.active { background: var(--paper-3); color: var(--ink); }
1383
+
1384
+ /* Toolbar buttons */
1385
+ .graph-toolbar-btn {
1386
+ padding: 3px 10px;
1387
+ font-size: 11px;
1388
+ font-weight: 500;
1389
+ cursor: pointer;
1390
+ background: none;
1391
+ border: 1px solid var(--rule-2);
1392
+ border-radius: var(--radius);
1393
+ color: var(--ink-3);
1394
+ font: inherit;
1395
+ }
1396
+
1397
+ .graph-toolbar-btn:hover { color: var(--ink); }
1398
+ .graph-toolbar-btn.active { background: var(--paper-3); color: var(--ink); }
1399
+
1400
+ /* Focus node search */
1401
+ .graph-focus-search { display: flex; align-items: center; gap: 6px; position: relative; }
1402
+
1403
+ .graph-focus-search-input {
1404
+ font: inherit;
1405
+ font-size: 12px;
1406
+ padding: 3px 8px;
1407
+ border: 1px solid var(--rule-2);
1408
+ border-radius: var(--radius);
1409
+ background: var(--paper);
1410
+ color: var(--ink);
1411
+ width: 180px;
1412
+ }
1413
+
1414
+ .graph-focus-search-input:focus { outline: none; border-color: var(--accent); }
1415
+
1416
+ .graph-focus-search-dropdown {
1417
+ position: absolute;
1418
+ top: calc(100% + 4px);
1419
+ left: 0;
1420
+ width: 280px;
1421
+ background: var(--paper);
1422
+ border: 1px solid var(--rule-2);
1423
+ border-radius: var(--radius);
1424
+ box-shadow: 0 4px 16px rgba(0,0,0,0.12);
1425
+ z-index: 100;
1426
+ overflow: hidden;
1427
+ }
1428
+
1429
+ .graph-focus-search-item {
1430
+ display: flex;
1431
+ align-items: center;
1432
+ padding: 7px 10px;
1433
+ cursor: pointer;
1434
+ font-size: 12px;
1435
+ gap: 6px;
1436
+ }
1437
+
1438
+ .graph-focus-search-item:hover,
1439
+ .graph-focus-search-item.selected { background: var(--paper-2); }
1440
+
1441
+ /* Graph nav link (used in EdgePanel and node header) */
1442
+ .graph-nav-link {
1443
+ display: inline-flex;
1444
+ align-items: center;
1445
+ gap: 4px;
1446
+ color: var(--ink-4);
1447
+ cursor: pointer;
1448
+ background: none;
1449
+ border: none;
1450
+ padding: 0;
1451
+ font: inherit;
1452
+ font-size: 11px;
1453
+ line-height: 1;
1454
+ }
1455
+
1456
+ .graph-nav-link:hover { color: var(--ink-2); }