GraphiteEditor / GraphiteEditor/Graphite

Typing of disconnected node outputs

Open
#4,276 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
27.2k
Forks
1.3k
Avg merge
20h 5m
Merged PRs (30d)
57

Description

When a node is disconnected from the graph output, the type hints for the output are not available. This occurs even if the output type is completely unambiguous such as the « tangent on path » node. This makes it rather frustrating to make graphs since nodes are often disconnected when building a graph.

```diff
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 685d32e59..8f80c3208 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
@@ -337,12 +337,29 @@ impl NodeNetworkInterface {
let Some(implementation) = self.implementation(node_id, network_path) else {
return TypeSource::Error("Could not get implementation");
};
+ info!("Got node");
match implementation {
DocumentNodeImplementation::Network(_) => self.input_type(&InputConnector::Export(*output_index), &[network_path, &[*node_id]].concat()),
- DocumentNodeImplementation::ProtoNode(_) => match self.resolved_types.types.get(&[network_path, &[*node_id]].concat()) {
- Some(resolved_type) => TypeSource::Compiled(resolved_type.output.clone()),
- None => TypeSource::Unknown,
- },
+ DocumentNodeImplementation::ProtoNode(proto_node_identifier) => {
+ if let Some(resolved_type) = self.resolved_types.types.get(&[network_path, &[*node_id]].concat()) {
+ TypeSource::Compiled(resolved_type.output.clone())
+ } else {
+ let Some(implementations) = NODE_REGISTRY.get(proto_node_identifier) else {
+ error!("Protonode {proto_node_identifier:?} not found in registry in output_type");
+ return TypeSource::Error("no protonode");
+ };
+
+ let mut possible_outputs = implementations.keys().map(|io| &io.return_value).collect::>();
+ possible_outputs.dedup();
+ // Only type unambiguous outputs (just one possible type)
+ if let Some([result]) = possible_outputs.as_array() {
+ TypeSource::Compiled((*result).clone())
+ } else {
+ info!("Ambiguous outputs {possible_outputs:#?}");
+ TypeSource::Unknown
+ }
+ }
+ }
DocumentNodeImplementation::Extract => TypeSource::Compiled(concrete!(())),
}
}
```

It should be possible to further filter the possible output types based on the known input types.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs at NodeNetworkInterface::output_type, then inspect resolved_types.types and NODE_REGISTRY handling for ProtoNode outputs. Verify that disconnected nodes with one possible output type expose that type, while ambiguous outputs remain unknown; the tangent on path node is the stated example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.