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): name every Behavior call box and count the same calls

Bernhard Jackiewicz371c271bdc89
diff --git a/graph-ui/src/architecture/BehaviorJourney.test.tsx b/graph-ui/src/architecture/BehaviorJourney.test.tsx
index 031402764..4c36d762e 100644
--- a/graph-ui/src/architecture/BehaviorJourney.test.tsx
+++ b/graph-ui/src/architecture/BehaviorJourney.test.tsx
@@ -110,6 +110,18 @@ describe('behavior journeys', () => {
await render(data, { data: undefined, pending: false, error: 'Snapshot changed.' });
expect(container.querySelector('[data-scene]')).toBeNull(); expect(container.textContent).toContain('Snapshot changed.');
});
+ it('pages through every direct callee the heading counts and says what lies beyond the drawing limit', async () => {
+ const data = fixture();
+ const callees = Array.from({ length: 14 }, (_, index) => symbol(index + 20));
+ data.paths = callees.map((target, index) => ({ entrypoint_id: 1, nodes: [data.entrypoints[0], target], edges: [{ id: 500 + index, source_id: 1, target_id: target.id, type: 'CALLS' }] }));
+ await render(data);
+ expect(container.querySelector('.behavior-navigation')?.textContent).toContain('14 direct callees with returned evidence');
+ expect(container.querySelector('[aria-label="Direct call pages"]')?.textContent).toContain('Calls 1 to 4 of 14');
+ for (let page = 0; page < 3; page++) await click('More calls →');
+ expect(container.querySelector('[aria-label="Direct call pages"]')?.textContent).toContain('Calls 13 to 14 of 14');
+ // Every page draws its calls and the start beside them.
+ expect(container.querySelectorAll('[data-node]')).toHaveLength(3);
+ });
it('shows the operation the journey opened with in the Start field, not "Choose an operation"', async () => {
// Without a requested entry the journey falls back to the first entry point (Django: main in manage.py-tpl).
await render(fixture(), { entryId: undefined });
diff --git a/graph-ui/src/architecture/BehaviorJourney.tsx b/graph-ui/src/architecture/BehaviorJourney.tsx
index 83d70431f..4b2f048df 100644
--- a/graph-ui/src/architecture/BehaviorJourney.tsx
+++ b/graph-ui/src/architecture/BehaviorJourney.tsx
@@ -170,7 +170,8 @@ export default function BehaviorJourney({ project, generation, data, entries, ta
<input type="range" aria-label="Call-chain position" min={0} max={path.nodes.length - 1} value={activeStep} onChange={event => selectStep(Number(event.target.value))} />
<span>{activeStep + 1} / {path.nodes.length}</span><button disabled={activeStep >= path.nodes.length - 1} onClick={() => selectStep(activeStep + 1)}>Next →</button></nav>}
{!path && journey.scene.nodes.length > 5 && <nav className="behavior-walk" aria-label="Direct call pages"><button disabled={branchPage === 0} onClick={() => { setBranchPage(page => page - 1); setSelection(undefined); }}>← Earlier calls</button>
- <span>Calls {branchPage * 4 + 1} to {Math.min(branchPage * 4 + 4, journey.scene.nodes.length - 1)} of {journey.scene.nodes.length - 1} shown</span>
+ <span>{text.callPage(branchPage * 4 + 1, Math.min(branchPage * 4 + 4, journey.scene.nodes.length - 1), journey.scene.nodes.length - 1,
+ journey.counts.omittedNodes, journey.scene.nodes.length - 1 + journey.counts.omittedNodes < journey.counts.directChoices)}</span>
<button disabled={(branchPage + 1) * 4 >= journey.scene.nodes.length - 1} onClick={() => { setBranchPage(page => page + 1); setSelection(undefined); }}>More calls →</button></nav>}
</div><aside className="behavior-inspector" aria-label="Behavior evidence inspector">
{caller ? <><span className="system-eyebrow">{call ? call.type.replaceAll('_', ' ') : path ? `Operation ${activeStep + 1}` : 'Starting operation'}</span>
diff --git a/graph-ui/src/architecture/SystemArchitectureScene.tsx b/graph-ui/src/architecture/SystemArchitectureScene.tsx
index e0860e346..eaab3e88e 100644
--- a/graph-ui/src/architecture/SystemArchitectureScene.tsx
+++ b/graph-ui/src/architecture/SystemArchitectureScene.tsx
@@ -8,7 +8,7 @@ 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 { placeSecondaryLabels, type LabelRect, type SecondaryLabel } from './label-space';
+import { journeyChipForm, placeSecondaryLabels, type LabelRect, type SecondaryLabel } from './label-space';
/** The model keeps its stable XY layout; rendering places that footprint on XZ. */
const groundPosition = ([x, y, z]: [number, number, number]): Vector3 => new Vector3(x, z, -y);
@@ -35,11 +35,13 @@ function ScopeCamera({ model, resetKey, planar, presentation }: { model: SystemS
const orbit = controls as unknown as { target: Vector3; update: () => void } | undefined;
if (!orbit || !(camera instanceof ThreeOrthographicCamera) || size.width < 1 || size.height < 1) return;
const last = previous.current;
- if (last && last.key !== key) {
+ // A Behavior page is always fitted afresh: a view kept from an earlier visit may frame none of its boxes.
+ const remember = presentation !== 'journey';
+ if (remember && last && last.key !== key) {
cameraViews.set(last.key, { position: camera.position.toArray() as [number, number, number], target: orbit.target.toArray() as [number, number, number], zoom: camera.zoom, far: camera.far, width: last.width, height: last.height });
if (cameraViews.size > 24) cameraViews.delete(cameraViews.keys().next().value!);
}
- const stored = last?.reset === resetKey ? cameraViews.get(key) : undefined;
+ const stored = remember && last?.reset === resetKey ? cameraViews.get(key) : undefined;
previous.current = { key, reset: resetKey, width: size.width, height: size.height };
camera.up.set(0, planar ? 0 : 1, planar ? -1 : 0);
if (stored && last?.key !== key && stored.width === size.width && stored.height === size.height) {
@@ -97,6 +99,7 @@ function laneSpots(lane: SystemSceneLane): { point: [number, number, number]; al
return ([[-x, far, 'start'], [-x, near, 'start'], [x, far, 'end'], [x, near, 'end']] as const)
.map(([dx, dz, align]) => ({ point: base.clone().add(new Vector3(dx, top, dz)).toArray() as [number, number, number], align }));
}
+const JOURNEY_CHIP = { width: 116, height: 58 }, JOURNEY_COMPACT = { width: 116, height: 26 };
/** Source-to-target geometry is shared by the base edge and the GPU pulse batch. */
function connectionGeometry(source: SystemSceneNode, target: SystemSceneNode, offset: number) {
@@ -147,8 +150,10 @@ const labelPosition = (node: SystemSceneNode): [number, number, number] => {
/**
* Corridor labels take priority; neither hovering nor ordinary selection changes membership.
- * Lane names come last and take a free corner of their lane, or wait hidden; a
- * lane that only repeats its one visible group name gives way to that chip.
+ * A Behavior call box always keeps its name: when the full chips would overlap,
+ * every chip shows the name alone (the tooltip keeps the rest). Lane names come
+ * last and take a free corner of their lane, or wait hidden; a lane that only
+ * repeats its one visible group name gives way to that chip.
*/
function NodeLabels({ model, selectedNode, highlightedPathIndex, onSelect, onExpand, loads, presentation }: {
model: SystemSceneModel; selectedNode?: string; highlightedPathIndex?: number;
@@ -159,6 +164,7 @@ function NodeLabels({ model, selectedNode, highlightedPathIndex, onSelect, onExp
// Html labels mount where drei puts them: the event source, else the canvas parent.
const labelHost = (events.connected as HTMLElement | undefined) ?? gl.domElement.parentElement;
const [visible, setVisible] = useState<Set<string>>(new Set());
+ const [compactChips, setCompactChips] = useState(false);
const [laneSpot, setLaneSpot] = useState<Map<string, number>>(new Map());
const laneBoxes = useRef(new Map<string, { width: number; height: number }>());
useEffect(() => { laneBoxes.current.clear(); }, [model.lanes]);
@@ -181,19 +187,22 @@ function NodeLabels({ model, selectedNode, highlightedPathIndex, onSelect, onExp
const projected = new Vector3(...point).project(camera);
return { x: (projected.x + 1) * size.width / 2, y: (1 - projected.y) * size.height / 2, z: projected.z };
};
+ const journey = presentation === 'journey';
+ const chipForm = journey ? journeyChipForm(ordered.map(node => screen(labelPosition(node))), JOURNEY_CHIP) : 'full';
for (const node of ordered) {
if (node.parentId && zoom < 5) continue;
const { x, y, z } = screen(labelPosition(node));
if (z < -1 || z > 1) continue;
const compact = node.kind === 'group' && !node.expanded;
- const width = presentation === 'journey' ? 116 : compact ? 76 : node.parentId ? 110 : node.expanded ? 126 : 96, height = presentation === 'journey' ? 58 : compact ? 24 : 28;
+ const { width, height } = journey ? chipForm === 'compact' ? JOURNEY_COMPACT : JOURNEY_CHIP
+ : { width: compact ? 76 : node.parentId ? 110 : node.expanded ? 126 : 96, height: compact ? 24 : 28 };
const box = { left: x - width / 2, right: x + width / 2, top: y - height / 2, bottom: y + height / 2 };
- if (box.left < 2 || box.right > size.width - 2 || box.top < 2 || box.bottom > size.height - captionHeight) continue;
- if (boxes.some(other => box.left < other.right && box.right > other.left && box.top < other.bottom && box.bottom > other.top)) continue;
+ if (!journey && (box.left < 2 || box.right > size.width - 2 || box.top < 2 || box.bottom > size.height - captionHeight)) continue;
+ if (!journey && boxes.some(other => box.left < other.right && box.right > other.left && box.top < other.bottom && box.bottom > other.top)) continue;
boxes.push(box); ids.push(node.id);
}
- const key = ids.join('|');
- if (key !== previous.current) { previous.current = key; setVisible(new Set(ids)); }
+ const key = `${chipForm}:${ids.join('|')}`;
+ if (key !== previous.current) { previous.current = key; setVisible(new Set(ids)); setCompactChips(chipForm === 'compact'); }
const shown = new Set(ids);
const names: SecondaryLabel[] = [], given: string[] = [];
for (const lane of [...(model.lanes ?? [])].sort((a, b) => b.width * (b.height ?? 24) - a.width * (a.height ?? 24) || a.id.localeCompare(b.id))) {
@@ -219,7 +228,7 @@ function NodeLabels({ model, selectedNode, highlightedPathIndex, onSelect, onExp
</Html>;
})}{ordered.filter(node => visible.has(node.id)).map(node => <Html key={node.id}
position={labelPosition(node)} center zIndexRange={[10, 6]}>
- <button className="system-scene-node-label" data-presentation={presentation} data-kind={node.kind} data-expanded={node.expanded} data-child={Boolean(node.parentId)}
+ <button className="system-scene-node-label" data-presentation={presentation} data-compact={presentation === 'journey' && compactChips} data-kind={node.kind} data-expanded={node.expanded} data-child={Boolean(node.parentId)}
data-selected={selectedNode === node.id} data-focus={model.focusId === node.id}
data-node-id={node.id} data-position={center(node).toArray().join(',')} data-size={dimensions(node).join(',')}
data-color={node.visual?.color} data-color-label={node.visual?.label}
@@ -228,9 +237,9 @@ function NodeLabels({ model, selectedNode, highlightedPathIndex, onSelect, onExp
data-muted={!activeNode(model, node, highlightedPathIndex)} title={`${node.label} · ${node.detail}${loads ? ` · ${loads.get(node.id)?.links ?? 0} visible links · ${loads.get(node.id)?.neighbors ?? 0} connected items` : ''}${node.visual ? ` · ${node.visual.label}${node.visual.basis ? ` (${node.visual.basis})` : ''}` : ''}`}
type="button" aria-label={`${node.label} · ${node.detail}`} aria-pressed={selectedNode === node.id}
onClick={() => onSelect(node.id)} onDoubleClick={onExpand && (node.group || presentation === 'journey') ? () => onExpand(node.id) : undefined}>
- {presentation === 'journey' && <small>{node.depth === 0 ? 'START' : node.pathIndices?.length ? `HOP ${node.depth}` : 'POSSIBLE CALL'}</small>}
+ {presentation === 'journey' && !compactChips && <small>{node.depth === 0 ? 'START' : node.pathIndices?.length ? `HOP ${node.depth}` : 'POSSIBLE CALL'}</small>}
<strong>{node.label}</strong>
- {presentation === 'journey' && <small>{node.symbol?.file_path?.split('/').at(-1) ?? 'Source unavailable'}</small>}
+ {presentation === 'journey' && !compactChips && <small>{node.symbol?.file_path?.split('/').at(-1) ?? 'Source unavailable'}</small>}
</button>
</Html>)}</>;
}
@@ -283,7 +292,7 @@ export default function SystemArchitectureScene({ model, selectedNode, selectedE
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));
- return <SceneBoundary><div className="system-scene" data-testid="system-scene" data-projection={planar ? 'plan' : '3d'}>
+ return <SceneBoundary><div className="system-scene" data-testid="system-scene" data-projection={planar ? 'plan' : '3d'} data-node-count={model.nodes.length}>
<Canvas {...background} frameloop={active ? 'demand' : 'never'} dpr={[1, 1.5]} gl={{ antialias: true, alpha: false, powerPreference: 'low-power' }}
role="img" aria-label={presentation === 'journey' ? 'Behavior call journey. Follow recorded invocations across component lanes. Double-click an operation to explore its calls.' : `System ${planar ? 'plan' : '3D map'}. Groups lie on a ground plane; expanded members sit above their group. Use the adjacent list to inspect source evidence.`}>
<color attach="background" args={[SCENE_PALETTE.background]} />
diff --git a/graph-ui/src/architecture/behavior-journey-model.test.ts b/graph-ui/src/architecture/behavior-journey-model.test.ts
index 8eb3eb8f3..1e6fe3be1 100644
--- a/graph-ui/src/architecture/behavior-journey-model.test.ts
+++ b/graph-ui/src/architecture/behavior-journey-model.test.ts
@@ -142,19 +142,30 @@ describe('focused Behavior journeys', () => {
expect(behaviorJourney(projection({ paths: [path([1, 2, 5])] }), { targetId: 5, filter: 'absent' }).mode).toBe('empty');
});
+ it('draws every direct callee the counter names, so the page counter and the count agree (cbm main: 14)', () => {
+ const callees = Array.from({ length: 14 }, (_, index) => symbol(index + 2));
+ const data = projection({ behavior: behavior([symbol(1), ...callees], callees.map((target, index) => edge(300 + index, 1, target.id))) });
+ const result = behaviorJourney(data);
+ expect(result.counts.directChoices).toBe(14);
+ expect(result.scene.nodes).toHaveLength(15);
+ expect(result.counts.omittedNodes).toBe(0);
+ expect(result.choices.filter(choice => choice.direct)).toHaveLength(14);
+ });
+
it('bounds a direct fan while reserving a real edge for every displayed callee', () => {
- const targets = Array.from({ length: 20 }, (_, index) => ({ ...symbol(index + 2), name: `target${String(index).padStart(2, '0')}` }));
+ const targets = Array.from({ length: 60 }, (_, index) => ({ ...symbol(index + 2), name: `target${String(index).padStart(2, '0')}` }));
const edges = [...Array.from({ length: 130 }, (_, index) => edge(index, 1, 2)),
...targets.slice(1).map((target, index) => edge(200 + index, 1, target.id))];
const data = projection({ behavior: behavior([symbol(1), ...targets], edges, {
complete: false, limits_hit: ['server-node-cap'], reachable_targets: targets.map(target => ({ ...target, distance: 1 })),
}) });
const result = behaviorJourney(data);
- expect(result.scene.nodes).toHaveLength(13); expect(result.scene.edges).toHaveLength(120);
- expect(result.choices.filter(choice => choice.direct)).toHaveLength(12);
+ // Twelve pages of four calls; the rest is counted, not drawn.
+ expect(result.scene.nodes).toHaveLength(49); expect(result.scene.edges).toHaveLength(120);
+ expect(result.choices.filter(choice => choice.direct)).toHaveLength(48);
const connected = new Set(result.scene.edges.map(item => item.target));
expect(result.scene.nodes.slice(1).every(node => connected.has(node.id))).toBe(true);
- expect(result.counts.omittedNodes).toBe(8); expect(result.counts.omittedChoices).toBe(8);
+ expect(result.counts.omittedNodes).toBe(12); expect(result.counts.omittedChoices).toBe(12);
expect(result.counts.omittedEdges).toBe(edges.length - 120);
expect(result.limits.sampled).toBe(true);
expect(result.limits.hit).toEqual(expect.arrayContaining(['server-node-cap', 'direct-choices', 'direct-edges']));
diff --git a/graph-ui/src/architecture/behavior-journey-model.ts b/graph-ui/src/architecture/behavior-journey-model.ts
index 500ec1bb6..b0987c445 100644
--- a/graph-ui/src/architecture/behavior-journey-model.ts
+++ b/graph-ui/src/architecture/behavior-journey-model.ts
@@ -15,7 +15,12 @@ export interface BehaviorJourney {
limits: { maxChoices: number; maxNodes: number; maxEdges: number; hit: string[]; sampled: boolean };
}
-const MAX_CHOICES = 12, MAX_NODES = 60, MAX_EDGES = 120;
+/**
+ * Direct callees drawn and offered: twelve pages of four. The page counter and
+ * the "direct callees" count name the same calls up to this bound; beyond it
+ * the page counter says how many were left out.
+ */
+const MAX_CHOICES = 48, MAX_NODES = 60, MAX_EDGES = 120;
const INVOCATIONS = new Set(['CALLS', 'HTTP_CALLS', 'ASYNC_CALLS', 'GRPC_CALLS', 'GRAPHQL_CALLS', 'TRPC_CALLS',
'CROSS_HTTP_CALLS', 'CROSS_ASYNC_CALLS', 'CROSS_GRPC_CALLS', 'CROSS_GRAPHQL_CALLS', 'CROSS_TRPC_CALLS']);
const invocation = (edge: { type: string }) => INVOCATIONS.has(edge.type.trim().replaceAll('-', '_').toUpperCase());
diff --git a/graph-ui/src/architecture/behavior-journey.css b/graph-ui/src/architecture/behavior-journey.css
index 952901c9f..410ff50b2 100644
--- a/graph-ui/src/architecture/behavior-journey.css
+++ b/graph-ui/src/architecture/behavior-journey.css
@@ -70,5 +70,7 @@
.system-architecture .system-scene .system-scene-node-label[data-presentation=journey] { width: 116px; height: 58px; gap: 3px; padding: 7px; background: var(--arch-label); border-radius: 8px; }
.system-architecture .system-scene .system-scene-node-label[data-presentation=journey] small { font-size: 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.system-architecture .system-scene .system-scene-node-label[data-presentation=journey] strong { font-size: 10px; }
+/* Too little room for the full chips: every call keeps its name, the kind and file move to the tooltip. */
+.system-architecture .system-scene .system-scene-node-label[data-presentation=journey][data-compact=true] { height: 26px; padding: 4px 7px; gap: 0; }
@media (max-width: 1000px) { .behavior-stage { grid-template-columns: minmax(0, 1fr) 280px; } .behavior-inspector { padding: 14px; } }
@media (max-width: 760px) { .behavior-stage { grid-template-columns: minmax(0, 1fr); } .behavior-inspector { border-left: 0; border-top: 1px solid var(--journey-line); max-height: 420px; } .behavior-heading h2 { font-size: 20px; } .behavior-requests label { flex-basis: 100%; } .behavior-walk { gap: 8px; } }
diff --git a/graph-ui/src/architecture/label-space.test.ts b/graph-ui/src/architecture/label-space.test.ts
index 975569c40..bf0993422 100644
--- a/graph-ui/src/architecture/label-space.test.ts
+++ b/graph-ui/src/architecture/label-space.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { labelEdges, labelInset, labelRect, labelsCollide, placeSecondaryLabels, spotRect, type LabelBox } from './label-space';
+import { journeyChipForm, labelEdges, labelInset, labelRect, labelsCollide, placeSecondaryLabels, spotRect, type LabelBox } from './label-space';
// The compact Overview and Endpoints label: padding 5px 7px and a 1px border (spatial-architecture.css).
const compact: LabelBox = { width: 100, height: 24, edgeX: 8, edgeY: 6 };
@@ -43,4 +43,10 @@ describe('label space', () => {
const covered = { id: 'c', width: 40, height: 14, spots: [{ x: 10, y: 10, align: 'start' as const }, { x: 390, y: 10, align: 'start' as const }] };
expect(placeSecondaryLabels([covered], [labelRect(30, 17, 60, 20, [0, 0])], 400, 300).get('c')).toBe(-1);
});
+ it('keeps every Behavior call name and switches all chips to the compact form when the full ones would overlap', () => {
+ const full = { width: 116, height: 58 };
+ // handle · loaddata.py in the hand-test window: neighbouring call boxes 60 px apart.
+ expect(journeyChipForm([{ x: 500, y: 100 }, { x: 500, y: 160 }, { x: 500, y: 220 }], full)).toBe('compact');
+ expect(journeyChipForm([{ x: 500, y: 100 }, { x: 500, y: 180 }, { x: 200, y: 140 }], full)).toBe('full');
+ });
});
diff --git a/graph-ui/src/architecture/label-space.ts b/graph-ui/src/architecture/label-space.ts
index 742188dc0..b9745d1ca 100644
--- a/graph-ui/src/architecture/label-space.ts
+++ b/graph-ui/src/architecture/label-space.ts
@@ -60,3 +60,12 @@ export function placeSecondaryLabels(labels: readonly SecondaryLabel[], occupied
return result;
}
+/**
+ * Behavior call boxes never lose their name to a neighbour. When the full
+ * chips (kind, name, file) would overlap at this zoom, every chip switches to
+ * the compact form with the name alone; the tooltip keeps the rest.
+ */
+export function journeyChipForm(centres: readonly { x: number; y: number }[], full: { width: number; height: number }, gap = 4): 'full' | 'compact' {
+ const rects = centres.map(({ x, y }) => labelRect(x, y, full.width + gap, full.height + gap, [0, 0]));
+ return rects.some((rect, index) => rects.slice(index + 1).some(other => labelsCollide(rect, other))) ? 'compact' : 'full';
+}
diff --git a/graph-ui/src/architecture/strings.ts b/graph-ui/src/architecture/strings.ts
index 94f210c9e..f5c71ee37 100644
--- a/graph-ui/src/architecture/strings.ts
+++ b/graph-ui/src/architecture/strings.ts
@@ -88,6 +88,8 @@ export const architectureText = {
compareFailed: 'Could not read that project. Its index may be unavailable.',
},
showEndpoints: 'Show endpoints →',
+ /** Behavior: the page of direct calls, the same calls the "direct callees" count names. */
+ callPage: (from: number, to: number, drawn: number, beyond: number, filtered: boolean) => `Calls ${from} to ${to} of ${drawn.toLocaleString()}${filtered ? ' matching the filter' : ''}${beyond ? ` · ${beyond.toLocaleString()} more beyond the display limit` : ''}`,
openedArea: 'Opened area',
openedFile: 'Opened file',
scopeMeasure: (files: number, lines?: number) => `${files.toLocaleString()} files · ${lines === undefined ? 'unknown' : lines.toLocaleString()} indexed lines`,