Skip to content

Commit 14ea671

Browse files
authored
Merge pull request #401 from badaitech/feat/transform-nodes
feat: Enhanced ExecutionEngine to manage parent node readiness and resolve ports correctly. Enhance node UI and dimensions handling
2 parents cbb257e + 92154b7 commit 14ea671

53 files changed

Lines changed: 1372 additions & 375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/chaingraph-backend/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @badaitech/chaingraph-backend
22

3+
## 0.6.36
4+
5+
### Patch Changes
6+
7+
- f359d5e: feat: Enhance node UI and dimensions handling
8+
- Updated dependencies [f359d5e]
9+
- @badaitech/chaingraph-nodes@0.6.36
10+
- @badaitech/chaingraph-types@0.6.36
11+
- @badaitech/chaingraph-trpc@0.6.36
12+
313
## 0.6.35
414

515
### Patch Changes

apps/chaingraph-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-backend",
33
"type": "module",
4-
"version": "0.6.35",
4+
"version": "0.6.36",
55
"private": false,
66
"description": "Backend server for the Chaingraph project",
77
"license": "BUSL-1.1",

apps/chaingraph-execution-api/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @badaitech/chaingraph-execution-api
22

3+
## 0.6.36
4+
5+
### Patch Changes
6+
7+
- f359d5e: feat: Enhance node UI and dimensions handling
8+
- Updated dependencies [f359d5e]
9+
- @badaitech/chaingraph-executor@0.6.36
10+
- @badaitech/chaingraph-nodes@0.6.36
11+
- @badaitech/chaingraph-types@0.6.36
12+
- @badaitech/chaingraph-trpc@0.6.36
13+
- @badaitech/badai-api@0.6.36
14+
315
## 0.6.35
416

517
### Patch Changes

apps/chaingraph-execution-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-execution-api",
33
"type": "module",
4-
"version": "0.6.35",
4+
"version": "0.6.36",
55
"private": false,
66
"description": "Chaingraph tRPC Server - Scalable API server for Chaingraph execution management",
77
"license": "BUSL-1.1",

apps/chaingraph-execution-worker/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @badaitech/chaingraph-execution-worker
22

3+
## 0.6.36
4+
5+
### Patch Changes
6+
7+
- f359d5e: feat: Enhance node UI and dimensions handling
8+
- Updated dependencies [f359d5e]
9+
- @badaitech/chaingraph-executor@0.6.36
10+
- @badaitech/chaingraph-nodes@0.6.36
11+
- @badaitech/chaingraph-types@0.6.36
12+
- @badaitech/chaingraph-trpc@0.6.36
13+
- @badaitech/badai-api@0.6.36
14+
315
## 0.6.35
416

517
### Patch Changes

apps/chaingraph-execution-worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-execution-worker",
33
"type": "module",
4-
"version": "0.6.35",
4+
"version": "0.6.36",
55
"private": false,
66
"description": "Chaingraph Execution Worker Service using DBOS for durable workflow execution",
77
"license": "BUSL-1.1",

apps/chaingraph-frontend/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @badaitech/chaingraph-frontend
22

3+
## 0.6.36
4+
5+
### Patch Changes
6+
7+
- f359d5e: feat: Enhance node UI and dimensions handling
8+
- Updated dependencies [f359d5e]
9+
- @badaitech/chaingraph-executor@0.6.36
10+
- @badaitech/chaingraph-nodes@0.6.36
11+
- @badaitech/chaingraph-types@0.6.36
12+
- @badaitech/chaingraph-trpc@0.6.36
13+
- @badaitech/badai-api@0.6.36
14+
315
## 0.6.35
416

517
### Patch Changes

apps/chaingraph-frontend/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-frontend",
33
"type": "module",
4-
"version": "0.6.35",
4+
"version": "0.6.36",
55
"private": false,
66
"description": "Frontend application for the Chaingraph project",
77
"license": "BUSL-1.1",
@@ -45,8 +45,8 @@
4545
"@trpc/react-query": "^11.7.2",
4646
"@trpc/server": "^11.7.2",
4747
"@trpc/tanstack-react-query": "^11.7.2",
48-
"@xyflow/react": "^12.8.6",
49-
"@xyflow/system": "^0.0.70",
48+
"@xyflow/react": "^12.10.0",
49+
"@xyflow/system": "^0.0.74",
5050
"react": "^19.2.0",
5151
"react-dom": "^19.2.0",
5252
"superjson": "^2.2.5",
@@ -91,8 +91,8 @@
9191
"@trpc/server": "^11.7.2",
9292
"@trpc/tanstack-react-query": "^11.7.2",
9393
"@types/color": "^4.2.0",
94-
"@xyflow/react": "^12.8.6",
95-
"@xyflow/system": "^0.0.70",
94+
"@xyflow/react": "^12.10.0",
95+
"@xyflow/system": "^0.0.74",
9696
"add": "^2.0.6",
9797
"ahooks": "^3.9.5",
9898
"class-variance-authority": "^0.7.1",

apps/chaingraph-frontend/src/components/flow/Flow.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
} from '@xyflow/react'
1515
import type { Viewport } from '@xyflow/system'
1616
import { NodeRegistry } from '@badaitech/chaingraph-types'
17-
import { Background, ReactFlow, useReactFlow } from '@xyflow/react'
17+
import { Background, ReactFlow, useNodesInitialized, useReactFlow } from '@xyflow/react'
1818
import { useUnit } from 'effector-react'
1919
import { AnimatePresence } from 'framer-motion'
2020
import { memo, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'
@@ -129,6 +129,17 @@ function Flow({
129129
onNodeDragStop,
130130
} = useFlowCallbacks()
131131

132+
const nodesInitialized = useNodesInitialized({
133+
includeHiddenNodes: false,
134+
})
135+
136+
useEffect(() => {
137+
if (nodesInitialized) {
138+
// console.log('[Flow] Nodes initialized:', nodesInitialized)
139+
// setLayoutedNodes(yourLayoutingFunction(getNodes()));
140+
}
141+
}, [nodesInitialized])
142+
132143
// State for a context menu
133144
const [contextMenu, setContextMenu] = useState<{ x: number, y: number } | null>(null)
134145

apps/chaingraph-frontend/src/components/flow/hooks/useNodeChanges.ts

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { NodeChange } from '@xyflow/react'
1111
import { useUnit } from 'effector-react'
1212
import { useCallback } from 'react'
1313
import { $activeFlowMetadata } from '@/store/flow'
14-
import { $nodes, removeNodeFromFlow, updateNodePosition, updateNodeUI } from '@/store/nodes'
14+
import { $nodes, removeNodeFromFlow, updateNodePosition, updateNodePositionOnly, updateNodeUI } from '@/store/nodes'
1515
import { positionInterpolator } from '@/store/nodes/position-interpolation-advanced'
1616
import { roundPosition } from './useFlowUtils'
1717

@@ -59,6 +59,13 @@ export function useNodeChanges() {
5959

6060
positionInterpolator.clearNodeState(node.id)
6161

62+
// Use position-only update during drag to avoid $nodes cascade
63+
updateNodePositionOnly({
64+
nodeId: change.id,
65+
position: roundPosition(change.position as Position),
66+
})
67+
68+
// Also trigger server sync (throttled separately at 500ms)
6269
updateNodePosition({
6370
flowId: activeFlow.id!,
6471
nodeId: change.id,
@@ -70,41 +77,15 @@ export function useNodeChanges() {
7077

7178
case 'dimensions':
7279
{
73-
const node = currentNodes[change.id]
74-
if (!node)
75-
return
76-
77-
if (node.metadata.category === 'group') {
78-
// ignore group node dimension changes, is is handled by the group node itself
79-
return
80-
}
81-
82-
if (!change.dimensions || !change.dimensions.width || !change.dimensions.height) {
83-
console.warn(`[useNodeChanges] Invalid dimensions change:`, change)
84-
return
85-
}
86-
const isSameDimensions
87-
= node.metadata.ui?.dimensions?.width === change.dimensions.width
88-
&& node.metadata.ui?.dimensions?.height === change.dimensions.height
89-
90-
const isNodeDimensionInitialized
91-
= node.metadata.ui?.dimensions !== undefined
92-
&& node.metadata.ui?.dimensions?.width !== undefined
93-
&& node.metadata.ui?.dimensions?.height !== undefined
94-
95-
if (isSameDimensions) { // || !isNodeDimensionInitialized) {
96-
return
97-
}
98-
99-
updateNodeUI({
100-
flowId: activeFlow.id!,
101-
nodeId: change.id,
102-
ui: {
103-
dimensions: change.dimensions,
104-
},
105-
version: node.getVersion(),
106-
})
107-
80+
// SKIP all dimension changes from XYFlow's onNodesChange
81+
// XYFlow reports measured DOM sizes which conflict with resize handle positions
82+
//
83+
// Dimension sources are now:
84+
// - Width: NodeResizeControl onResize handler (user intent)
85+
// - Height: useElementResize content detection (for regular nodes)
86+
// - Both: NodeResizer onResize handler (for GroupNode)
87+
//
88+
// GroupNode is also skipped here as it handles dimensions in its own component
10889
break
10990
}
11091

@@ -117,7 +98,7 @@ export function useNodeChanges() {
11798
updateNodeUI({
11899
flowId: activeFlow.id!,
119100
nodeId: change.id,
120-
version: node.getVersion() + 1,
101+
version: 0,
121102
ui: {
122103
state: {
123104
isSelected: change.selected,

0 commit comments

Comments
 (0)