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): keep a large finished Galaxy layer as an arranged cloud

Bernhard Jackiewiczad1805d7d643
diff --git a/graph-ui/src/galaxy/GalaxyPanel.layers.test.tsx b/graph-ui/src/galaxy/GalaxyPanel.layers.test.tsx
index 2addac6a2..bc3b60733 100644
--- a/graph-ui/src/galaxy/GalaxyPanel.layers.test.tsx
+++ b/graph-ui/src/galaxy/GalaxyPanel.layers.test.tsx
@@ -13,9 +13,13 @@ import { viewPreferencesKey } from '../settings/view-preferences';
import { scopeFetch, scopeNode } from './test-scope-fetch';
import type { GraphEdge } from './types';
+const scene = vi.hoisted(() => ({ separateNodes: undefined as boolean | undefined, nodes: 0 }));
vi.mock('./GraphScene', async importOriginal => ({
...await importOriginal<typeof import('./GraphScene')>(),
- GraphScene: () => <output data-testid="scene" />,
+ GraphScene: ({ separateNodes, data }: { separateNodes?: boolean; data: { nodes: unknown[] } }) => {
+ scene.separateNodes = separateNodes; scene.nodes = data.nodes.length;
+ return <output data-testid="scene" />;
+ },
}));
let host: HTMLDivElement, root: Root;
@@ -98,3 +102,16 @@ it('K8: a layer past the render limit stops there, says it is partial and cannot
await act(async () => minus().click());
await settle(() => expect(status()?.textContent).toBe('2 nodes · 1 edge'));
});
+
+it('K8: a large finished layer keeps its arranged cloud instead of being pushed apart on screen', async () => {
+ const fan = Array.from({ length: 1600 }, (_, at) => scopeNode(100 + at));
+ const nodes = [scopeNode(1), ...fan];
+ const edges: GraphEdge[] = fan.map((node, at) => ({ id: 10 + at, source: 1, target: node.id, type: 'CALLS' }));
+ await act(async () => root.render(<GalaxyPanel project="sample" visible workspaceExpanded onOpenNode={vi.fn()} fetch={scopeFetch({ nodes, edges }).fetch} />));
+ await settle(() => expect(seam().nodes).toBeGreaterThan(0));
+ await act(async () => { seam().clickNode('sample.n1'); });
+ await settle(() => expect(status()?.textContent).toBe(`${(1601).toLocaleString()} nodes · ${(1600).toLocaleString()} edges`));
+ expect(scene.nodes).toBe(1601);
+ // Screen separation pushed a dense cloud of thousands of nodes into a cross of long lines (layer 3 of JSONBAgg).
+ expect(scene.separateNodes).toBe(false);
+});
diff --git a/graph-ui/src/galaxy/GalaxyPanel.reader-focus.test.tsx b/graph-ui/src/galaxy/GalaxyPanel.reader-focus.test.tsx
index 69d1db84f..966bcc84e 100644
--- a/graph-ui/src/galaxy/GalaxyPanel.reader-focus.test.tsx
+++ b/graph-ui/src/galaxy/GalaxyPanel.reader-focus.test.tsx
@@ -115,7 +115,8 @@ it('does not report a file missing from a capped layout while its indexed scope
});
await act(async () => root.render(<GalaxyPanel project="sample" visible focusFilePath="src/a.ts" onOpenNode={vi.fn()} fetch={fetchImpl} />));
// Hand test K8: the status names the layer that is loading instead of an endless "Loading relationships".
- expect(host.textContent).toContain('Loading layer 1…');
+ // It may first say "Checking index…" while the index generation is read; wait for the load itself.
+ await vi.waitFor(() => expect(host.textContent).toContain('Loading layer 1…'));
expect(host.querySelector('[data-testid="atlas-galaxy-note"]')).toBeNull();
await act(async () => { release(); });
expect(host.textContent).toContain('All indexed direct dependencies included.');
diff --git a/graph-ui/src/galaxy/GalaxyPanel.tsx b/graph-ui/src/galaxy/GalaxyPanel.tsx
index 2e5d55d4c..a6ceeada8 100644
--- a/graph-ui/src/galaxy/GalaxyPanel.tsx
+++ b/graph-ui/src/galaxy/GalaxyPanel.tsx
@@ -751,6 +751,14 @@ export interface GalaxyPanelProps {
selectionPanel?: ReactNode | ((scope: SelectionScope | undefined) => ReactNode);
}
+/**
+ * Bis zu wie vielen Knoten ein Ausschnitt auf dem Schirm auseinandergeschoben
+ * wird (Handtest K8). Die Trennung hebt Namen und Ringe kleiner Ausschnitte aus
+ * der Wolke; eine dichte Wolke aus tausenden Knoten (die dritte Ebene um
+ * JSONBAgg) schob sie dagegen zu einem Kreuz aus langen Linien auseinander.
+ */
+export const SCOPE_SEPARATION_LIMIT = 1500;
+
/** Wie lange die Zeitangaben im Instrument stehen, bis sie neu gerechnet werden. */
export const AGENT_TICK_MS = 1000;
@@ -2761,7 +2769,7 @@ export default function GalaxyPanel(props: GalaxyPanelProps): JSX.Element {
{sceneShown !== undefined && everVisible.current && (
<GraphScene
active={visible}
- separateNodes={mode === 'galaxy' && sceneScoped}
+ separateNodes={mode === 'galaxy' && sceneScoped && sceneShown.nodes.length <= SCOPE_SEPARATION_LIMIT}
onRenderBusyChange={setSpacingBusy}
idleRotation={mode === 'galaxy' && !sceneScoped}
rootIds={mode === 'galaxy' && sceneScoped ? scope.result?.roots : undefined}