Skip to content

Fix socket mapping and UI leakage in node editor - #175

Open
brettfxio wants to merge 2 commits into
mainfrom
fix-socket-mapping-error-4653557990281224505
Open

Fix socket mapping and UI leakage in node editor#175
brettfxio wants to merge 2 commits into
mainfrom
fix-socket-mapping-error-4653557990281224505

Conversation

@brettfxio

Copy link
Copy Markdown
Contributor

The issue was caused by a mismatch between the visually rendered sockets and the underlying Rete.js socket mapping, often resulting in an "off-by-one" effect where a connection to one input (like Master Audio In) would incorrectly map to another (like Master Gain CV).

I implemented a key-based mapping system by:

  • Uncommenting and fixing input/output rendering in the CustomNodeComponent to include data-socket-key.
  • Adding a robust cleanup phase in the node rendering pipeline to remove stale or duplicate DOM elements (both custom and React-rendered) before each render.
  • Adjusting the socket rendering hook to safely return context when a custom socket isn't found, preventing pipeline breakages.

Visual verification via Playwright confirmed that sockets now correctly associate with their intended labels and remain stable through multiple randomizations.


PR created automatically by Jules for task 4653557990281224505 started by @brettfxio

This commit resolves an off-by-one error where connecting to one socket
would visually or functionally trigger another. The fix involves:

1.  Updating `CustomNodeComponent` to render inputs and outputs with
    explicit `data-socket-key` attributes, ensuring key-based instead of
    index-based mapping.
2.  Enhancing the `rendered` node pipe to clean up existing custom
    controls and React-rendered elements before re-rendering,
    preventing DOM accumulation and visual inconsistencies.
3.  Updating the `render` socket pipe to handle fallback cases safely,
    ensuring Rete's internal mapping remains stable.

These changes ensure robust socket identification and a consistent UI
state across workspace randomizations and node updates.

Co-authored-by: brettfxio <105930054+brettfxio@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

This commit addresses the "off-by-one" socket mapping error and the
missing connection lines reported by the user.

Key changes:
1.  Modified the socket `render` pipe to tag Rete-generated socket
    elements with `data-socket-key` and `data-type`.
2.  Updated the node `rendered` pipe to preserve these original socket
    elements during UI cleanup.
3.  Implemented a relocation strategy that moves original sockets into
    the correct placeholders in the `CustomNodeComponent`.
4.  Added a call to `area.update('node', id)` after relocation to ensure
    Rete's connection plugin correctly recalculates and renders the
    connection paths (SVG lines).

This approach ensures that Rete.js's internal state and event listeners
stay synchronized with the visual layout, providing a stable and
correct mapping for all audio and CV ports.

Co-authored-by: brettfxio <105930054+brettfxio@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant