diff --git a/editor/src/messages/portfolio/document/node_graph/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_properties.rs index 6371d8d0e8..8d0322eb47 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_properties.rs @@ -2002,7 +2002,7 @@ impl<'a> ParameterWidgetsInfo<'a> { let (name, description) = context.network_interface.displayed_input_name_and_description(&node_id, index, context.selection_network_path); let input_type = context .network_interface - .input_type(&InputConnector::node(node_id, index), context.selection_network_path) + .input_type_not_invalid(&InputConnector::node(node_id, index), context.selection_network_path) .displayed_type(); let document_node = context.network_interface.document_node(&node_id, context.selection_network_path); diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs b/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs index a3dccaacdc..c5caded7f9 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use graph_craft::document::value::TaggedValue; use graph_craft::document::{DocumentNodeImplementation, InlineRust, NodeInput}; -use graph_craft::proto::GraphErrors; +use graph_craft::proto::{GraphErrorType, GraphErrors}; use graph_craft::{Type, concrete}; use graphene_std::uuid::NodeId; use interpreted_executor::dynamic_executor::{NodeTypes, ResolvedDocumentNodeTypesDelta}; @@ -129,7 +129,14 @@ impl NodeNetworkInterface { InputConnector::Export(_) => false, }) } - DocumentNodeImplementation::ProtoNode(_) => self.resolved_types.node_graph_errors.iter().any(|error| error.node_path == node_path), + DocumentNodeImplementation::ProtoNode(_) => self.resolved_types.node_graph_errors.iter().any(|error| { + error.node_path == node_path + && match &error.error { + GraphErrorType::InvalidImplementations { error_inputs, .. } => error_inputs.iter().any(|solution| solution.iter().any(|(index, _)| index == input_index)), + _ => true, + } + }), + DocumentNodeImplementation::Extract => false, } } @@ -137,7 +144,7 @@ impl NodeNetworkInterface { } } - fn input_type_not_invalid(&mut self, input_connector: &InputConnector, network_path: &[NodeId]) -> TypeSource { + pub fn input_type_not_invalid(&mut self, input_connector: &InputConnector, network_path: &[NodeId]) -> TypeSource { let Some(input) = self.input_from_connector(input_connector, network_path) else { return TypeSource::Error("Could not get input from connector"); }; diff --git a/node-graph/graph-craft/src/document.rs b/node-graph/graph-craft/src/document.rs index 4f84913fd4..bdb1e0389b 100644 --- a/node-graph/graph-craft/src/document.rs +++ b/node-graph/graph-craft/src/document.rs @@ -84,6 +84,8 @@ pub struct OriginalLocation { pub dependants: Vec>, /// A list of flags indicating whether the input is exposed in the UI pub inputs_exposed: Vec, + // For automatically inserted convert and into nodes, if there is an error display it on the node it is connect to + pub auto_convert_index: Option, } impl Default for DocumentNode { @@ -664,12 +666,9 @@ impl NodeNetwork { if node.original_location.path.is_some() { log::warn!("Attempting to overwrite node path"); } else { - node.original_location = OriginalLocation { - path: Some(new_path), - inputs_exposed: node.inputs.iter().map(|input| input.is_exposed()).collect(), - dependants: (0..node.implementation.output_count()).map(|_| Vec::new()).collect(), - ..Default::default() - }; + node.original_location.path = Some(new_path); + node.original_location.inputs_exposed = node.inputs.iter().map(|input| input.is_exposed()).collect(); + node.original_location.dependants = (0..node.implementation.output_count()).map(|_| Vec::new()).collect(); } } } diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index f2e3a3977f..3520945ab4 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -542,6 +542,8 @@ pub enum GraphErrorType { UnexpectedGenerics { index: usize, inputs: Vec }, NoImplementations, NoConstructor, + // The first vec represents a list of correct NodeIOTypes + // The second vec represents what the input index and what it expects InvalidImplementations { inputs: String, error_inputs: Vec> }, MultipleImplementations { inputs: String, valid: Vec }, } @@ -756,9 +758,11 @@ impl TypingContext { match valid_impls.as_slice() { [] => { + let convert_node_index_offset = node.original_location.auto_convert_index.unwrap_or(0); let mut best_errors = usize::MAX; let mut error_inputs = Vec::new(); for node_io in impls.keys() { + // For errors on convert nodes, add to the input index to it is correct for the node it is connected to let current_errors = [call_argument] .into_iter() .chain(&inputs) @@ -766,10 +770,7 @@ impl TypingContext { .zip([&node_io.call_argument].into_iter().chain(&node_io.inputs).cloned()) .enumerate() .filter(|(_, (p1, p2))| !valid_type(p1, p2)) - .map(|(index, ty)| { - let i = node.original_location.inputs(index).min_by_key(|s| s.node.len()).map(|s| s.index).unwrap_or(index); - (i, ty) - }) + .map(|(index, expected)| (index - 1 + convert_node_index_offset, expected)) .collect::>(); if current_errors.len() < best_errors { best_errors = current_errors.len(); @@ -783,7 +784,7 @@ impl TypingContext { .into_iter() .chain(&inputs) .enumerate() - .filter_map(|(i, t)| if i == 0 { None } else { Some(format!("• Input {i}: {t}")) }) + .filter_map(|(i, t)| if i == 0 { None } else { Some(format!("• Input {}: {t}", i + convert_node_index_offset)) }) .collect::>() .join("\n"); Err(vec![GraphError::new(node, GraphErrorType::InvalidImplementations { inputs, error_inputs })]) diff --git a/node-graph/preprocessor/src/lib.rs b/node-graph/preprocessor/src/lib.rs index 185463401b..fa610eaffa 100644 --- a/node-graph/preprocessor/src/lib.rs +++ b/node-graph/preprocessor/src/lib.rs @@ -86,11 +86,13 @@ pub fn generate_node_substitutions() -> HashMap