marimo
marimo copied to clipboard
UI elements not refreshing after page reload when using mosaic_app.embed()
Describe the bug
When embedding a marimo app using app.embed() in a parent Marimo app, the child UI elements rendered with mo.vstack are dynamically refreshed when the page is loaded for the first time. However, if I refresh the page afterward, the UI elements are no longer refreshed correctly — they seem to be cached or preserved from the previous state.
Actual Behavior
- On the initial load, the UI elements are displayed correctly.
- After a page reload, the UI elements are not refreshed and seem to retain the state from the previous load.
Expected Behavior
- UI elements displayed with
mo.vstackshould be refreshed correctly each time the page is loaded, even after a page reload.
Environment
Replace this line with the output of marimo env. Leave the backticks in place.
Code to reproduce
dashboard.py
import marimo
__generated_with = "0.10.18"
app = marimo.App(width="medium", app_title="Embedded Dashboard")
@app.cell
def _():
import marimo as mo
return (mo,)
@app.cell
def _(mo):
centers = ["Center A", "Center B", "Center C"]
indications = ["Indication 1", "Indication 2", "Indication 3"]
dropdown_center = mo.ui.dropdown(
centers,
value="Center A"
)
dropdown_indication = mo.ui.dropdown(
indications,
value="Indication 1"
)
return centers, dropdown_center, dropdown_indication, indications
@app.cell
def _(dropdown_center, dropdown_indication, mo):
mo.vstack([
mo.md("## Test Dashboard"),
mo.hstack([
dropdown_center,
dropdown_indication,
], justify="start"),
mo.md(f"Selected Center: **{dropdown_center.selected_key}**"),
mo.md(f"Selected Indication: **{dropdown_indication.selected_key}**")
])
return
if __name__ == "__main__":
app.run()
embedding.py
import marimo
__generated_with = "0.10.18"
app = marimo.App(width="columns", app_title="Test embedding")
@app.cell(hide_code=True)
def _():
from dashboard import app as child_app
import marimo as mo
return mo, child_app
@app.cell
async def _(child_app):
result = await child_app.embed()
return (result,)
@app.cell
def _(mo, result):
result.output
return (result,)
if __name__ == "__main__":
app.run()
````
I also tried
refresh = mo.ui.refresh(
label="Refresh",
options=["1s", "5s", "10s", "30s"]
)
refresh
No matter manual refresh or auto-refresh, the below SQL cell is not re-run