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.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(ui): keep folder names in place while the pointer moves over chips
Bernhard Jackiewicza644d8c4c86f
diff --git a/graph-ui/src/architecture/ArchitectureScene.tsx b/graph-ui/src/architecture/ArchitectureScene.tsxindex 2f8638e79..eb5468e2f 100644--- a/graph-ui/src/architecture/ArchitectureScene.tsx+++ b/graph-ui/src/architecture/ArchitectureScene.tsx@@ -6,7 +6,7 @@ import type { OrbitControls as OrbitControlsImpl } from 'three-stdlib';import type { SemanticEdge, SemanticGraph, SemanticNode, SemanticPlatform } from './semantic-graph';import { languageColor, measureSourceNode, scopeBrickHeights, sourceLanguage, sourceNodeSizePercent, type SourceCatalog, type SourceMeasure } from './source-metrics';import { gravityPercent, gravityStrength, hotspotsForNode, type HotspotCatalog, type HotspotGroup } from './hotspot-map';-import { labelEdges, labelInset, labelRect, labelsCollide, placeSecondaryLabels, type LabelBox, type LabelRect, type SecondaryLabel } from './label-space';+import { labelEdges, labelInset, placeSceneLabels, type LabelBox, type SceneChip, type SecondaryLabel } from './label-space';import { edgeColor, isDirectedEdge } from '../graph/edge-style';import { EdgePulseLayer } from '../graph/EdgePulseLayer';import './architecture-scene.css';@@ -208,8 +208,8 @@ const folderPriority = (a: SemanticPlatform, b: SemanticPlatform) => Number(b.id* chip and no other name lies: the chips are placed first, then each folder* name takes a free corner of its platform or hides.*/-function SceneLabels({ model, priorityId, cull, onVisible, onFolders }: {- model: RenderGraph; priorityId?: string; cull: boolean;+function SceneLabels({ model, priorityId, selectedId, cull, onVisible, onFolders }: {+ model: RenderGraph; priorityId?: string; selectedId?: string; cull: boolean;onVisible: (ids: Set<string>) => void; onFolders: (spots: Map<string, number>) => void;}) {const { camera, size, gl, events, invalidate } = useThree();@@ -237,26 +237,14 @@ function SceneLabels({ model, priorityId, cull, onVisible, onFolders }: {}// A measured label may overlap a neighbour by its padding, never by its text.const inset = labelInset(boxes.current.values());- const occupied: LabelRect[] = [];- // A folder name may not sit under any part of a chip: its whole box counts.- const chips: LabelRect[] = [];- const ids = new Set<string>();// Hotspot wells, then larger parts, claim their label space first.- const ordered = [...model.nodes].sort((a, b) => Number(b.id === priorityId) - Number(a.id === priorityId)- || (b.gravity ?? 0) - (a.gravity ?? 0) || b.count - a.count);- for (const node of ordered) {+ const chips: SceneChip[] = [...model.nodes].sort((a, b) => (b.gravity ?? 0) - (a.gravity ?? 0) || b.count - a.count).map(node => {const point = new Vector3(...node.position).add(new Vector3(0, dimensions(node)[1] + 7, 0)).project(camera);- const x = (point.x + 1) * size.width / 2; const y = (1 - point.y) * size.height / 2;const box = boxes.current.get(node.id);- const width = box?.width ?? Math.min(178, Math.max(78, (node.shortLabel ?? node.label).length * 7 + (node.gravityPercent === undefined ? 26 : 68)));- const height = node.id === priorityId ? 96 : box?.height ?? 38;- const rect = labelRect(x, y, width, height, box ? inset : [-5, 0]);- if (cull && node.id !== priorityId && (rect.right < 0 || rect.left > size.width || rect.bottom < 0 || rect.top > size.height- || occupied.some(other => labelsCollide(rect, other)))) continue;- ids.add(node.id); occupied.push(rect); chips.push(labelRect(x, y, width, height, [0, 0]));- }- const key = [...ids].sort().join('|');- if (previous.current !== key) { previous.current = key; onVisible(ids); }+ return { id: node.id, x: (point.x + 1) * size.width / 2, y: (1 - point.y) * size.height / 2,+ width: box?.width ?? Math.min(178, Math.max(78, (node.shortLabel ?? node.label).length * 7 + (node.gravityPercent === undefined ? 26 : 68))),+ height: box?.height ?? 38, measured: Boolean(box) };+ });const names: SecondaryLabel[] = [...platforms].sort(folderPriority).map(platform => {const measured = folderBoxes.current.get(platform.id);const text = platform.path ? platform.path.split('/').at(-1) ?? '' : platform.label;@@ -266,7 +254,9 @@ function SceneLabels({ model, priorityId, cull, onVisible, onFolders }: {return { x: (point.x + 1) * size.width / 2, y: (1 - point.y) * size.height / 2, align };}) };});- const spots = placeSecondaryLabels(names, chips, size.width, size.height);+ const { visible: ids, folders: spots } = placeSceneLabels(chips, names, { priorityId, selectedId, cull, width: size.width, height: size.height, inset });+ const key = [...ids].sort().join('|');+ if (previous.current !== key) { previous.current = key; onVisible(ids); }const folderKey = [...spots].map(([id, spot]) => `${id}:${spot}`).join('|');if (previousFolders.current !== folderKey) { previousFolders.current = folderKey; onFolders(spots); }// Labels mount a moment after the scene; a few extra frames pick up their real size.@@ -420,7 +410,7 @@ export function ArchitectureScene({ model: graphModel, selectedId, selectedEdgeItouches={{ ONE: planar ? TOUCH.PAN : TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN }}minZoom={0.15} maxZoom={60} rotateSpeed={0.5} zoomSpeed={0.8} maxPolarAngle={SCENE_MAX_TILT} zoomToCursor /><FitArchitecture model={model} planar={planar} resetKey={resetKey} controls={controls} active={active} />- <SceneLabels model={model} priorityId={selectedId ?? hoveredId} cull={adaptiveLabels || model.view === 'hotspots'} onVisible={setVisibleHotspotLabels} onFolders={setFolderSpotsShown} />+ <SceneLabels model={model} priorityId={selectedId ?? hoveredId} selectedId={selectedId} cull={adaptiveLabels || model.view === 'hotspots'} onVisible={setVisibleHotspotLabels} onFolders={setFolderSpotsShown} /></Canvas><div className="architecture-scene-guide" aria-hidden="true"><span>{planar ? 'PLAN' : '3D MAP'}</span>{planar ? 'Drag to pan · Scroll to zoom' : 'Drag to orbit · Right-drag to pan · Scroll to zoom'}</div></div>;diff --git a/graph-ui/src/architecture/label-space.test.ts b/graph-ui/src/architecture/label-space.test.tsindex bf0993422..99ad786ba 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 { journeyChipForm, labelEdges, labelInset, labelRect, labelsCollide, placeSecondaryLabels, spotRect, type LabelBox } from './label-space';+import { journeyChipForm, labelEdges, labelInset, labelRect, labelsCollide, placeSceneLabels, placeSecondaryLabels, spotRect, type LabelBox, type SceneChip, type SecondaryLabel } 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 };@@ -49,4 +49,18 @@ describe('label space', () => {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');});+ it('leaves folder names where they are while the pointer moves over the chips (Hotspots, Overview)', () => {+ const chips: SceneChip[] = [{ id: 'create', x: 200, y: 100, width: 100, height: 24, measured: true }, { id: 'other', x: 600, y: 300, width: 100, height: 24, measured: true }];+ // The folder name's own corner lies just below the chip, its next corner further away.+ const folders: SecondaryLabel[] = [{ id: 'contrib', width: 60, height: 14, spots: [{ x: 160, y: 125, align: 'start' }, { x: 420, y: 200, align: 'start' }] }];+ const options = { cull: true, width: 800, height: 500, inset: [4, 3] as [number, number] };+ const resting = placeSceneLabels(chips, folders, options);+ expect(resting.folders.get('contrib')).toBe(0);+ // Hovering a chip makes it the priority chip, which is not a reason to move the names around it.+ const hovered = placeSceneLabels(chips, folders, { ...options, priorityId: 'create' });+ expect(hovered.folders).toEqual(resting.folders);+ expect(hovered.visible.has('create')).toBe(true);+ // A selected chip opens its extra rows; the name gives way to it.+ expect(placeSceneLabels(chips, folders, { ...options, priorityId: 'create', selectedId: 'create' }).folders.get('contrib')).toBe(1);+ });});diff --git a/graph-ui/src/architecture/label-space.ts b/graph-ui/src/architecture/label-space.tsindex b9745d1ca..c73746187 100644--- a/graph-ui/src/architecture/label-space.ts+++ b/graph-ui/src/architecture/label-space.ts@@ -60,6 +60,45 @@ export function placeSecondaryLabels(labels: readonly SecondaryLabel[], occupiedreturn result;}+/** A map chip at its projected anchor; an unmeasured one carries an estimate and keeps a margin. */+export interface SceneChip { id: string; x: number; y: number; width: number; height: number; measured: boolean }+export interface SceneLabelOptions {+ /** The chip that claims space first and is never culled: the selected one, else the one under the pointer. */+ priorityId?: string;+ /** The selected chip, which shows its extra rows. */+ selectedId?: string;+ cull: boolean; width: number; height: number;+ /** labelInset of the measured chips. */+ inset: [number, number];+}++/**+ * Chips first, in the given order with the priority chip in front: with+ * `cull` a chip that leaves the canvas or meets one placed before it hides.+ * The priority chip reserves the height of a selected chip (96 px). Folder+ * names then take the free corners (placeSecondaryLabels), placed around+ * the chips as they lie without the pointer: hovering a chip must not make+ * the names beside it jump to another corner and back.+ */+export function placeSceneLabels(chips: readonly SceneChip[], folders: readonly SecondaryLabel[], options: SceneLabelOptions): { visible: Set<string>; folders: Map<string, number> } {+ const place = (priorityId: string | undefined) => {+ const occupied: LabelRect[] = [], boxes: LabelRect[] = [], visible = new Set<string>();+ const ordered = [...chips].sort((a, b) => Number(b.id === priorityId) - Number(a.id === priorityId));+ for (const chip of ordered) {+ const height = chip.id === priorityId ? 96 : chip.height;+ const rect = labelRect(chip.x, chip.y, chip.width, height, chip.measured ? options.inset : [-5, 0]);+ if (options.cull && chip.id !== priorityId && (rect.right < 0 || rect.left > options.width || rect.bottom < 0 || rect.top > options.height+ || occupied.some(other => labelsCollide(rect, other)))) continue;+ // A folder name may not sit under any part of a chip: its whole box counts.+ visible.add(chip.id); occupied.push(rect); boxes.push(labelRect(chip.x, chip.y, chip.width, height, [0, 0]));+ }+ return { visible, boxes };+ };+ const chipsShown = place(options.priorityId);+ const resting = options.priorityId === options.selectedId ? chipsShown : place(options.selectedId);+ return { visible: chipsShown.visible, folders: placeSecondaryLabels(folders, resting.boxes, options.width, options.height) };+}+/*** 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