@checkstack/dependency-frontend 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @checkstack/dependency-frontend
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c0935d8: Fix dependency map node positions resetting when connecting two nodes. The graph-building effect was rebuilding all nodes from scratch on every data change, discarding unsaved drag positions. Node and edge construction are now split into separate effects with a clear position resolution priority: in-memory positions → saved positions → auto-layout fallback for new systems only.
8
+ - @checkstack/catalog-common@1.3.0
9
+ - @checkstack/common@0.6.4
10
+ - @checkstack/dashboard-frontend@0.3.25
11
+ - @checkstack/dependency-common@0.2.0
12
+ - @checkstack/frontend-api@0.3.8
13
+ - @checkstack/healthcheck-common@0.10.0
14
+ - @checkstack/signal-frontend@0.0.14
15
+ - @checkstack/ui@1.2.0
16
+
3
17
  ## 0.2.1
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/dependency-frontend",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -227,21 +227,44 @@ function DependencyMapContent() {
227
227
  [createDependency],
228
228
  );
229
229
 
230
- // Build graph from data
230
+ // Track node positions for saving and for preserving in-memory positions
231
+ const nodesRef = useRef(nodes);
232
+ nodesRef.current = nodes;
233
+
234
+ // Build nodes from systems, positions, warnings, and health data.
235
+ // Position resolution priority:
236
+ // 1. Current in-memory position (user may have dragged but not saved yet)
237
+ // 2. Saved position from the backend
238
+ // 3. Auto-layout fallback for brand-new systems with no position at all
239
+
231
240
  useEffect(() => {
232
- if (!systemsData?.systems || !depsData?.dependencies) return;
241
+ if (!systemsData?.systems) return;
233
242
 
234
243
  const savedPositions = posData?.positions ?? [];
235
- const positions = autoLayout(
236
- systemsData.systems.map((s) => s.id),
237
- savedPositions,
238
- );
239
-
240
244
  const warnings = warningsData?.warnings ?? {};
241
245
  const healthStatuses = healthData?.statuses ?? {};
242
246
 
247
+ // Lookup maps for position resolution
248
+ const savedPositionMap = new Map(
249
+ savedPositions.map((p) => [p.systemId, { x: p.x, y: p.y }]),
250
+ );
251
+ const currentPositionMap = new Map<string, { x: number; y: number }>();
252
+ for (const node of nodesRef.current) {
253
+ currentPositionMap.set(node.id, node.position);
254
+ }
255
+
256
+ // Auto-layout only for systems that have no saved and no in-memory position
257
+ const unpositioned = systemsData.systems
258
+ .map((s) => s.id)
259
+ .filter((id) => !savedPositionMap.has(id) && !currentPositionMap.has(id));
260
+ const fallbackPositions = autoLayout(unpositioned, []);
261
+
243
262
  const newNodes: SystemNode[] = systemsData.systems.map((system) => {
244
- const pos = positions.get(system.id) ?? { x: 0, y: 0 };
263
+ const pos =
264
+ currentPositionMap.get(system.id) ??
265
+ savedPositionMap.get(system.id) ??
266
+ fallbackPositions.get(system.id) ?? { x: 0, y: 0 };
267
+
245
268
  const warning = warnings[system.id];
246
269
 
247
270
  // Map real health status to node status
@@ -270,6 +293,13 @@ function DependencyMapContent() {
270
293
  };
271
294
  });
272
295
 
296
+ setNodes(newNodes);
297
+ }, [systemsData, posData, warningsData, healthData, setNodes]);
298
+
299
+ // Build edges separately — only depends on dependency data
300
+ useEffect(() => {
301
+ if (!depsData?.dependencies) return;
302
+
273
303
  const newEdges: DependencyEdge[] = depsData.dependencies.map(
274
304
  (dep: Dependency) => {
275
305
  const edgeData: DependencyEdgeData = {
@@ -294,13 +324,10 @@ function DependencyMapContent() {
294
324
  },
295
325
  );
296
326
 
297
- setNodes(newNodes);
298
327
  setEdges(newEdges);
299
- }, [systemsData, depsData, posData, warningsData, healthData, setNodes, setEdges]);
328
+ }, [depsData, setEdges]);
300
329
 
301
330
  // Track node position changes for saving
302
- const nodesRef = useRef(nodes);
303
- nodesRef.current = nodes;
304
331
 
305
332
  const handleNodesChange = useCallback(
306
333
  (changes: NodeChange<SystemNode>[]) => {