Repository navigation
Conversation
…tor#4792) When splicing a Map node onto a wire or inserting it into a chain, inspect the upstream element type and automatically instantiate and wire the corresponding Read node into the mapped input. If input 1 is already connected, preserve existing wiring.
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 3/5
- In
layout.rs, the connection guard treats onlyNodeInput::Nodeas connected, socreate_wirecan replace a mapped import with an auto-created Read node in a nested network. TreatNodeInput::Importas connected too. move_node_to_chain_startskips the helper when Map is first in a chain and on the import path, leaving Map without its required Read node. Call the helper on both paths.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="editor/src/messages/portfolio/document/utility_types/network_interface/layout.rs">
<violation number="1" location="editor/src/messages/portfolio/document/utility_types/network_interface/layout.rs:1163">
P1: `move_node_to_chain_start` skips this helper when Map is added as the first node in a chain, and also on its `import` path. Those direct wiring paths leave the Map without the required Read node; invoke the helper after those wirings as well.</violation>
<violation number="2" location="editor/src/messages/portfolio/document/utility_types/network_interface/layout.rs:1173">
P1: `NodeInput::Import` is a real wire connection, but this guard only treats `NodeInput::Node` as connected. In a nested network, the later `create_wire` replaces an existing mapped import with an auto-created Read node; preserve imports in this guard.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } | ||
|
|
||
| let mapped_input_connector = InputConnector::node_at_index(*node_id, 1); | ||
| if matches!(self.input_from_connector(&mapped_input_connector, network_path), Some(NodeInput::Node { .. })) { |
Contributor
There was a problem hiding this comment.
P1: NodeInput::Import is a real wire connection, but this guard only treats NodeInput::Node as connected. In a nested network, the later create_wire replaces an existing mapped import with an auto-created Read node; preserve imports in this guard.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At editor/src/messages/portfolio/document/utility_types/network_interface/layout.rs, line 1173:
<comment>`NodeInput::Import` is a real wire connection, but this guard only treats `NodeInput::Node` as connected. In a nested network, the later `create_wire` replaces an existing mapped import with an auto-created Read node; preserve imports in this guard.</comment>
<file context>
@@ -1154,6 +1154,61 @@ impl NodeNetworkInterface {
+ }
+
+ let mapped_input_connector = InputConnector::node_at_index(*node_id, 1);
+ if matches!(self.input_from_connector(&mapped_input_connector, network_path), Some(NodeInput::Node { .. })) {
+ return;
+ }
</file context>
Suggested change
| if matches!(self.input_from_connector(&mapped_input_connector, network_path), Some(NodeInput::Node { .. })) { | |
| if matches!(self.input_from_connector(&mapped_input_connector, network_path), Some(NodeInput::Node { .. } | NodeInput::Import { .. })) { |
|
|
||
| /// If `node_id` is a Map node whose "Mapped" input (index 1) is unconnected, inspects the type feeding its primary | ||
| /// input (index 0) and creates a matching "Read X" node wired into the "Mapped" input. | ||
| pub fn auto_create_read_node_for_map(&mut self, node_id: &NodeId, network_path: &[NodeId]) { |
Contributor
There was a problem hiding this comment.
P1: move_node_to_chain_start skips this helper when Map is added as the first node in a chain, and also on its import path. Those direct wiring paths leave the Map without the required Read node; invoke the helper after those wirings as well.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At editor/src/messages/portfolio/document/utility_types/network_interface/layout.rs, line 1163:
<comment>`move_node_to_chain_start` skips this helper when Map is added as the first node in a chain, and also on its `import` path. Those direct wiring paths leave the Map without the required Read node; invoke the helper after those wirings as well.</comment>
<file context>
@@ -1154,6 +1154,61 @@ impl NodeNetworkInterface {
+
+ /// If `node_id` is a Map node whose "Mapped" input (index 1) is unconnected, inspects the type feeding its primary
+ /// input (index 0) and creates a matching "Read X" node wired into the "Mapped" input.
+ pub fn auto_create_read_node_for_map(&mut self, node_id: &NodeId, network_path: &[NodeId]) {
+ let is_map_node = matches!(
+ self.implementation(node_id, network_path),
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4792
Description
When a Map node is added to a chain or inserted into an existing wire, it now checks the type of data coming into its
contentinput and automatically adds the matching Read node to the mapped input.It supports Vector, Graphic, Raster (CPU), Color, Gradient, Number, and String types.
The Read node is placed to the left of the Map node. If the mapped input is already connected, the existing connection is left unchanged.
Tests
Added a test to check that inserting a Map node automatically creates the correct Read node.
Added a test to make sure an existing
mappedconnection is preserved.