@@ -212,14 +212,14 @@ impl NodeRuntime {
212212 }
213213 GraphRuntimeRequest :: ExecutionRequest ( ExecutionRequest { execution_id, render_config, .. } ) => {
214214 let result = self . execute_network ( render_config) . await ;
215- let mut responses = VecDeque :: new ( ) ;
215+ let mut execution_responses = Vec :: new ( ) ;
216216 // TODO: Only process monitor nodes if the graph has changed, not when only the Footprint changes
217- self . process_monitor_nodes ( & mut responses , self . update_thumbnails ) ;
217+ self . process_monitor_nodes ( & mut execution_responses , self . update_thumbnails ) ;
218218 self . update_thumbnails = false ;
219219
220220 // Resolve the result from the inspection by accessing the monitor node
221221 let inspect_result = self . inspect_state . and_then ( |state| state. access ( & self . executor ) ) ;
222-
222+ execution_responses . push ( ExecutionResponseMessage :: InspectResult ( inspect_result ) ) ;
223223 let texture = if let Ok ( TaggedValue :: RenderOutput ( RenderOutput {
224224 data : RenderOutputType :: Texture ( texture) ,
225225 ..
@@ -233,9 +233,8 @@ impl NodeRuntime {
233233 self . sender . send_execution_response ( ExecutionResponse {
234234 execution_id,
235235 result,
236- responses ,
236+ execution_responses ,
237237 vector_modify : self . vector_modify . clone ( ) ,
238- inspect_result,
239238 } ) ;
240239 return texture;
241240 }
@@ -289,10 +288,10 @@ impl NodeRuntime {
289288 }
290289
291290 /// Updates state data
292- pub fn process_monitor_nodes ( & mut self , responses : & mut VecDeque < FrontendMessage > , update_thumbnails : bool ) {
291+ pub fn process_monitor_nodes ( & mut self , responses : & mut Vec < ExecutionResponseMessage > , update_thumbnails : bool ) {
293292 // TODO: Consider optimizing this since it's currently O(m*n^2), with a sort it could be made O(m * n*log(n))
294293 self . thumbnail_renders . retain ( |id, _| self . monitor_nodes . iter ( ) . any ( |monitor_node_path| monitor_node_path. contains ( id) ) ) ;
295-
294+ let mut updated_thumbnails = false ;
296295 for monitor_node_path in & self . monitor_nodes {
297296 // Skip the inspect monitor node
298297 if self . inspect_state . is_some_and ( |inspect_state| monitor_node_path. last ( ) . copied ( ) == Some ( inspect_state. monitor_node ) ) {
@@ -316,13 +315,17 @@ impl NodeRuntime {
316315 // Graphic table: thumbnail
317316 if let Some ( io) = introspected_data. downcast_ref :: < IORecord < Context , Table < Graphic > > > ( ) {
318317 if update_thumbnails {
319- Self :: render_thumbnail ( & mut self . thumbnail_renders , parent_network_node_id, & io. output , responses)
318+ Self :: render_thumbnail ( & mut self . thumbnail_renders , parent_network_node_id, & io. output , responses) ;
319+ responses. push ( ExecutionResponseMessage :: UpdateNodeGraphThumbnail ( parent_network_node_id, io. output . clone ( ) . to_graphic ( ) ) ) ;
320+ updated_thumbnails = true ;
320321 }
321322 }
322323 // Artboard table: thumbnail
323324 else if let Some ( io) = introspected_data. downcast_ref :: < IORecord < Context , Table < Artboard > > > ( ) {
324325 if update_thumbnails {
325- Self :: render_thumbnail ( & mut self . thumbnail_renders , parent_network_node_id, & io. output , responses)
326+ Self :: render_thumbnail ( & mut self . thumbnail_renders , parent_network_node_id, & io. output , responses) ;
327+ responses. push ( ExecutionResponseMessage :: UpdateNodeGraphThumbnail ( parent_network_node_id, io. output . clone ( ) . to_graphic ( ) ) ) ;
328+ updated_thumbnails = true ;
326329 }
327330 }
328331 // Vector table: vector modifications
@@ -337,18 +340,21 @@ impl NodeRuntime {
337340 log:: warn!( "Failed to downcast monitor node output {parent_network_node_id:?}" ) ;
338341 }
339342 }
343+ if updated_thumbnails {
344+ responses. push ( ExecutionResponseMessage :: SendGraph ) ;
345+ }
340346 }
341347
342348 /// If this is `Graphic` data, regenerate click targets and thumbnails for the layers in the graph, modifying the state and updating the UI.
343- fn render_thumbnail ( thumbnail_renders : & mut HashMap < NodeId , Vec < SvgSegment > > , parent_network_node_id : NodeId , graphic : & impl Render , responses : & mut VecDeque < FrontendMessage > ) {
349+ fn render_thumbnail ( thumbnail_renders : & mut HashMap < NodeId , Vec < SvgSegment > > , parent_network_node_id : NodeId , graphic : & impl Render , responses : & mut Vec < ExecutionResponseMessage > ) {
344350 // Skip thumbnails if the layer is too complex (for performance)
345351 if graphic. render_complexity ( ) > 1000 {
346352 let old = thumbnail_renders. insert ( parent_network_node_id, Vec :: new ( ) ) ;
347353 if old. is_none_or ( |v| !v. is_empty ( ) ) {
348- responses. push_back ( FrontendMessage :: UpdateNodeThumbnail {
349- id : parent_network_node_id,
350- value : "<svg viewBox=\" 0 0 10 10\" ><title>Dense thumbnail omitted for performance</title><line x1=\" 0\" y1=\" 10\" x2=\" 10\" y2=\" 0\" stroke=\" red\" /></svg>" . to_string ( ) ,
351- } ) ;
354+ responses. push ( ExecutionResponseMessage :: UpdateFrontendThumbnail (
355+ parent_network_node_id,
356+ "<svg viewBox=\" 0 0 10 10\" ><title>Dense thumbnail omitted for performance</title><line x1=\" 0\" y1=\" 10\" x2=\" 10\" y2=\" 0\" stroke=\" red\" /></svg>" . to_string ( ) ,
357+ ) ) ;
352358 }
353359 return ;
354360 }
@@ -382,10 +388,7 @@ impl NodeRuntime {
382388 let old_thumbnail_svg = thumbnail_renders. entry ( parent_network_node_id) . or_default ( ) ;
383389
384390 if old_thumbnail_svg != & new_thumbnail_svg {
385- responses. push_back ( FrontendMessage :: UpdateNodeThumbnail {
386- id : parent_network_node_id,
387- value : new_thumbnail_svg. to_svg_string ( ) ,
388- } ) ;
391+ responses. push ( ExecutionResponseMessage :: UpdateFrontendThumbnail ( parent_network_node_id, new_thumbnail_svg. to_svg_string ( ) ) ) ;
389392 * old_thumbnail_svg = new_thumbnail_svg;
390393 }
391394 }
0 commit comments