Skip to content

Preserve placeholder connections when resolving to multiple clips#277

Open
jakubjezek001 wants to merge 7 commits into
developfrom
enhancement/template-builder-multiple-resolved-connected-nodes
Open

Preserve placeholder connections when resolving to multiple clips#277
jakubjezek001 wants to merge 7 commits into
developfrom
enhancement/template-builder-multiple-resolved-connected-nodes

Conversation

@jakubjezek001

@jakubjezek001 jakubjezek001 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Changelog Description

When a Loader Placeholder resolves to multiple clips without explicit "Input"/"Output" nodes, the system now preserves the original upstream and downstream connections by falling back to the last connectable node. Previously, placeholders resolving to multiple items would disconnect from the node graph, leaving all loaded clips floating. This fix ensures the first resolved item maintains the placeholder's original connections while additional items remain unconnected as intended.

The change addresses the root cause where get_group_io_nodes() returns None for both input/output when multiple clips lack specifically named IO nodes. The fallback logic identifies connectable nodes (those with available inputs or outputs) and uses the last one to maintain graph connectivity.

Additional info

The fix modifies the _set_loaded_connections method in the placeholder loader to include fallback logic when IO nodes are unavailable:

  • Filters loaded nodes for those with maxInputs() > 0 or maxOutputs() > 0
  • Uses the last connectable node as fallback for both input and output connections
  • Preserves existing behavior when proper IO nodes exist
  • Also improves docstring formatting for better code clarity

Testing notes:

  1. Create a Loader Placeholder in Nuke that resolves to multiple clips (e.g., multiple versions of a render)
  2. Connect nodes upstream and downstream of the placeholder
  3. Resolve the placeholder to load all matching clips
  4. Verify that the first loaded clip maintains the upstream/downstream connections
  5. Verify that additional loaded clips appear unconnected in the node graph

Dependency

Close #109
AY-7741

When multiple clips are loaded without explicit "Input"/"Output" nodes,
fall back to the last connectable node to preserve upstream/downstream
connections. Also improve docstring formatting.
@jakubjezek001 jakubjezek001 added the type: bug Something isn't working label Jun 26, 2026
@jakubjezek001 jakubjezek001 changed the title Fix placeholder node connections when IO nodes unavailable Enhancement: Preserve placeholder connections when resolving to multiple clips Jun 26, 2026
@jakubjezek001 jakubjezek001 self-assigned this Jun 26, 2026
@jakubjezek001 jakubjezek001 added the sponsored This is directly sponsored by a client or community member label Jun 26, 2026
@jakubjezek001 jakubjezek001 reopened this Jun 26, 2026
@jakubjezek001

Copy link
Copy Markdown
Member Author

closed by accindent

@jakubjezek001
jakubjezek001 marked this pull request as ready for review June 26, 2026 11:03
@jakubjezek001 jakubjezek001 changed the title Enhancement: Preserve placeholder connections when resolving to multiple clips Preserve placeholder connections when resolving to multiple clips Jun 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Nuke Loader Placeholder behavior when it resolves to multiple clips by attempting to preserve the original node-graph connections (upstream/downstream) instead of leaving all loaded nodes disconnected.

Changes:

  • Updates _set_loaded_connections to add fallback logic when get_group_io_nodes() can’t find explicitly named “Input”/“Output” nodes for multi-clip loads.
  • Adjusts the method docstring/comment formatting for clarity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/ayon_nuke/plugins/workfile_build/load_placeholder.py Outdated

@moonyuet moonyuet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well for the load placeholder with clip loader
https://github.com/user-attachments/assets/aa609a5c-7613-4eb4-bce5-e86ef6556be6

It also works with load geo(input and output nodes).

Recording.2026-06-26.200953.mp4

Comment thread client/ayon_nuke/plugins/workfile_build/load_placeholder.py Outdated
@BigRoy

BigRoy commented Jul 13, 2026

Copy link
Copy Markdown
Member

What's the status here? @jakubjezek001

@jakubjezek001
jakubjezek001 requested a review from BigRoy July 15, 2026 14:26
Comment on lines +371 to +381
if input_node is None:
input_candidates = [
n for n in connectable if n.maxInputs() > 0]
input_node = (
input_candidates[0] if input_candidates else None)

if output_node is None:
output_candidates = [
n for n in connectable if n.maxOutputs() > 0]
output_node = (
output_candidates[0] if output_candidates else None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you load a group that has say 5 nodes, and they are connected in one stream, like A-B-C-D-E. The input would be A, the output would be E. Right?

In this logic here, the input and output would be A - because it allows more inputs and outputs than zero and has the first name (sorted). I'm still confused by this logic.

It should really be that we prefer nodes that are at the start of the graph, e.g. have no inputs but do have outputs. (so they must be somewhere at the start of it) The same goes for outputs, it must be a node that preferably has no output connections (within the loaded nodes), allows to have outputs and if there are two nodes for which this is true prefer the one that does have input connections. So that if for whatever reason you load a group that has a separate floating node C, we'd still take the one at the end of a stream of nodes:

A-B
C

☝️ pick B?

Or what's the reasoning you're after @jakubjezek001 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before it was not connecting any node by mistake. So if placeholder was connected and was resolving in multiple loadable containers - before it would not connect anything at all. But now after the fix it will connect at least single loaded node.

Try it and will see.

@BigRoy BigRoy Jul 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may work consistently for a single node, but not for a graph of nodes as I'm trying to explain. If we're solving just the single node case - then the logic should consider it's only a single node. Then no need for the sorting and iterating. Then just:

if len(nodes) == 1:
    node = nodes[0]
    if node.maxInputs() > 0:
        input_node = node
    if node.maxOutputs() > 0:
        output_node = node

Right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sponsored This is directly sponsored by a client or community member type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AY-7741_placeholder resolved with multiple items turns into disconnected

5 participants