marimo icon indicating copy to clipboard operation
marimo copied to clipboard

persist gui selections on autoreload

Open majidaldo opened this issue 1 year ago • 1 comments

Description

  1. create a ui selection element
  2. select
  3. change code in an imported module
  4. 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

majidaldo avatar Jan 15 '25 20:01 majidaldo

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.

akshayka avatar Jan 15 '25 22:01 akshayka

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

mscolnick avatar Jan 16 '25 18:01 mscolnick