feat(canvas): implement local node size pinning and reconciliation logic

- Added functions to handle local node size pins, ensuring that node sizes are preserved during reconciliation.
- Updated `reconcileCanvasFlowNodes` to incorporate size pinning logic.
- Enhanced tests to verify the correct behavior of size pinning in various scenarios.
- Updated related components to support new size pinning functionality.
This commit is contained in:
2026-04-10 08:48:34 +02:00
parent 26d008705f
commit 463830f178
12 changed files with 711 additions and 10 deletions

View File

@@ -21,6 +21,9 @@ type CanvasFlowReconciliationRefs = {
Map<string, PositionPin>
>;
pendingLocalNodeDataUntilConvexMatchesRef: MutableRefObject<Map<string, unknown>>;
pendingLocalNodeSizeUntilConvexMatchesRef: MutableRefObject<
Map<string, { width: number; height: number }>
>;
preferLocalPositionNodeIdsRef: MutableRefObject<Set<string>>;
isDragging: MutableRefObject<boolean>;
isResizing: MutableRefObject<boolean>;
@@ -56,6 +59,7 @@ export function useCanvasFlowReconciliation(args: {
pendingConnectionCreatesRef,
pendingLocalPositionUntilConvexMatchesRef,
pendingLocalNodeDataUntilConvexMatchesRef,
pendingLocalNodeSizeUntilConvexMatchesRef,
preferLocalPositionNodeIdsRef,
isDragging,
isResizing,
@@ -135,6 +139,8 @@ export function useCanvasFlowReconciliation(args: {
pendingLocalPositionPins: pendingLocalPositionUntilConvexMatchesRef.current,
pendingLocalNodeDataPins:
pendingLocalNodeDataUntilConvexMatchesRef.current,
pendingLocalNodeSizePins:
pendingLocalNodeSizeUntilConvexMatchesRef.current,
pendingMovePins,
});
@@ -144,6 +150,8 @@ export function useCanvasFlowReconciliation(args: {
reconciliation.nextPendingLocalPositionPins;
pendingLocalNodeDataUntilConvexMatchesRef.current =
reconciliation.nextPendingLocalNodeDataPins;
pendingLocalNodeSizeUntilConvexMatchesRef.current =
reconciliation.nextPendingLocalNodeSizePins;
for (const nodeId of reconciliation.clearedPreferLocalPositionNodeIds) {
preferLocalPositionNodeIdsRef.current.delete(nodeId);
}
@@ -162,6 +170,7 @@ export function useCanvasFlowReconciliation(args: {
pendingConnectionCreatesRef,
pendingLocalPositionUntilConvexMatchesRef,
pendingLocalNodeDataUntilConvexMatchesRef,
pendingLocalNodeSizeUntilConvexMatchesRef,
preferLocalPositionNodeIdsRef,
resolvedRealIdByClientRequestRef,
]);