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): let a hovered chip keep its size so its neighbours stay

Bernhard Jackiewicz15562c4c8987
diff --git a/graph-ui/src/architecture/label-space.test.ts b/graph-ui/src/architecture/label-space.test.ts
index 99ad786ba..e70e0f28b 100644
--- a/graph-ui/src/architecture/label-space.test.ts
+++ b/graph-ui/src/architecture/label-space.test.ts
@@ -59,7 +59,11 @@ describe('label space', () => {
// 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);
+ // Nor to hide its neighbours: only a selected chip grows, a hovered one keeps its size (Hotspots: create hid label_for_field).
+ const crowded: SceneChip[] = [...chips, { id: 'label_for_field', x: 230, y: 132, width: 110, height: 24, measured: true }];
+ const calm = placeSceneLabels(crowded, [], options);
+ expect(calm.visible.size).toBe(3);
+ expect([...placeSceneLabels(crowded, [], { ...options, priorityId: 'create' }).visible].sort()).toEqual([...calm.visible].sort());
// 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.ts
index c73746187..21dae0f8c 100644
--- a/graph-ui/src/architecture/label-space.ts
+++ b/graph-ui/src/architecture/label-space.ts
@@ -75,17 +75,19 @@ export interface SceneLabelOptions {
/**
* 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.
+ * Only the selected chip reserves the 96 px its extra rows take; a hovered
+ * chip goes first but keeps its size, so hovering a shown chip hides none of
+ * its neighbours, and hovering a box reveals its hidden chip. Folder names
+ * then take the free corners (placeSecondaryLabels), placed around the chips
+ * as they lie without the pointer: hovering must not make the names beside a
+ * chip 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 height = chip.id === options.selectedId ? 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;