Skip to content

Commit d62923f

Browse files
benceruleanlugithub-actions
authored andcommitted
Increase vue slot/link functionality (#5710)
Increase functionality for slots and links, covered with playwright tests. - Allow for reroute anchors to work when dragging from input slot - Allow for dragging existing links from input slot - Allow for ctrl/command + alt to create new link from input slot - Allow shift to drag all connected links on output slot - Connect links with reroutes (only when dragged from vue slot) - Dragging input to input drags existing link - Dropping an input link back on its slot restores the original connection - Ctrl+alt drag from an input starts a fresh link - Should reuse the existing origin when dragging an input link - Shift-dragging an output with multiple links should drag all links - Rerouted input drag preview remains anchored to reroute - Rerouted output shift-drag preview remains anchored to reroute The double rendering system for links being dragged, it works right now, maybe they can be coalesced later. Edit: As in the adapter, can be removed in a followup PR Also, it's known that more features will arrive in smaller PRs, this PR actually should've been much smaller. The next ones coming up are drop on canvas support, snap to node, type compatibility highlighting, and working with subgraphs. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5710-Increase-vue-slot-link-functionality-2756d73d3650814f8995f7782244803b) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <[email protected]>
1 parent 61e765c commit d62923f

10 files changed

+37
-274
lines changed

browser_tests/tests/vueNodes/interactions/links/linkInteraction.spec.ts

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -693,99 +693,4 @@ test.describe('Vue Node Link Interaction', () => {
693693
if (shiftHeld) await comfyPage.page.keyboard.up('Shift').catch(() => {})
694694
}
695695
})
696-
697-
test('should snap to node center while dragging and link on drop', async ({
698-
comfyPage,
699-
comfyMouse
700-
}) => {
701-
const clipNode = (await comfyPage.getNodeRefsByType('CLIPTextEncode'))[0]
702-
const samplerNode = (await comfyPage.getNodeRefsByType('KSampler'))[0]
703-
expect(clipNode && samplerNode).toBeTruthy()
704-
705-
// Start drag from CLIP output[0]
706-
const clipOutputCenter = await getSlotCenter(
707-
comfyPage.page,
708-
clipNode.id,
709-
0,
710-
false
711-
)
712-
713-
// Drag to the visual center of the KSampler Vue node (not a slot)
714-
const samplerVue = comfyPage.vueNodes.getNodeLocator(String(samplerNode.id))
715-
await expect(samplerVue).toBeVisible()
716-
const samplerCenter = await getCenter(samplerVue)
717-
718-
await comfyMouse.move(clipOutputCenter)
719-
await comfyMouse.drag(samplerCenter)
720-
721-
// During drag, the preview should snap/highlight a compatible input on KSampler
722-
await expect(comfyPage.canvas).toHaveScreenshot('vue-node-snap-to-node.png')
723-
724-
// Drop to create the link
725-
await comfyMouse.drop()
726-
await comfyPage.nextFrame()
727-
728-
// Validate a link was created to one of KSampler's compatible inputs (1 or 2)
729-
const linkOnInput1 = await getInputLinkDetails(
730-
comfyPage.page,
731-
samplerNode.id,
732-
1
733-
)
734-
const linkOnInput2 = await getInputLinkDetails(
735-
comfyPage.page,
736-
samplerNode.id,
737-
2
738-
)
739-
740-
const linked = linkOnInput1 ?? linkOnInput2
741-
expect(linked).not.toBeNull()
742-
expect(linked?.originId).toBe(clipNode.id)
743-
expect(linked?.targetId).toBe(samplerNode.id)
744-
})
745-
746-
test('should snap to a specific compatible slot when targeting it', async ({
747-
comfyPage,
748-
comfyMouse
749-
}) => {
750-
const clipNode = (await comfyPage.getNodeRefsByType('CLIPTextEncode'))[0]
751-
const samplerNode = (await comfyPage.getNodeRefsByType('KSampler'))[0]
752-
expect(clipNode && samplerNode).toBeTruthy()
753-
754-
// Drag from CLIP output[0] to KSampler input[2] (third slot) which is the
755-
// second compatible input for CLIP
756-
const clipOutputCenter = await getSlotCenter(
757-
comfyPage.page,
758-
clipNode.id,
759-
0,
760-
false
761-
)
762-
const samplerInput3Center = await getSlotCenter(
763-
comfyPage.page,
764-
samplerNode.id,
765-
2,
766-
true
767-
)
768-
769-
await comfyMouse.move(clipOutputCenter)
770-
await comfyMouse.drag(samplerInput3Center)
771-
772-
// Expect the preview to show snapping to the targeted slot
773-
await expect(comfyPage.canvas).toHaveScreenshot('vue-node-snap-to-slot.png')
774-
775-
// Finish the connection
776-
await comfyMouse.drop()
777-
await comfyPage.nextFrame()
778-
779-
const linkDetails = await getInputLinkDetails(
780-
comfyPage.page,
781-
samplerNode.id,
782-
2
783-
)
784-
expect(linkDetails).not.toBeNull()
785-
expect(linkDetails).toMatchObject({
786-
originId: clipNode.id,
787-
targetId: samplerNode.id,
788-
targetSlot: 2
789-
})
790-
})
791696
})
53.5 KB
Loading
50.8 KB
Loading
51.4 KB
Loading
52.8 KB
Loading
55.3 KB
Loading
53.3 KB
Loading

src/renderer/core/canvas/links/slotLinkPreviewRenderer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) {
4949
const renderLinks = createLinkConnectorAdapter()?.renderLinks
5050
if (!renderLinks || renderLinks.length === 0) return
5151

52-
const to: Readonly<Point> = state.candidate?.compatible
53-
? [state.candidate.layout.position.x, state.candidate.layout.position.y]
54-
: [pointer.canvas.x, pointer.canvas.y]
52+
const to: Readonly<Point> = [pointer.canvas.x, pointer.canvas.y]
5553
ctx.save()
5654
for (const link of renderLinks) {
5755
const startDir = link.fromDirection ?? LinkDirection.RIGHT

0 commit comments

Comments
 (0)