Week 4 - New node editor
Summary
This week, I began implementing the necessary changes to support subtree composition. I first analyzed the required modifications on the backend, focusing on enhancing the json editing endpoint to handle the new functionality more effectively. With a clearer understanding of the backend adjustments, I shifted to the frontend, where I started making changes to test and integrate these new features. This will lay the groundwork for a more flexible and dynamic editing environment moving forward.
Backend changes
Last week, I considered integrating subtree composition at the tree_gardener level using the py_trees library, which would allow dynamic addition of subtrees at runtime. However, managing multiple XML components during execution could complicate the library’s behavior. Given the existing endpoints for storing and retrieving JSON data from the editor, as well as converting it to XML, I decided that introducing a “merging” step after the JSON-XML conversion would be a more optimal and streamlined solution. This way, the app generation endpoint still receives a self contained XML and the process only requires and additional step.
The new diagram editor
While preparing for tests, I realized that the current state of the tree diagram editor presents significant challenges. It deviates from key React conventions, such as component purity and proper state management. These issues, which I previously reported in this issue, create unintended side effects and make state updates unpredictable, complicating both debugging and testing. Addressing these structural problems is essential to ensure a stable, maintainable foundation for future development.
To address the limitations of the current editor, I started developing a new version that operates independently of execution logic. This editor receives JSON data, allows for easy editing, and updates results via a setter prop. This approach enables it to handle arbitrary JSON inputs regardless of their source, ensuring compatibility with future API changes. Additionally, the new editor will support graphical representation of composable elements. I’m currently evaluating whether to display these components in modals or separate windows for better user experience. In any case, this new editor with less dependencies allows for loading multiple instances of it without any issue.