marimo
marimo copied to clipboard
persist gui selections on autoreload
Description
- create a ui selection element
- select
- change code in an imported module
- reloading clears the element so now i have to (manually) reselect.
Suggested solution
autoreloading should keep notebook selections
Alternative
No response
Additional context
No response
If this is affecting cells that don't depend on the reloaded code, then this is a bug. Otherwise, if it only affects cells that depend on the reloaded modules (ie the cell importing the module or any of its descendants), then there likely isn't anything we can do about this.
You can use mo.state() to hoist the state out of the DAG that gets re-run. This would avoid re-setting the values for the UI elements. This comes with many other caveats to using state: https://docs.marimo.io/guides/state/#reactive-state