Skip to content

Commit 8f44f95

Browse files
committed
fix: attribute batched layout operations to their real source
batchMoveNodes stamped every operation Vue regardless of the mutations instance it came from, and the paste path passed Vue by hand, so arrange and paste reported themselves as Vue-originated. LGraphNode.vue skips its CSS-var rewrite for Vue-sourced changes, so both paths silently opted out of it.
1 parent 54ff310 commit 8f44f95

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/lib/litegraph/src/LGraphCanvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4370,7 +4370,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
43704370

43714371
const rootGraphId = graph.rootGraph.id
43724372
layoutStore.batchUpdateNodeBounds(rootGraphId, newPositions, {
4373-
source: LayoutSource.Vue
4373+
source: LayoutSource.Canvas
43744374
})
43754375

43764376
// Bring cloned/pasted nodes to front so they render above the originals

src/renderer/core/layout/operations/layoutMutations.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ describe('batchMoveNodes', () => {
239239
}
240240
)
241241
})
242+
243+
it('reports the source it was built with, not the batch transport', async () => {
244+
const sources: LayoutSource[] = []
245+
const stop = layoutStore.onChange(({ source }) => sources.push(source))
246+
onTestFinished(stop)
247+
248+
useLayoutMutations(LayoutSource.Canvas).batchMoveNodes(GRAPH, [
249+
{ nodeId: NODE_1, position: { x: 50, y: 60 } }
250+
])
251+
await vi.waitFor(() => expect(sources).not.toHaveLength(0))
252+
253+
expect(sources).toEqual([LayoutSource.Canvas])
254+
})
242255
})
243256

244257
describe('bringNodeToFront', () => {

src/renderer/core/layout/operations/layoutMutations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import type { NodeId } from '@/types/nodeId'
1111
import type { UUID } from '@/utils/uuid'
1212
import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
1313
import type { GroupId } from '@/types/groupId'
14-
import { LayoutSource } from '@/renderer/core/layout/types'
1514
import type {
1615
GroupLayout,
1716
LayoutOperationResult,
17+
LayoutSource,
1818
NodeLayout,
1919
Point,
2020
RerouteId,
@@ -133,7 +133,7 @@ export function useLayoutMutations(source: LayoutSource): LayoutMutations {
133133

134134
if (nodeBoundsUpdates.length === 0) return
135135
layoutStore.batchUpdateNodeBounds(rootGraphId, nodeBoundsUpdates, {
136-
source: LayoutSource.Vue
136+
source
137137
})
138138
}
139139

0 commit comments

Comments
 (0)