feat(canvas): enhance edge insertion and local node data handling

- Added support for new edge insertion features, including default edge types and improved layout calculations.
- Introduced local node data persistence during flow reconciliation to ensure data integrity.
- Updated connection drop menu to handle edge insertions and node interactions more effectively.
- Enhanced testing for edge insert layout and local node data management.
This commit is contained in:
2026-04-05 21:26:20 +02:00
parent de37b63b2b
commit 7c34da45b4
24 changed files with 2404 additions and 63 deletions

View File

@@ -256,6 +256,96 @@ describe("canvas flow reconciliation helpers", () => {
expect(result.nextPendingLocalPositionPins.size).toBe(0);
});
it("keeps pinned local node data until convex catches up", () => {
const pinnedData = { blackPoint: 209, whitePoint: 255 };
const staleIncomingData = { blackPoint: 124, whitePoint: 255 };
const result = reconcileCanvasFlowNodes({
previousNodes: [
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: pinnedData,
},
],
incomingNodes: [
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: staleIncomingData,
},
],
convexNodes: [{ _id: asNodeId("node-1"), type: "curves" }],
deletingNodeIds: new Set(),
resolvedRealIdByClientRequest: new Map(),
pendingConnectionCreateIds: new Set(),
preferLocalPositionNodeIds: new Set(),
pendingLocalPositionPins: new Map(),
pendingLocalNodeDataPins: new Map([["node-1", pinnedData]]),
pendingMovePins: new Map(),
});
expect(result.nodes).toEqual([
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: pinnedData,
},
]);
expect(result.nextPendingLocalNodeDataPins).toEqual(
new Map([["node-1", pinnedData]]),
);
});
it("clears pinned local node data once incoming data includes the persisted values", () => {
const pinnedData = { blackPoint: 209, whitePoint: 255 };
const incomingData = {
blackPoint: 209,
whitePoint: 255,
_status: "idle",
};
const result = reconcileCanvasFlowNodes({
previousNodes: [
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: pinnedData,
},
],
incomingNodes: [
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: incomingData,
},
],
convexNodes: [{ _id: asNodeId("node-1"), type: "curves" }],
deletingNodeIds: new Set(),
resolvedRealIdByClientRequest: new Map(),
pendingConnectionCreateIds: new Set(),
preferLocalPositionNodeIds: new Set(),
pendingLocalPositionPins: new Map(),
pendingLocalNodeDataPins: new Map([["node-1", pinnedData]]),
pendingMovePins: new Map(),
});
expect(result.nodes).toEqual([
{
id: "node-1",
type: "curves",
position: { x: 120, y: 80 },
data: incomingData,
},
]);
expect(result.nextPendingLocalNodeDataPins.size).toBe(0);
});
it("filters deleting nodes from incoming reconciliation results", () => {
const result = reconcileCanvasFlowNodes({
previousNodes: [