From 0a69934a2d4fd3da6e204bf0e48de51fa3b1f836 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Jan 2026 19:26:39 -0800 Subject: [PATCH 1/3] Fix tooltips --- frontend/src/components/floating-menus/NodeCatalog.svelte | 5 ++++- frontend/src/components/views/Graph.svelte | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/floating-menus/NodeCatalog.svelte b/frontend/src/components/floating-menus/NodeCatalog.svelte index dac04949dd..278fc3ac2c 100644 --- a/frontend/src/components/floating-menus/NodeCatalog.svelte +++ b/frontend/src/components/floating-menus/NodeCatalog.svelte @@ -125,7 +125,10 @@ {disabled} label={nodeType.name} tooltipLabel={nodeType.name} - tooltipDescription={$nodeGraph.nodeDescriptions.get(nodeType.identifier)} + tooltipDescription={[...$nodeGraph.nodeDescriptions.entries()] + .find(([key]) => key.type === nodeType.identifier?.type && key.data === nodeType.identifier?.data) + ?.at(1) + ?.toString()} action={() => dispatch("selectNodeType", nodeType.identifier)} /> {/each} diff --git a/frontend/src/components/views/Graph.svelte b/frontend/src/components/views/Graph.svelte index 2f52d80f43..3a5339358f 100644 --- a/frontend/src/components/views/Graph.svelte +++ b/frontend/src/components/views/Graph.svelte @@ -481,7 +481,7 @@ {@const layerAreaWidth = $nodeGraph.layerWidths.get(node.id) || 8} {@const layerChainWidth = $nodeGraph.chainWidths.get(node.id) || 0} {@const hasLeftInputWire = $nodeGraph.hasLeftInputWire.get(node.id) || false} - {@const description = (node.reference && $nodeGraph.nodeDescriptions.get(node.reference)) || undefined} + {@const description = [...$nodeGraph.nodeDescriptions.entries()].find(([key]) => key.type === node.reference?.type && key.data === node.reference?.data)?.at(1) || undefined}
({ node, nodeIndex })) as { node, nodeIndex } (nodeIndex)} {@const exposedInputsOutputs = zipWithUndefined(node.exposedInputs, node.exposedOutputs)} {@const clipPathId = String(Math.random()).substring(2)} - {@const description = (node.reference && $nodeGraph.nodeDescriptions.get(node.reference)) || undefined} + {@const description = [...$nodeGraph.nodeDescriptions.entries()].find(([key]) => key.type === node.reference?.type && key.data === node.reference?.data)?.at(1) || undefined}
Date: Thu, 15 Jan 2026 13:47:23 -0800 Subject: [PATCH 2/3] Convert DefinitionIdentifier to string in JavaScript --- .../src/messages/frontend/frontend_message.rs | 3 +- .../node_graph/document_node_definitions.rs | 45 ++++++++++--------- .../node_graph/node_graph_message_handler.rs | 2 +- .../document/node_graph/utility_types.rs | 5 +-- .../floating-menus/NodeCatalog.svelte | 9 ++-- frontend/src/components/views/Graph.svelte | 8 ++-- frontend/src/messages.ts | 6 +-- frontend/src/state-providers/node-graph.ts | 3 +- 8 files changed, 40 insertions(+), 41 deletions(-) diff --git a/editor/src/messages/frontend/frontend_message.rs b/editor/src/messages/frontend/frontend_message.rs index 0f47b6f5f7..e6c724069f 100644 --- a/editor/src/messages/frontend/frontend_message.rs +++ b/editor/src/messages/frontend/frontend_message.rs @@ -2,7 +2,6 @@ use super::utility_types::{DocumentDetails, MouseCursorIcon, OpenDocument}; use crate::messages::app_window::app_window_message_handler::AppWindowPlatform; use crate::messages::input_mapper::utility_types::misc::ActionShortcut; use crate::messages::layout::utility_types::widget_prelude::*; -use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier; use crate::messages::portfolio::document::node_graph::utility_types::{ BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphErrorDiagnostic, Transform, }; @@ -61,7 +60,7 @@ pub enum FrontendMessage { // Send prefix: Send global, static data to the frontend that is never updated SendUIMetadata { #[serde(rename = "nodeDescriptions")] - node_descriptions: Vec<(DefinitionIdentifier, String)>, + node_descriptions: Vec<(String, String)>, #[serde(rename = "nodeTypes")] node_types: Vec, }, diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index bb90f2c946..422e0161f3 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -80,29 +80,29 @@ impl DefinitionIdentifier { }), } } + + pub fn serialized(&self) -> String { + match self { + DefinitionIdentifier::ProtoNode(id) => { + format!("Proto Node:{}", id.as_str()) + } + DefinitionIdentifier::Network(data) => { + format!("Network:{}", data) + } + } + } } impl From for DefinitionIdentifier { fn from(value: Value) -> Self { - match value { - Value::Object(mut map) => { - let ty = map.remove("type").unwrap().as_str().unwrap().to_owned(); + let s = value.as_str().expect("DefinitionIdentifier value must be a string"); - match ty.as_ref() { - "Network" => { - let data = map.remove("data").unwrap().as_str().unwrap().to_owned(); - DefinitionIdentifier::Network(data) - } - "ProtoNode" => { - let value = map.remove("data").unwrap(); - let proto: ProtoNodeIdentifier = serde_json::from_value(value).unwrap(); - DefinitionIdentifier::ProtoNode(proto) - } - _ => panic!("Unknown `DefinitionIdentifier` type: {:?}", ty), - } - } + let (ty, data) = s.split_once(':').expect("Invalid DefinitionIdentifier key format"); - _ => panic!("Expected a JSON object to convert to `DefinitionIdentifier`"), + match ty { + "Proto Node" => DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::with_owned_string(data.to_string())), + "Network" => DefinitionIdentifier::Network(data.to_string()), + other => panic!("Unknown DefinitionIdentifier type: {other}"), } } } @@ -2621,7 +2621,7 @@ pub fn collect_node_types() -> Vec { name = identifier.implementation_name_from_identifier() } FrontendNodeType { - identifier: identifier.clone(), + identifier: identifier.serialized(), name, category: definition.category.to_string(), input_types, @@ -2630,10 +2630,15 @@ pub fn collect_node_types() -> Vec { .collect() } -pub fn collect_node_descriptions() -> Vec<(DefinitionIdentifier, String)> { +pub fn collect_node_descriptions() -> Vec<(String, String)> { DOCUMENT_NODE_TYPES .iter() - .map(|(identifier, definition)| (identifier.clone(), if definition.description != "TODO" { definition.description.to_string() } else { String::new() })) + .map(|(identifier, definition)| { + ( + identifier.serialized(), + if definition.description != "TODO" { definition.description.to_string() } else { String::new() }, + ) + }) .collect() } diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index a171ef360d..45f8f145d1 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -2599,7 +2599,7 @@ impl NodeGraphMessageHandler { .node_metadata(&node_id, breadcrumb_network_path) .is_some_and(|node_metadata| node_metadata.persistent_metadata.is_layer()), can_be_layer: network_interface.is_eligible_to_be_layer(&node_id, breadcrumb_network_path), - reference: network_interface.reference(&node_id, breadcrumb_network_path), + reference: network_interface.reference(&node_id, breadcrumb_network_path).map(|reference| reference.serialized()), display_name: network_interface.display_name(&node_id, breadcrumb_network_path), implementation_name: network_interface.implementation_name(&node_id, breadcrumb_network_path), primary_input, diff --git a/editor/src/messages/portfolio/document/node_graph/utility_types.rs b/editor/src/messages/portfolio/document/node_graph/utility_types.rs index 54ca255e84..12d6780fc1 100644 --- a/editor/src/messages/portfolio/document/node_graph/utility_types.rs +++ b/editor/src/messages/portfolio/document/node_graph/utility_types.rs @@ -1,4 +1,3 @@ -use super::document_node_definitions::DefinitionIdentifier; use glam::{DVec2, IVec2}; use graph_craft::document::NodeId; use graph_craft::document::value::TaggedValue; @@ -79,7 +78,7 @@ pub struct FrontendNode { pub is_layer: bool, #[serde(rename = "canBeLayer")] pub can_be_layer: bool, - pub reference: Option, + pub reference: Option, #[serde(rename = "displayName")] pub display_name: String, #[serde(rename = "implementationName")] @@ -104,7 +103,7 @@ pub struct FrontendNode { #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)] pub struct FrontendNodeType { - pub identifier: DefinitionIdentifier, + pub identifier: String, pub name: String, pub category: String, #[serde(rename = "inputTypes")] diff --git a/frontend/src/components/floating-menus/NodeCatalog.svelte b/frontend/src/components/floating-menus/NodeCatalog.svelte index 278fc3ac2c..13af50a772 100644 --- a/frontend/src/components/floating-menus/NodeCatalog.svelte +++ b/frontend/src/components/floating-menus/NodeCatalog.svelte @@ -1,7 +1,7 @@