Comfy-Org / Comfy-Org/ComfyUI_frontend

Avoid duplicate placeholder link reconnections during API JSON import

Open
#14,736 1 comment 1 reaction 1 assignee Claimed by @christian-byrne View on GitHub
area:links perf:speed
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

Reduce redundant placeholder-input reconnection during API JSON import.

`ComfyApp.loadApiJson` currently calls `processNodeInputs` twice, with
`arrange()` between the calls. This pattern predates pull request #14555.
After placeholder nodes for uninstalled node types were added, the second pass
processes wildcard inputs that are already connected.

The second pass calls `disconnectInput` and then reconnects the same input with
a new `linkId`. This fires `onConnectionsChange` twice for each affected
placeholder input. The final serialized workflow remains correct because
`node.last_serialization.inputs` is refreshed in `processNodeInputs`.

Also include the `useNodeReplacement.ts` cleanup identified in the review body
of pull request #14555.

## Rationale

The current behavior produces redundant work and duplicate connection-change
events. It does not produce incorrect serialized output.

Do not change the double `processNodeInputs` plus `arrange()` sequence without
validating its link-resolution behavior. This sequence is pre-existing and may
have compatibility requirements.

## Affected areas

- `src/scripts/app.ts`: `ComfyApp.loadApiJson` and `processNodeInputs`
- `useNodeReplacement.ts` cleanup identified during review of pull request
#14555

## Acceptance criteria

- API JSON imports do not disconnect and reconnect already-correct placeholder
wildcard input links solely because of the second input-processing pass.
- Link resolution remains compatible with existing API JSON imports.
- `onConnectionsChange` does not receive duplicate events for unchanged
placeholder input connections.
- Placeholder serialization still preserves input links and literal values.
- The `useNodeReplacement.ts` cleanup from the pull request review is included
or is tracked with a clear dependency.
- Add focused regression tests for the selected behavior.

## Context

Requested by @christian-byrne.

- Pull request: https://github.com/Comfy-Org/ComfyUI_frontend/pull/14555
- Review discussion: https://github.com/Comfy-Org/ComfyUI_frontend/pull/14555#discussion_r3708963300

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.