-
Notifications
You must be signed in to change notification settings - Fork 490
fix(vueNodes): sync node size changes from extensions to Vue components #7993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
94facc9
ca656ce
779d4b3
4adc54f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,10 +5,8 @@ import { PREFIX, SEPARATOR } from '@/constants/groupNodeConstants' | |||||||||||||||||||||||||||||||||||
| import { LitegraphLinkAdapter } from '@/renderer/core/canvas/litegraph/litegraphLinkAdapter' | ||||||||||||||||||||||||||||||||||||
| import type { LinkRenderContext } from '@/renderer/core/canvas/litegraph/litegraphLinkAdapter' | ||||||||||||||||||||||||||||||||||||
| import { getSlotPosition } from '@/renderer/core/canvas/litegraph/slotCalculations' | ||||||||||||||||||||||||||||||||||||
| import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations' | ||||||||||||||||||||||||||||||||||||
| import { layoutStore } from '@/renderer/core/layout/store/layoutStore' | ||||||||||||||||||||||||||||||||||||
| import { LayoutSource } from '@/renderer/core/layout/types' | ||||||||||||||||||||||||||||||||||||
| import { removeNodeTitleHeight } from '@/renderer/core/layout/utils/nodeSizeUtil' | ||||||||||||||||||||||||||||||||||||
| import { forEachNode } from '@/utils/graphTraversalUtil' | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import { CanvasPointer } from './CanvasPointer' | ||||||||||||||||||||||||||||||||||||
|
|
@@ -2370,8 +2368,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| const cloned = items?.created[0] as LGraphNode | undefined | ||||||||||||||||||||||||||||||||||||
| if (!cloned) return | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| cloned.pos[0] += 5 | ||||||||||||||||||||||||||||||||||||
| cloned.pos[1] += 5 | ||||||||||||||||||||||||||||||||||||
| cloned.setPos(cloned.pos[0] + 5, cloned.pos[1] + 5) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (this.allow_dragnodes) { | ||||||||||||||||||||||||||||||||||||
| pointer.onDragStart = (pointer) => { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -4055,31 +4052,30 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Adjust positions | ||||||||||||||||||||||||||||||||||||
| // Adjust positions - use move/setPos to ensure layout store is updated | ||||||||||||||||||||||||||||||||||||
| const dx = position[0] - offsetX | ||||||||||||||||||||||||||||||||||||
| const dy = position[1] - offsetY | ||||||||||||||||||||||||||||||||||||
| for (const item of created) { | ||||||||||||||||||||||||||||||||||||
| item.pos[0] += position[0] - offsetX | ||||||||||||||||||||||||||||||||||||
| item.pos[1] += position[1] - offsetY | ||||||||||||||||||||||||||||||||||||
| if (item instanceof LGraphNode) { | ||||||||||||||||||||||||||||||||||||
| item.setPos(item.pos[0] + dx, item.pos[1] + dy) | ||||||||||||||||||||||||||||||||||||
| } else if (item instanceof Reroute) { | ||||||||||||||||||||||||||||||||||||
| item.move(dx, dy) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
4058
to
4064
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find and examine Reroute class definition
echo "=== Searching for Reroute class ==="
fd -t f "Reroute" src/lib/litegraph/src/
echo -e "\n=== Checking Reroute.ts for move() method ==="
rg -n "^\s*(move|setPos)\s*\(" src/lib/litegraph/src/Reroute.ts -A 5 2>/dev/null || echo "File not found or no matches"Repository: Comfy-Org/ComfyUI_frontend Length of output: 495 🏁 Script executed: #!/bin/bash
# Find and examine LGraphGroup class definition
echo "=== Searching for LGraphGroup class ==="
fd -t f "LGraphGroup" src/lib/litegraph/src/
echo -e "\n=== Checking LGraphGroup.ts for move() method ==="
rg -n "^\s*(move|setPos)\s*\(" src/lib/litegraph/src/LGraphGroup.ts -A 5 2>/dev/null || echo "File not found or no matches"Repository: Comfy-Org/ComfyUI_frontend Length of output: 523 🏁 Script executed: #!/bin/bash
# Search for layoutStore usage related to reroutes
echo "=== Searching for layoutStore and queryRerouteAtPoint ==="
rg -n "layoutStore\.|queryRerouteAtPoint|updateReroute" src/lib/litegraph/src --max-count 20
echo -e "\n=== Checking for move() implementations in all litegraph source files ==="
rg -n "^\s*move\s*\(" src/lib/litegraph/src -A 3 --max-count 30Repository: Comfy-Org/ComfyUI_frontend Length of output: 3304 🏁 Script executed: #!/bin/bash
# Get full Reroute.move() implementation
echo "=== Full Reroute.move() implementation ==="
sed -n '413,450p' src/lib/litegraph/src/Reroute.ts
echo -e "\n=== Full LGraphNode.move() implementation ==="
sed -n '2002,2050p' src/lib/litegraph/src/LGraphNode.ts
echo -e "\n=== Full LGraphGroup.move() implementation ==="
sed -n '227,280p' src/lib/litegraph/src/LGraphGroup.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 4515 🏁 Script executed: #!/bin/bash
# Check how layoutStore is updated after pos changes
echo "=== Search for updateReroute or similar in layoutStore context ==="
rg -n "updateReroute|invalidate.*[Rr]eroute|setReroutePos" src/lib/litegraph/src/
echo -e "\n=== Check Reroute setter/getter for pos ==="
rg -n "^\s*(get|set)\s+pos\|^\s*pos\s*=" src/lib/litegraph/src/Reroute.ts -A 3Repository: Comfy-Org/ComfyUI_frontend Length of output: 383 🏁 Script executed: #!/bin/bash
# Check the current code at lines 4013-4022 in context to see how items are used after positioning
echo "=== Context around lines 4013-4022 in LGraphCanvas.ts ==="
sed -n '4000,4050p' src/lib/litegraph/src/LGraphCanvas.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 1616 Use Proposed change (routes all items through their own movement API)- for (const item of created) {
- const newX = item.pos[0] + position[0] - offsetX
- const newY = item.pos[1] + position[1] - offsetY
- if (item instanceof LGraphNode) {
- item.setPos(newX, newY)
- } else {
- item.pos[0] = newX
- item.pos[1] = newY
- }
- }
+ const deltaX = position[0] - offsetX
+ const deltaY = position[1] - offsetY
+ for (const item of created) {
+ item.move(deltaX, deltaY, true)
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jtydhr88 Does this comment seem plausible?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // TODO: Report failures, i.e. `failedNodes` | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const newPositions = created | ||||||||||||||||||||||||||||||||||||
| .filter((item): item is LGraphNode => item instanceof LGraphNode) | ||||||||||||||||||||||||||||||||||||
| .map((node) => { | ||||||||||||||||||||||||||||||||||||
| const fullHeight = node.size?.[1] ?? 200 | ||||||||||||||||||||||||||||||||||||
| const layoutHeight = LiteGraph.vueNodesMode | ||||||||||||||||||||||||||||||||||||
| ? removeNodeTitleHeight(fullHeight) | ||||||||||||||||||||||||||||||||||||
| : fullHeight | ||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||
| nodeId: String(node.id), | ||||||||||||||||||||||||||||||||||||
| bounds: { | ||||||||||||||||||||||||||||||||||||
| x: node.pos[0], | ||||||||||||||||||||||||||||||||||||
| y: node.pos[1], | ||||||||||||||||||||||||||||||||||||
| width: node.size?.[0] ?? 100, | ||||||||||||||||||||||||||||||||||||
| height: layoutHeight | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| .map((node) => ({ | ||||||||||||||||||||||||||||||||||||
| nodeId: String(node.id), | ||||||||||||||||||||||||||||||||||||
| bounds: { | ||||||||||||||||||||||||||||||||||||
| x: node.pos[0], | ||||||||||||||||||||||||||||||||||||
| y: node.pos[1], | ||||||||||||||||||||||||||||||||||||
| width: node.size?.[0] ?? 100, | ||||||||||||||||||||||||||||||||||||
| height: node.size?.[1] ?? 200 | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
| })) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (newPositions.length) layoutStore.setSource(LayoutSource.Canvas) | ||||||||||||||||||||||||||||||||||||
| layoutStore.batchUpdateNodeBounds(newPositions) | ||||||||||||||||||||||||||||||||||||
|
|
@@ -6281,7 +6277,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| options | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||
| node.pos[0] -= node.size[0] * 0.5 | ||||||||||||||||||||||||||||||||||||
| node.setPos(node.pos[0] - node.size[0] * 0.5, node.pos[1]) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||
|
|
@@ -8569,27 +8565,14 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| * Apply batched node position updates | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| private applyNodePositionUpdates( | ||||||||||||||||||||||||||||||||||||
| nodesToMove: Array<{ node: LGraphNode; newPos: { x: number; y: number } }>, | ||||||||||||||||||||||||||||||||||||
| mutations: ReturnType<typeof useLayoutMutations> | ||||||||||||||||||||||||||||||||||||
| nodesToMove: Array<{ node: LGraphNode; newPos: { x: number; y: number } }> | ||||||||||||||||||||||||||||||||||||
| ): void { | ||||||||||||||||||||||||||||||||||||
| for (const { node, newPos } of nodesToMove) { | ||||||||||||||||||||||||||||||||||||
| // Update LiteGraph position first so next drag uses correct base position | ||||||||||||||||||||||||||||||||||||
| node.pos[0] = newPos.x | ||||||||||||||||||||||||||||||||||||
| node.pos[1] = newPos.y | ||||||||||||||||||||||||||||||||||||
| // Then update layout store which will update Vue nodes | ||||||||||||||||||||||||||||||||||||
| mutations.moveNode(node.id, newPos) | ||||||||||||||||||||||||||||||||||||
| // setPos automatically syncs to layout store | ||||||||||||||||||||||||||||||||||||
| node.setPos(newPos.x, newPos.y) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
jtydhr88 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
jtydhr88 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * Initialize layout mutations with Canvas source | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| private initLayoutMutations(): ReturnType<typeof useLayoutMutations> { | ||||||||||||||||||||||||||||||||||||
| const mutations = useLayoutMutations() | ||||||||||||||||||||||||||||||||||||
| mutations.setSource(LayoutSource.Canvas) | ||||||||||||||||||||||||||||||||||||
| return mutations | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * Collect all nodes that are children of groups in the selection | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
|
|
@@ -8637,7 +8620,6 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| deltaX: number, | ||||||||||||||||||||||||||||||||||||
| deltaY: number | ||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||
| const mutations = this.initLayoutMutations() | ||||||||||||||||||||||||||||||||||||
| const nodesInMovingGroups = this.collectNodesInGroups(allItems) | ||||||||||||||||||||||||||||||||||||
| const nodesToMove: NewNodePosition[] = [] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -8663,12 +8645,11 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Now apply all the node moves at once | ||||||||||||||||||||||||||||||||||||
| this.applyNodePositionUpdates(nodesToMove, mutations) | ||||||||||||||||||||||||||||||||||||
| this.applyNodePositionUpdates(nodesToMove) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| repositionNodesVueMode(nodesToReposition: NewNodePosition[]) { | ||||||||||||||||||||||||||||||||||||
| const mutations = this.initLayoutMutations() | ||||||||||||||||||||||||||||||||||||
| this.applyNodePositionUpdates(nodesToReposition, mutations) | ||||||||||||||||||||||||||||||||||||
| this.applyNodePositionUpdates(nodesToReposition) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pasted groups aren’t offset with the paste position.
createdincludesLGraphGroup, but the offset loop only moves nodes and reroutes, so pasted groups will stay at the original coordinates. Please move groups alongside nodes/reroutes.🔧 Suggested fix
for (const item of created) { if (item instanceof LGraphNode) { item.setPos(item.pos[0] + dx, item.pos[1] + dy) + } else if (item instanceof LGraphGroup) { + item.move(dx, dy, true) } else if (item instanceof Reroute) { item.move(dx, dy) } }🤖 Prompt for AI Agents