Repository navigation
Conversation
📝 WalkthroughWalkthroughAdds a subgraph drag bridge linking canvas-initiated subgraph IO drags to the Vue slot-drag UI state, introduces events to intercept canvas drops, emits slot-link change events on subgraph IO connect/disconnect, and updates slot hover/snap handling and visuals for live feedback. Changes
Sequence DiagramsequenceDiagram
participant Canvas as Canvas
participant LinkConnector as LinkConnector
participant Bridge as SubgraphDragBridge
participant UIState as Slot UI State
participant Slot as Slot Component
Canvas->>LinkConnector: start drag from Subgraph IO
LinkConnector->>Bridge: emit "connecting" { connectingTo }
Bridge->>Bridge: create adapter & compute compatibility
Bridge->>UIState: begin drag (set candidate & snap position)
Canvas->>LinkConnector: pointer move events
LinkConnector->>Bridge: forward pointer updates
Bridge->>Bridge: RAF pointer tracking -> resolve target
Bridge->>UIState: update candidate & snap position
UIState->>Slot: apply `lg-slot--snap-target` class (visual highlight)
Canvas->>LinkConnector: drop event
LinkConnector->>Bridge: emit "before-drop-on-canvas"
Bridge->>Bridge: connectToCandidate() (if compatible)
Bridge->>Canvas: perform connection / end drag
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| * (canvas-drawn), the Vue slot components need to know about it so they | ||
| * can dim incompatible slots, snap links, and highlight compatible targets. | ||
| */ | ||
| export function useSubgraphDragBridge() { |
There was a problem hiding this comment.
This composable exists because SubgraphInput/Output nodes are canvas-drawn while regular nodes are Vue-rendered — during a canvas-initiated drag, pointer capture is on the <canvas> element, so Vue slot components never receive hover events. The bridge listens to LinkConnector events and translates them into slotLinkDragUIState mutations so Vue components can react (dimming, snap highlights). The reverse direction (Vue-to-canvas) is handled in useSlotLinkInteraction.ts instead, since the pointermove handler already lives there.
🎭 Playwright: ⏳ Running... |
| : 'size-3 cursor-crosshair group-hover/slot:[--node-component-slot-dot-outline-opacity-mult:5] group-hover/slot:scale-125' | ||
| : 'size-3 cursor-crosshair group-hover/slot:[--node-component-slot-dot-outline-opacity-mult:5] group-hover/slot:scale-125 group-[.lg-slot--snap-target]/slot:[--node-component-slot-dot-outline-opacity-mult:5] group-[.lg-slot--snap-target]/slot:scale-125' | ||
| ) | ||
| ) |
There was a problem hiding this comment.
The group-hover/slot: variants work for Vue-to-Vue drags because useSlotLinkInteraction doesn't call setPointerCapture — CSS :hover fires naturally. But canvas-initiated drags call CanvasPointer.down() → setPointerCapture() on the <canvas>, which suppresses :hover on all other elements. The bridge toggles lg-slot--snap-target on the group/slot parent element to replicate the same visual effect programmatically.
| @@ -878,7 +880,10 @@ | |||
There was a problem hiding this comment.
Without this, releasing a canvas-initiated drag over a snapped Vue slot would miss the connection — dropOnNothing() does geometric hit-testing in canvas space which can't find Vue DOM nodes. The bridge listens for before-drop-on-canvas, connects to the snapped candidate from dragState, and calls preventDefault() to stop dropped-on-canvas (which would open the search dialog).
| connected: true, | ||
| linkId: link.id | ||
| }) | ||
| } |
There was a problem hiding this comment.
This trigger was missing — SubgraphInput.connect() establishes the link but never notified the Vue layer. Without it, widget input dots (the connected state indicator) don't appear until some other Vue action forces a re-render. Mirrors the pattern in LGraphNode.connect().
| if (wasPointerOver !== node.isPointerOver || node.isPointerOver) { | ||
| subgraphIOHoverChanged = true | ||
| } | ||
|
|
There was a problem hiding this comment.
This handles the reverse direction — Vue-to-canvas. During Vue-initiated drags, LGraphCanvas.processMouseMove() is never called, so SubgraphIONodeBase.onPointerMove() never fires. The synthetic event only needs canvasX/canvasY (already computed above). onPointerMove() handles both enter/leave transitions internally, so cleanup is automatic when the pointer moves away.
Bridge canvas-initiated subgraph IO drags to Vue slot drag state and vice versa, restoring slot dimming, proximity snap, dot highlights, and drop-to-connect across the canvas/Vue rendering boundary. Fixes Comfy-Org#9010
75a3585 to
376a1e9
Compare
|
Tagging @christian-byrne for current |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts (1)
545-547:⚠️ Potential issue | 🟡 MinorDuplicate
raf.flush()calls.There are two consecutive
raf.flush()calls on lines 545 and 547. This appears to be a copy-paste error.Proposed fix
raf.flush() - raf.flush() - if (!state.source) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts` around lines 545 - 547, The code contains duplicate consecutive raf.flush() calls in the useSlotLinkInteraction composable—remove the redundant second call so only a single raf.flush() remains; locate the raf.flush() invocations inside the useSlotLinkInteraction function and delete the duplicate line to avoid unnecessary double flushing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts`:
- Around line 545-547: The code contains duplicate consecutive raf.flush() calls
in the useSlotLinkInteraction composable—remove the redundant second call so
only a single raf.flush() remains; locate the raf.flush() invocations inside the
useSlotLinkInteraction function and delete the duplicate line to avoid
unnecessary double flushing.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/components/graph/GraphCanvas.vuesrc/lib/litegraph/src/canvas/LinkConnector.tssrc/lib/litegraph/src/infrastructure/LinkConnectorEventMap.tssrc/lib/litegraph/src/subgraph/SubgraphInput.tssrc/lib/litegraph/src/subgraph/SubgraphInputNode.tssrc/renderer/core/canvas/links/linkConnectorAdapter.tssrc/renderer/core/canvas/links/useSubgraphDragBridge.tssrc/renderer/extensions/vueNodes/components/SlotConnectionDot.vuesrc/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts
💤 Files with no reviewable changes (1)
- src/renderer/core/canvas/links/linkConnectorAdapter.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/lib/litegraph/src/infrastructure/LinkConnectorEventMap.ts
- src/lib/litegraph/src/subgraph/SubgraphInput.ts
- src/lib/litegraph/src/canvas/LinkConnector.ts
- src/components/graph/GraphCanvas.vue
- SubgraphInput.connect() fires node:slot-links:changed for widget inputs - SubgraphInputNode._disconnectNodeInput() fires on disconnect - LinkConnector.dropOnNothing() dispatches before-drop-on-canvas before dropped-on-canvas, and skips downstream when intercepted - Remove duplicate raf.flush() in finishInteraction
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts (1)
404-406: Avoid unconditional canvas dirtying during stable hover.At Line 404,
|| node.isPointerOvermakessubgraphIOHoverChangedtrue for every pointer move while hovering. That causes Line 439 to callsetDirty(true, true)even when nothing changed, which can hurt drag smoothness.♻️ Proposed fix
- if (wasPointerOver !== node.isPointerOver || node.isPointerOver) { + if (wasPointerOver !== node.isPointerOver) { subgraphIOHoverChanged = true }Also applies to: 437-439
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts` around lines 404 - 406, The hover-change flag is being set unconditionally while pointer is over a node due to the `|| node.isPointerOver` logic; update the condition so `subgraphIOHoverChanged` is only set when the hover state actually toggles (i.e., when `wasPointerOver !== node.isPointerOver`) and remove the `|| node.isPointerOver` clause; apply the same fix to the duplicate logic around the other block that sets `subgraphIOHoverChanged` (the lines near where `setDirty(true, true)` is called) so `setDirty` is only invoked when the hover state truly changed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/litegraph/src/subgraph/SubgraphIOSlotLinks.test.ts`:
- Around line 44-47: The test's negative assertion is too weak—replace
expect(triggerSpy).not.toHaveBeenCalledWith('node:slot-links:changed',
expect.anything()) with an assertion that no call used that event name (e.g.
collect triggerSpy.mock.calls.map(c => c[0]) and assert
.not.toContain('node:slot-links:changed')) so an emitted event with undefined
payload won't slip through; apply the identical change to the "disconnect
non-widget" test (the other assertion at lines 96-99) in
SubgraphIOSlotLinks.test.ts.
---
Nitpick comments:
In `@src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts`:
- Around line 404-406: The hover-change flag is being set unconditionally while
pointer is over a node due to the `|| node.isPointerOver` logic; update the
condition so `subgraphIOHoverChanged` is only set when the hover state actually
toggles (i.e., when `wasPointerOver !== node.isPointerOver`) and remove the `||
node.isPointerOver` clause; apply the same fix to the duplicate logic around the
other block that sets `subgraphIOHoverChanged` (the lines near where
`setDirty(true, true)` is called) so `setDirty` is only invoked when the hover
state truly changed.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lib/litegraph/src/canvas/LinkConnectorDropEvents.test.tssrc/lib/litegraph/src/subgraph/SubgraphIOSlotLinks.test.tssrc/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts
Replace weak negative assertions with explicit call-name filtering to catch false passes. Add docstrings to inner bridge functions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/core/canvas/links/useSubgraphDragBridge.ts (1)
70-75: Reuse a single adapter per drag session instead of recreating it per frame/event.
createLinkConnectorAdapter()is called on Line 70, again on Lines 117-118, and each RAF tick on Lines 181-182. Capturing one adapter for the active drag reduces churn and keeps candidate resolution/connect decisions consistent within the same drag session.♻️ Proposed refactor
export function useSubgraphDragBridge() { @@ function setupBridge(lgCanvas: LGraphCanvas): () => void { const linkConnector: LinkConnector = lgCanvas.linkConnector let teardownDrag: (() => void) | undefined + let activeAdapter: ReturnType<typeof createLinkConnectorAdapter> | null = null let isBridgeDrag = false @@ const adapter = createLinkConnectorAdapter() if (!adapter) return + activeAdapter = adapter @@ - teardownDrag = startPointerTracking(lgCanvas, linkConnector) + teardownDrag = startPointerTracking(lgCanvas, linkConnector, adapter) } @@ - const adapter = createLinkConnectorAdapter() - if (!adapter) return + const adapter = activeAdapter + if (!adapter) return @@ const onReset = () => { if (!isBridgeDrag) return @@ isBridgeDrag = false + activeAdapter = null endDrag() } @@ teardownDrag?.() teardownDrag = undefined + activeAdapter = null if (isBridgeDrag) { @@ function startPointerTracking( lgCanvas: LGraphCanvas, - linkConnector: LinkConnector + linkConnector: LinkConnector, + adapter: NonNullable<ReturnType<typeof createLinkConnectorAdapter>> ): () => void { @@ - const adapter = createLinkConnectorAdapter() - if (!adapter) return const graph = adapter.networkAlso applies to: 108-109, 117-123, 181-184
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/core/canvas/links/useSubgraphDragBridge.ts` around lines 70 - 75, The code currently calls createLinkConnectorAdapter multiple times during a drag session (e.g., where adapter and renderLink are captured), causing churn and inconsistent candidate resolution; change this to instantiate a single adapter when the drag session starts (store it on a stable ref/state inside useSubgraphDragBridge or the startDrag handler), reuse that stored adapter and its renderLinks (e.g., renderLink) in all subsequent handlers/RAF ticks, and only recreate or dispose the adapter when the drag ends or is cancelled so all calls no longer call createLinkConnectorAdapter repeatedly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/renderer/core/canvas/links/useSubgraphDragBridge.ts`:
- Around line 70-75: The code currently calls createLinkConnectorAdapter
multiple times during a drag session (e.g., where adapter and renderLink are
captured), causing churn and inconsistent candidate resolution; change this to
instantiate a single adapter when the drag session starts (store it on a stable
ref/state inside useSubgraphDragBridge or the startDrag handler), reuse that
stored adapter and its renderLinks (e.g., renderLink) in all subsequent
handlers/RAF ticks, and only recreate or dispose the adapter when the drag ends
or is cancelled so all calls no longer call createLinkConnectorAdapter
repeatedly.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/lib/litegraph/src/subgraph/SubgraphIOSlotLinks.test.tssrc/renderer/core/canvas/links/useSubgraphDragBridge.ts
|
Rebased onto main and addressed CodeRabbit feedback in #9838:
Great work on this @artokun — the bridge composable approach is clean and well-tested. 🎉 |
christian-byrne
left a comment
There was a problem hiding this comment.
LGTM — clean architecture bridging canvas and Vue pointer state. CodeRabbit nitpick addressed in adopted PR #9838. Tests look good.
|
Closing this one out since the work is continuing in #9838 on the updated branch. Please follow that PR for the active review and any follow-up changes. |

Summary
Subgraph IO nodes (canvas-drawn) have no visual feedback when dragging links to/from Vue-rendered nodes inside a subgraph — no slot dimming, no proximity snap, no dot highlight, and connections silently fail when releasing on a snapped candidate.
The core problem is that these two rendering layers don't share pointer state. Vue-initiated drags never call
SubgraphIONodeBase.onPointerMove(), and canvas-initiated drags never touch the VueslotLinkDragUIState. I couldn't find an existing mechanism to bridge this gap — if there's a built-in way to propagate drag context between canvas and Vue that I'm missing, I'd genuinely love to know about it. The approach here is a bridge composable (useSubgraphDragBridge) that translatesLinkConnectorevents into Vue drag state mutations, and a symmetric addition inprocessPointerMoveFramefor the reverse direction.Changes
useSubgraphDragBridgecomposable that listens toLinkConnectorevents (connecting,before-drop-on-canvas,reset) and drives the VueslotLinkDragUIState— enabling slot dimming, proximity snap, snap-target highlighting, and drop-to-connect for canvas-to-Vue drags. For Vue-to-canvas drags, extendedprocessPointerMoveFrameto callSubgraphIONodeBase.onPointerMove()with a synthetic event, driving the canvas-side slot dot highlights and link snapping. Also firesnode:slot-links:changedfromSubgraphInput.connect()andSubgraphInputNode._disconnectNodeInput()so widget input dots update immediately on cross-layer connections.Fixes #9010
Review Focus
useSlotLinkInteractionbut operates on document-level events since canvas pointer capture suppresses DOM hover states on Vue elements. I'd appreciate a close look at the lifecycle cleanup and theisBridgeDragownership guard.SlotConnectionDot.vueaddsgroup-[.lg-slot--snap-target]/slot:Tailwind variants alongside the existinggroup-hover/slot:ones. This is needed because canvas pointer capture suppresses CSS:hoveron Vue elements during canvas-initiated drags — the bridge adds/removes thelg-slot--snap-targetclass programmatically instead.before-drop-on-canvasevent onLinkConnectorfires beforedropped-on-canvasand is cancelable — the bridge intercepts it to connect to the snapped Vue candidate before the canvas search dialog would appear.Demo
Screen.Recording.2026-02-26.at.8.58.29.PM.mov
┆Issue is synchronized with this Notion page by Unito