Make the node graph's "Merge Selected Nodes" target the right-clicked node, and fix it crashing (#4252)

This commit is contained in:
Keavon Chambers
2026-06-17 22:31:06 -07:00
committed by GitHub
parent 9a9436c5b9
commit 5b008936d2
3 changed files with 52 additions and 3 deletions

View File

@@ -609,11 +609,23 @@ impl PartialEq for InspectResult {
impl InspectState {
/// Insert the monitor node alongside the inspect node identified by `inspect_path` (full path from root, last element is the target).
/// Returns `None` if the path is empty or doesn't resolve to a node inside a reachable subnetwork.
/// Returns `None` if the path is empty, doesn't resolve to a node inside a reachable subnetwork, or the target has no
/// flatten-safe primary output to monitor (e.g. an empty merged subnetwork), which would otherwise leave the monitor's
/// input dangling once the subnetwork is flattened away.
pub fn monitor_inspect_node(network: &mut NodeNetwork, inspect_path: &[NodeId]) -> Option<Self> {
let (inspect_node, parent_path) = inspect_path.split_last()?;
let inspect_node = *inspect_node;
let target_network = navigate_to_network_mut(network, parent_path)?;
// A subnetwork's primary output only survives flattening if its first export is a node
let monitorable = match &target_network.nodes.get(&inspect_node)?.implementation {
DocumentNodeImplementation::Network(inner) => matches!(inner.exports.first(), Some(NodeInput::Node { .. })),
_ => true,
};
if !monitorable {
return None;
}
let monitor_id = NodeId::new();
// It is necessary to replace the inputs before inserting the monitor node to avoid changing the input of the new monitor node