Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ui): draw Behavior and Service map calls in the green of the scheme

Bernhard Jackiewicz112abd48d182
diff --git a/graph-ui/src/architecture/ArchitectureScene.tsx b/graph-ui/src/architecture/ArchitectureScene.tsx
index eb5468e2f..1dc818387 100644
--- a/graph-ui/src/architecture/ArchitectureScene.tsx
+++ b/graph-ui/src/architecture/ArchitectureScene.tsx
@@ -112,7 +112,7 @@ function Relationship({ edge, geometry, selected, emphasized, dimmed, showLabel,
onSelect: () => void; onHover: (id?: string) => void;
}) {
const { curve, labelPosition } = geometry;
- const color = edgeColor(edge.type);
+ const color = edge.tint ?? edgeColor(edge.type);
const opacity = dimmed ? 0.06 : selected ? 1 : emphasized ? 0.95 : 0.55;
return <group>
<mesh onClick={event => { event.stopPropagation(); onSelect(); }}
@@ -374,7 +374,7 @@ export function ArchitectureScene({ model: graphModel, selectedId, selectedEdgeI
const geometry = edgeGeometry.get(edge.id);
if (!geometry || !isDirectedEdge(edge.type)) return [];
const emphasized = edge.id === focusEdgeId || edge.source === focusId || edge.target === focusId;
- return [{ id: edge.id, type: edge.type, points: geometry.points,
+ return [{ id: edge.id, type: edge.type, points: geometry.points, color: edge.tint,
opacity: related.size > 0 && !emphasized ? 0.04 : edge.id === selectedEdgeId ? 0.95 : emphasized ? 0.8 : 0.65 }];
}), [model.edges, edgeGeometry, focusEdgeId, focusId, related, selectedEdgeId]);
const floorY = Math.min(0, ...model.nodes.map(node => node.position[1])) - 0.14;
diff --git a/graph-ui/src/architecture/SystemArchitectureScene.tsx b/graph-ui/src/architecture/SystemArchitectureScene.tsx
index eaab3e88e..91768b9bd 100644
--- a/graph-ui/src/architecture/SystemArchitectureScene.tsx
+++ b/graph-ui/src/architecture/SystemArchitectureScene.tsx
@@ -7,7 +7,7 @@ import { edgeColor, isDirectedEdge, normalizeEdgeType } from '../graph/edge-styl
import { EdgePulseLayer } from '../graph/EdgePulseLayer';
import { useGraphBackgroundReset } from '../graph/useGraphBackgroundReset';
import { connectionLoad, type ConnectionLoad } from '../graph/connection-load';
-import { SCENE_MAX_TILT, SCENE_PALETTE } from './scene-palette';
+import { journeyEdgeColor, SCENE_MAX_TILT, SCENE_PALETTE } from './scene-palette';
import { journeyChipForm, placeSecondaryLabels, type LabelRect, type SecondaryLabel } from './label-space';
/** The model keeps its stable XY layout; rendering places that footprint on XZ. */
@@ -126,19 +126,20 @@ function connectionGeometry(source: SystemSceneNode, target: SystemSceneNode, of
interface ConnectionStrand { type: string; geometry: ReturnType<typeof connectionGeometry> }
-function Connection({ edge, strands, selected, dimmed, emphasized, onSelect }: {
+function Connection({ edge, strands, selected, dimmed, emphasized, onSelect, colorOf }: {
edge: SystemSceneEdge; strands: ConnectionStrand[]; selected: boolean;
dimmed: boolean; emphasized: boolean; onSelect: () => void;
+ colorOf: (type: string, types?: readonly string[]) => string;
}) {
const internal = edge.source === edge.target;
const opacity = selected ? 0.98 : dimmed ? 0.065 : emphasized ? 0.86 : internal ? 0.15 : 0.34;
return <group onClick={event => { event.stopPropagation(); onSelect(); }}>
{strands.map(({ type, geometry }) => <group key={type}>
- <Line points={geometry.points} color={edgeColor(type)} lineWidth={selected ? 2 : emphasized ? 1.6 : 0.7}
+ <Line points={geometry.points} color={colorOf(type)} lineWidth={selected ? 2 : emphasized ? 1.6 : 0.7}
transparent opacity={opacity} depthWrite={false} />
</group>)}
{selected && <Html position={strands[0].geometry.curve.getPoint(0.5).lerp(strands.at(-1)!.geometry.curve.getPoint(0.5), 0.5)} center zIndexRange={[15, 10]} style={{ pointerEvents: 'none' }}>
- <span className="system-scene-edge-label" style={{ borderColor: edgeColor(edge.type, edge.types) }}>{internal ? 'Within group · ' : ''}{edge.types?.length ? edge.types.join(' · ').replaceAll('_', ' ') : edge.type.replaceAll('_', ' ')} · {edge.count}</span>
+ <span className="system-scene-edge-label" style={{ borderColor: colorOf(edge.type, edge.types) }}>{internal ? 'Within group · ' : ''}{edge.types?.length ? edge.types.join(' · ').replaceAll('_', ' ') : edge.type.replaceAll('_', ' ')} · {edge.count}</span>
</Html>}
</group>;
}
@@ -284,11 +285,13 @@ export default function SystemArchitectureScene({ model, selectedNode, selectedE
}
return result;
}, [model.edges, nodes, offsets]);
+ // Behavior draws only invocations: its plain calls take the green of the scheme.
+ const colorOf = presentation === 'journey' ? journeyEdgeColor : edgeColor;
const pulsePaths = useMemo(() => model.edges.flatMap(edge => {
const dimmed = !activeEdge(model, edge, activePath) || !focusedEdge(edge), emphasized = (model.highlightActive || neighborhood.size > 0) && !dimmed;
- return (edgeStrands.get(edge.id) ?? []).filter(strand => isDirectedEdge(strand.type)).map(({ type, geometry }) => ({ id: `${edge.id}:${type}`, type, points: geometry.points,
+ return (edgeStrands.get(edge.id) ?? []).filter(strand => isDirectedEdge(strand.type)).map(({ type, geometry }) => ({ id: `${edge.id}:${type}`, type, points: geometry.points, color: colorOf(type),
opacity: edge.id === selectedEdge ? 0.95 : dimmed ? 0.04 : emphasized ? 0.8 : edge.source === edge.target ? 0.22 : 0.65 }));
- }), [model, edgeStrands, activePath, selectedEdge, selectedNode, neighborhood]);
+ }), [model, edgeStrands, activePath, selectedEdge, selectedNode, neighborhood, colorOf]);
const background = useGraphBackgroundReset(onClearSelection);
const floorY = Math.min(0, ...model.nodes.map(node => center(node).y - dimensions(node)[1] / 2), ...(model.lanes ?? []).map(lane => lane.position[2] - lane.depth / 2)) - 0.2;
const extent = Math.max(120, ...model.nodes.map(node => Math.max(Math.abs(node.position[0]) + dimensions(node)[0] / 2, Math.abs(node.position[1]) + dimensions(node)[2] / 2) * 2 + 40));
@@ -317,7 +320,7 @@ export default function SystemArchitectureScene({ model, selectedNode, selectedE
return strands ? <Connection key={edge.id} edge={edge} strands={strands}
selected={selectedEdge === edge.id} dimmed={!activeEdge(model, edge, activePath) || !focusedEdge(edge)}
emphasized={Boolean((model.highlightActive || neighborhood.size > 0) && activeEdge(model, edge, activePath) && focusedEdge(edge))}
- onSelect={() => onSelectEdge(edge.id)} /> : null;
+ onSelect={() => onSelectEdge(edge.id)} colorOf={colorOf} /> : null;
})}
<EdgePulseLayer paths={pulsePaths} active={active} />
{model.nodes.map(node => {
diff --git a/graph-ui/src/architecture/container-layout.ts b/graph-ui/src/architecture/container-layout.ts
index 4de35f765..087b82908 100644
--- a/graph-ui/src/architecture/container-layout.ts
+++ b/graph-ui/src/architecture/container-layout.ts
@@ -1,5 +1,6 @@
import type { ContainerTopology } from './container-topology';
import type { SemanticGraph } from './semantic-graph';
+import { SCENE_PALETTE } from './scene-palette';
/** Condense cycles before layering. Direction describes callers, not data movement. */
export function layoutContainers(topology: ContainerTopology): { graph: SemanticGraph; cycles: string[][] } {
@@ -51,12 +52,15 @@ export function layoutContainers(topology: ContainerTopology): { graph: Semantic
nodes: services.map(service => ({ id: service.id, kind: 'area', label: service.name,
detail: `${service.project} · ${service.image ?? 'built from source'}`, position: positions.get(service.id)!,
count: service.sourcePaths.length, members: [], footprint: [18, 18],
- tint: service.sourcePaths.length ? '#85b4c5' : '#b6a087', kindLabel: 'Declared service' })),
- edges: [...topology.connections].sort((a, b) => a.id.localeCompare(b.id)).map(edge => ({ id: edge.id, source: edge.source, target: edge.target,
- type: edge.kind === 'startup' ? 'STARTUP_DEPENDENCY' : edge.kind === 'configuration' ? 'CONFIGURES'
+ tint: service.sourcePaths.length ? SCENE_PALETTE.serviceSource : SCENE_PALETTE.serviceImage, kindLabel: 'Declared service' })),
+ edges: [...topology.connections].sort((a, b) => a.id.localeCompare(b.id)).map(edge => {
+ const type = edge.kind === 'startup' ? 'STARTUP_DEPENDENCY' : edge.kind === 'configuration' ? 'CONFIGURES'
: /redis|postgres|mysql|database|sql/i.test(edge.protocol) ? 'SERVICE_CALLS'
- : /grpc/i.test(edge.protocol) ? 'GRPC_CALLS' : /http/i.test(edge.protocol) ? 'HTTP_CALLS' : 'SERVICE_CALLS',
- count: edge.evidence.length, evidence: [] })),
+ : /grpc/i.test(edge.protocol) ? 'GRPC_CALLS' : /http/i.test(edge.protocol) ? 'HTTP_CALLS' : 'SERVICE_CALLS';
+ // A plain service link is the line of this map: the green of the scheme, as in the "Calls" key.
+ return { id: edge.id, source: edge.source, target: edge.target, type, count: edge.evidence.length, evidence: [],
+ ...(type === 'SERVICE_CALLS' ? { tint: SCENE_PALETTE.call } : {}) };
+ }),
totalNodes: services.length, totalEdges: topology.connections.length, omittedNodes: 0, omittedEdges: 0, warnings: [],
};
return { graph, cycles: groups.filter(group => group.length > 1 || adjacent.get(group[0])!.has(group[0])) };
diff --git a/graph-ui/src/architecture/container-map.css b/graph-ui/src/architecture/container-map.css
index 14471b0fb..4cd14059c 100644
--- a/graph-ui/src/architecture/container-map.css
+++ b/graph-ui/src/architecture/container-map.css
@@ -4,7 +4,7 @@
.container-edge-key { display:flex; flex-wrap:wrap; gap:14px; font-size:11px; align-items:center; color:var(--spatial-muted); }
.container-edge-key label, .container-edge-key span { display:flex; align-items:center; gap:6px; }
.container-edge-key input { accent-color:#a9b8b1; }
-.container-call-key { width:18px; height:2px; background:#7da4ba; }
+.container-call-key { width:18px; height:2px; background:var(--arch-call); }
.container-map .spatial-map { height:clamp(540px,64vh,820px); }
.container-map .spatial-inspector { max-height:clamp(540px,64vh,820px); }
.container-map .architecture-node-label:not(.is-selected) { max-width:145px; background:var(--arch-label); border-color:color-mix(in srgb, var(--arch-accent-line) 50%, transparent); border-radius:6px; padding:7px 12px; }
@@ -18,7 +18,7 @@
.container-mode { display:flex; gap:6px; margin:16px 0; }
.container-mode button { color:#aebeb7; border:1px solid #314c43; border-radius:6px; padding:8px 14px; background:#101b19; font:inherit; font-size:12px; cursor:pointer; }
.container-mode button[aria-pressed=true] { color:#d9ece5; background:#243d35; border-color:#638d7b; }
-.container-mode button:focus-visible { outline:2px solid #8ce9f7; outline-offset:3px; }
+.container-mode button:focus-visible { outline:2px solid var(--atlas-cyan); outline-offset:3px; }
@media(max-width:760px) { .container-projects { padding:12px; } .container-map .spatial-map { height:540px; } }
/* A project without Compose files is an answer, not a warning; a read failure keeps the warning tone. */
.container-discovery { display:flex; flex-wrap:wrap; align-items:center; gap:10px 16px; padding:12px 20px; }
diff --git a/graph-ui/src/architecture/scene-palette.test.ts b/graph-ui/src/architecture/scene-palette.test.ts
index 225b299f4..2456e0976 100644
--- a/graph-ui/src/architecture/scene-palette.test.ts
+++ b/graph-ui/src/architecture/scene-palette.test.ts
@@ -2,7 +2,9 @@ import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
-import { SCENE_PALETTE, scenePaletteStyle } from './scene-palette';
+import { edgeColor } from '../graph/edge-style';
+import { layoutContainers } from './container-layout';
+import { journeyEdgeColor, SCENE_PALETTE, scenePaletteStyle } from './scene-palette';
const here = dirname(fileURLToPath(import.meta.url));
const read = (name: string) => readFileSync(join(here, name), 'utf8');
@@ -13,6 +15,15 @@ const SCENE_FILES = ['ArchitectureScene.tsx', 'SystemArchitectureScene.tsx', 'ar
const BLUE_GREY = ['#0b1118', '#1c3440', '#15242e', '#536977', '#6e8a98', '#91a6b4', '#27333e', '#0e1925', '#111923', '#14212e',
'#101820', '#0b1219', '#080f17', '#0b1525', '#12252d', '#080f14', '#101b23', '#638db3', '#719ec5', '#8ca5bc', '#9bb5ca', '#b6c7d5'];
const rgb = (hex: string) => [1, 3, 5].map(at => parseInt(hex.slice(at, at + 2), 16));
+/** Blue the strongest channel: the hue the user called "blau statt grün". */
+const bluish = (hex: string) => { const [red, green, blue] = rgb(hex); return blue > green && blue > red; };
+/**
+ * Blue literals that encode data, not scenery: the kind colours of the
+ * Overview (the reference scheme) and the fill light it was lit with.
+ */
+const ENCODINGS: Record<string, string> = {
+ '#8ccff1': 'Overview: file kind', '#c2afff': 'Overview: symbol kind', '#554d70': 'Overview: symbol kind, chip border', '#a899ff': 'fill light of every scene, Overview included',
+};
describe('architecture scene palette', () => {
it('leaves no blue-grey scene colour in any Architecture scene', () => {
@@ -38,4 +49,25 @@ describe('architecture scene palette', () => {
expect(read(name), name).toContain('var(--arch-');
}
});
+ it('draws no scenery in blue: every blue literal in a scene file is a named data encoding', () => {
+ const found = [...SCENE_FILES, 'container-layout.ts', 'scene-palette.ts'].flatMap(name => [...read(name).matchAll(/#[0-9a-f]{6}(?:[0-9a-f]{2})?\b/gi)]
+ .map(match => match[0].slice(0, 7).toLowerCase()).filter(color => bluish(color) && !ENCODINGS[color]).map(color => `${name}: ${color}`));
+ expect(found).toEqual([]);
+ for (const [key, value] of Object.entries(SCENE_PALETTE)) if (key !== 'fillLight') expect(bluish(value), key).toBe(false);
+ });
+ it('draws the calls of Behavior and the Service map in the green of the scheme, other relationships in their own hue', () => {
+ // Behavior shows only invocations, so its plain call needs no hue to tell it from imports or usage.
+ expect(bluish(edgeColor('CALLS'))).toBe(true);
+ expect(journeyEdgeColor('CALLS')).toBe(SCENE_PALETTE.call);
+ expect(journeyEdgeColor('HTTP_CALLS')).toBe(edgeColor('HTTP_CALLS'));
+ const [red, green, blue] = rgb(SCENE_PALETTE.call);
+ expect(green).toBeGreaterThan(Math.max(red, blue));
+ const service = { project: 'demo', manifest: 'compose.yml', line: 1, networks: [], ports: [] };
+ const { graph } = layoutContainers({ services: [{ ...service, id: 'api', name: 'api', sourcePaths: ['api'] }, { ...service, id: 'db', name: 'db', image: 'postgres:16', sourcePaths: [] }],
+ connections: [{ id: 'api->db', source: 'api', target: 'db', kind: 'call', protocol: 'postgres', evidence: [] }], warnings: [], unresolved: [] });
+ expect(graph.nodes.map(node => node.tint)).toEqual([SCENE_PALETTE.serviceSource, SCENE_PALETTE.serviceImage]);
+ expect(graph.edges.map(edge => [edge.type, edge.tint])).toEqual([['SERVICE_CALLS', SCENE_PALETTE.call]]);
+ expect(read('SystemArchitectureScene.tsx')).toContain('journeyEdgeColor');
+ expect(read('container-map.css')).toContain('.container-call-key { width:18px; height:2px; background:var(--arch-call); }');
+ });
});
diff --git a/graph-ui/src/architecture/scene-palette.ts b/graph-ui/src/architecture/scene-palette.ts
index 0e6aa0e73..51ebaf135 100644
--- a/graph-ui/src/architecture/scene-palette.ts
+++ b/graph-ui/src/architecture/scene-palette.ts
@@ -1,4 +1,5 @@
import type { CSSProperties } from 'react';
+import { edgeColor, normalizeEdgeType } from '../graph/edge-style';
/**
* One colour scheme for every Architecture scene: Overview, Routes (Service
@@ -13,7 +14,10 @@ import type { CSSProperties } from 'react';
* root), so there is a single table.
*
* Relationship hues (graph/edge-style.ts), language tints and the amber of
- * hotspots and routes are encodings, not scenery, and stay as they are.
+ * hotspots and routes are encodings, not scenery, and stay as they are. The
+ * one exception is the plain call where it is the only kind of line: in
+ * Behavior and in the Service map it takes `call` (journeyEdgeColor,
+ * container-layout.ts).
*/
export const SCENE_PALETTE = {
/** Canvas clear colour and the ground of every scene container. */
@@ -28,6 +32,11 @@ export const SCENE_PALETTE = {
/** A box without its own tint: a group, component or operation. */
node: '#8fc0aa',
remainder: '#a6a68f',
+ /** The plain call where it is the only kind of line: Behavior, and the service links of the Service map. */
+ call: '#62d2a2',
+ /** Service map: a service built from source, and one that runs a published image. */
+ serviceSource: '#79c9b0',
+ serviceImage: '#b6a087',
selected: '#effff8',
keyLight: '#dcfff3',
fillLight: '#a899ff',
@@ -55,6 +64,18 @@ export const SCENE_PALETTE = {
codeLine: '#6be7ba1f',
} as const;
+/**
+ * The line colour of a Behavior call. Behavior draws only invocations, so a
+ * plain call needs no hue to tell it from imports or usage and takes the
+ * green of the scheme; HTTP, async and the other invocation kinds keep their
+ * hues. Overview and System structure keep every hue: there calls run beside
+ * green usage lines.
+ */
+export function journeyEdgeColor(type: string, types?: readonly string[]): string {
+ const kinds = [...new Set((types?.length ? types : [type]).map(normalizeEdgeType))];
+ return kinds.length === 1 && kinds[0] === 'CALLS' ? SCENE_PALETTE.call : edgeColor(type, types);
+}
+
/** The lowest the camera may tilt: a map turned edge-on reads as a flat line. */
export const SCENE_MAX_TILT = Math.PI * 7 / 18;
diff --git a/graph-ui/src/architecture/semantic-graph.ts b/graph-ui/src/architecture/semantic-graph.ts
index 2d0e705e0..b0ef4bee2 100644
--- a/graph-ui/src/architecture/semantic-graph.ts
+++ b/graph-ui/src/architecture/semantic-graph.ts
@@ -47,6 +47,8 @@ export interface SemanticEdge {
type: string;
count: number;
evidence: SemanticEvidence[];
+ /** The line colour a map chose for this relationship; the hue of its type otherwise. */
+ tint?: string;
}
/** Visual folder context only; these containers are never graph nodes. */
export interface SemanticPlatform {
diff --git a/graph-ui/src/architecture/spatial-architecture.css b/graph-ui/src/architecture/spatial-architecture.css
index 2a34d6501..b117d7090 100644
--- a/graph-ui/src/architecture/spatial-architecture.css
+++ b/graph-ui/src/architecture/spatial-architecture.css
@@ -5,7 +5,7 @@
.spatial-heading p { margin:8px 0 0; max-width:740px; font-size:13px; line-height:1.6; color:var(--spatial-muted); }
.spatial-architecture button, .spatial-architecture select { color:inherit; border:1px solid var(--spatial-line); border-radius:5px; background:var(--arch-panel-raised); padding:7px 10px; font:inherit; font-size:12px; cursor:pointer; }
.spatial-architecture button:hover, .spatial-architecture button[aria-pressed=true] { color:#85f0c3; background:#17332e; border-color:#449e7b; }
-.spatial-architecture button:focus-visible, .spatial-architecture select:focus-visible, .spatial-architecture summary:focus-visible { outline:2px solid #8ce9f7; outline-offset:3px; }
+.spatial-architecture button:focus-visible, .spatial-architecture select:focus-visible, .spatial-architecture summary:focus-visible { outline:2px solid var(--atlas-cyan); outline-offset:3px; }
.spatial-architecture button:disabled { opacity:.5; cursor:default; }
.spatial-camera-controls { display:flex; gap:4px; flex-shrink:0; }
.spatial-controls { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; padding:12px 20px; border-block:1px solid var(--spatial-line); }
@@ -44,7 +44,7 @@
.spatial-architecture summary { font-size:12px; color:var(--spatial-muted); cursor:pointer; padding:8px 0; }
.spatial-evidence article { padding:12px 0; border-bottom:1px solid var(--spatial-line); font-size:11px; display:flex; flex-direction:column; gap:4px; }
.spatial-evidence article button { text-align:left; overflow-wrap:anywhere; }
-.spatial-evidence code { color:#a7b6ff; overflow-wrap:anywhere; }
+.spatial-evidence code { color:var(--arch-accent-strong); overflow-wrap:anywhere; }
.spatial-bottom { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; padding:12px 20px; border-top:1px solid var(--spatial-line); color:var(--spatial-muted); font-size:11px; }
.spatial-notice { padding:0 20px; font-size:11px; line-height:1.6; color:#d7be8b; }
.spatial-relationship-list, .spatial-coverage { padding:0 20px 12px; }
diff --git a/graph-ui/src/architecture/system-architecture.css b/graph-ui/src/architecture/system-architecture.css
index 6f3d9f117..66ec47064 100644
--- a/graph-ui/src/architecture/system-architecture.css
+++ b/graph-ui/src/architecture/system-architecture.css
@@ -90,7 +90,7 @@
.system-architecture .system-scene-node-label[data-kind=remainder] { color: #b6b3a6; border-style: dashed; }
.system-scene-lane-label { color: #92a89c; font: 10px var(--atlas-ui-font, system-ui, sans-serif); white-space: nowrap; background: #0d1512bb; padding: 3px 7px; border-radius: 4px; }
.system-scene-lane-label[data-component=true] { font-size: 11px; color: #a7b9af; display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
-.system-scene-edge-label { display: inline-block; max-width: 230px; color: #c2c6cf; font-size: 10px; background: #111716f2; border: 1px solid #91a59a38; padding: 5px 8px; border-radius: 6px; }
+.system-scene-edge-label { display: inline-block; max-width: 230px; color: var(--arch-label-text); font-size: 10px; background: #111716f2; border: 1px solid #91a59a38; padding: 5px 8px; border-radius: 6px; }
.system-scope-actions, .system-selection-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 8px 0 12px; }
.system-scope-actions button, .system-selection-actions button { border: 1px solid var(--atlas-line); border-radius: 5px; background: #82998f0c; color: var(--atlas-fg); font: inherit; font-size: 11px; padding: 5px 8px; }
.system-selection-actions button:disabled, .system-scope-actions button:disabled { opacity: .4; }
diff --git a/graph-ui/src/graph/EdgePulseLayer.tsx b/graph-ui/src/graph/EdgePulseLayer.tsx
index 2e9190059..fae2d1e31 100644
--- a/graph-ui/src/graph/EdgePulseLayer.tsx
+++ b/graph-ui/src/graph/EdgePulseLayer.tsx
@@ -7,6 +7,8 @@ import { useEdgeMotion } from './edge-motion';
export interface EdgePulsePath {
id: string | number; type: string; types?: readonly string[];
points: readonly { x: number; y: number; z: number }[]; opacity?: number;
+ /** The colour the view drew the line in, when it is not the hue of its type. */
+ color?: string;
}
/** A full arrow is 1.65 times this scale in CSS pixels. Smaller embedded views
@@ -28,7 +30,7 @@ export function edgePulseGeometry(paths: readonly EdgePulsePath[]): BufferGeomet
}
const total = distances.at(-1)!;
if (!total) continue;
- const color = new Color(edgeColor(path.type, path.types)), phase = edgePhase(path.id);
+ const color = new Color(path.color ?? edgeColor(path.type, path.types)), phase = edgePhase(path.id);
for (let i = 1; i < path.points.length; i++) for (const index of [i - 1, i]) {
const point = path.points[index];
positions.push(point.x, point.y, point.z); colors.push(color.r, color.g, color.b);
@@ -57,7 +59,7 @@ export function edgeArrowGeometry(paths: readonly EdgePulsePath[]): BufferGeomet
}
const total = distances.at(-1)!;
if (!total) continue;
- const color = new Color(edgeColor(path.type, path.types));
+ const color = new Color(path.color ?? edgeColor(path.type, path.types));
for (let i = 1; i < path.points.length; i++) {
if (distances[i] === distances[i - 1]) continue;
const a = path.points[i - 1], b = path.points[i];
diff --git a/graph-ui/src/graph/edge-pulse-geometry.test.ts b/graph-ui/src/graph/edge-pulse-geometry.test.ts
index 90b8d69aa..a0315ebef 100644
--- a/graph-ui/src/graph/edge-pulse-geometry.test.ts
+++ b/graph-ui/src/graph/edge-pulse-geometry.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { edgePulseGeometry, type EdgePulsePath } from './EdgePulseLayer';
+import { Color } from 'three';
+import { edgeArrowGeometry, edgePulseGeometry, type EdgePulsePath } from './EdgePulseLayer';
const path = (id: string, type = 'CALLS'): EdgePulsePath => ({ id, type, points: [{ x: 4, y: 0, z: 0 }, { x: 3, y: 0, z: 0 }, { x: 3, y: 0, z: -3 }] });
describe('batched direction pulse geometry', () => {
@@ -30,4 +31,14 @@ describe('batched direction pulse geometry', () => {
expect([...geometry.getAttribute('position').array].every(Number.isFinite)).toBe(true);
geometry.dispose();
});
+ it('draws a pulse and its arrow in the colour the view chose for the line, else in the hue of its type', () => {
+ const chosen = new Color('#62d2a2'), calls = new Color('#579fc7');
+ for (const build of [edgePulseGeometry, edgeArrowGeometry]) {
+ const geometry = build([{ ...path('journey'), color: '#62d2a2' }, path('plain')]);
+ const colors = geometry.getAttribute('color'), last = colors.count - 1;
+ expect([colors.getX(0), colors.getY(0), colors.getZ(0)].map(value => Number(value.toFixed(4)))).toEqual([chosen.r, chosen.g, chosen.b].map(value => Number(value.toFixed(4))));
+ expect([colors.getX(last), colors.getY(last), colors.getZ(last)].map(value => Number(value.toFixed(4)))).toEqual([calls.r, calls.g, calls.b].map(value => Number(value.toFixed(4))));
+ geometry.dispose();
+ }
+ });
});