refact: proposal for a new design arround component tree#367
Conversation
38efd79 to
cbd02ff
Compare
src/streamsync/core_ui.py
Outdated
| super().__init__(attach_root) | ||
| self.base_component_tree = base_component_tree | ||
| def __init__(self, trees: List[ComponentTreeFragment]): | ||
| assert len(trees) > 0, "Component tree must have at least one tree fragment" |
There was a problem hiding this comment.
Not necessarily true for CMC trees, they can be empty if the user chooses to not create any CMCs
There was a problem hiding this comment.
I renamed trees to tree_branches. A tree can have 0 components but it must still have several branches, one for the bmc, one for the cmc and one for the smc
cbd02ff to
364b87a
Compare
111fee7 to
6d3fbd4
Compare
|
This is a step in the right direction. However, I'd like to change the nomenclature "smc" as I don't think it's reflective of what we're doing. Manage should be interpreted in the sense of enabling the user to create, delete, etc. Not from an internal perspective. Two categories emerge:
The other classification emerges from the specificity of the components:
Therefore, the combinations are:
There are currently no plans to have builder-managed session-specific components. For simplicity, we can adopt the following:
@mmikita95 fyi, feel free to add to the conversation |
That's sound interesting, I will take a look at the change involved. |
|
@ramedina86 great breakdown, thank you! One thing I would probably adjust is to shift focus on "session CMCs" as "main CMCs" (i.e., use names like "pre-session CMCs vs session CMCs or in-session CMCs"), because in my opinion, while "pre-session CMCs" are expected to be used more widely, technically the session context is the last point that collects all components into a "render package", and one can view "pre-session CMCs" as "copies made for the session". Therefore, to better reflect this technicality, I'd suggest this naming convention. Sorry if this is turning out to be too confusing 😅 |
|
Excellent point @mmikita95 , glad I tagged you. With this in mind, what classification (short names) would you go for? |
|
My thought is
but I'm slightly dubious on that, as these 5-letter acronyms look dangerously "too much". |
|
in line with state ( |
6d3fbd4 to
f96e538
Compare
* rename different branch regards to ramiro comment (writer#367 (comment))
* refact: use the term branch instead of fragment for smc, cmc and bmc
* fix: inversion of frozen state
* refact: improve code lisibility
* rename different branch regards to ramiro comment (writer#367 (comment))
* fix clear_children
* use dedicated clone method instead of copy
b72a85c to
0661ed8
Compare
This is a refactoring proposal to make the notion of component tree simpler. This refactoring removes the 3 distinct classes that inherit from each other to represent the 3 trees. It removes cascading inheritance and method overloading.
There is a single class
ComponentTreeclass that can combine fragments. One fragment for BMC, one for CMC, one for SMC. A fragment can be frozen to lock its contents. Fragments are an instance of the sameComponentTreeFragmentclass.The application contains 2 tree construction methods.
build_base_component_treewhich builds the tree the application needs upon loading with a fragment for BMCs and CMCs.build_session_component_treebuilds a tree dedicated to the user session with 3 fragments, one fragment for SMCs, one for CMCs and a frozen fragment for BMCs. The fragments are copied to separate them from the base representation.I added in the tests, 2 distinct contexts, one to represent a ui manager when streamsync application is loading and one to represent a ui manager in an event handler.