bonsai-rx / bonsai

The compiler, IDE, and standard library for the Bonsai visual programming language for reactive systems
https://bonsai-rx.org
MIT License
131 stars 29 forks source link

`Visualizer` operator does not propagate internal workflow visualizer #1860

Open bruno-f-cruz opened 1 week ago

bruno-f-cruz commented 1 week ago

The intended use of Visualizer was to be able to propagate the visualizer of the nested workflow. However, as of the last bonsai version, this behavior seems to have been broken:

image

Here, I would expect that a visualizer for the String type should be propagated and not the Int. This is probably because Visualizer is of operator type Sink. This regression bug was probably introduced in #1751 where sinks will now propagate the visualizer of the input type.

I believe we should support the following 2 cases:

1. Propagation of the original sequence's visualizer

This is extremely useful for introducing side-effects after UI elements. For instance: image This should be supported by the generic Sink operator

2. Propagation of nested workflow's visualizer

This is useful when the user wants to have a UI for the actual side effect. Moroever, as the Visualizer operator has its own scope, it also prevents contaminating the workflow with unnecessary subjects. This is also critical for IncludeWorkflows with their own visualizer.

image

This case should be handled by the Visualizer operator. Moreover, it would be very useful to allow a 0-input Visualizer overload. Essentially allowing the creation of "visualization scopes".

bruno-f-cruz commented 1 week ago

I just realized that there may actually be a 3rd case

3. Propagation of internal scope sequence + visualizer

For instance, consider the following workflow:

image

A potential pattern might be to nest these operators within a Defer and want the visualizer output to be Button while the output to be the Int. I wonder if a more "Bonsonic" way to do this is to allow VisualizerMapping to target WorkflowOutputs. For instance:

image