Skip to content

Composite UI elements (array/dictionary/batch) cause two recomputations on change #7545

@cebamps

Description

@cebamps

Describe the bug

When I put a UI element inside of a mo.ui.array or batch or dictionary, cells that use the composite's value are recomputed twice.

In the included notebook, the Tracing view of marimo shows two executions on every change of the checkbox in ui_composite, while the ui_simple checkbox behaves as expected (computes once).

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.18.4",
  "editable": false,
  "location": "https://github.com/private/tmp/repro/.venv/lib/python3.13/site-packages/marimo",
  "OS": "Darwin",
  "OS Version": "23.6.0",
  "Processor": "arm",
  "Python Version": "3.13.2",
  "Locale": "en_US",
  "Binaries": {
    "Browser": "143.0.7499.111",
    "Node": "v24.10.0"
  },
  "Dependencies": {
    "click": "8.3.1",
    "docutils": "0.22.3",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.10",
    "narwhals": "2.14.0",
    "packaging": "25.0",
    "psutil": "7.1.3",
    "pygments": "2.19.2",
    "pymdown-extensions": "10.19.1",
    "pyyaml": "6.0.3",
    "starlette": "0.50.0",
    "tomlkit": "0.13.3",
    "typing-extensions": "missing",
    "uvicorn": "0.38.0",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {
    "loro": "1.10.3"
  },
  "Experimental Flags": {}
}

Code to reproduce

import marimo

__generated_with = "0.18.4"
app = marimo.App(width="medium")


@app.cell
def _():
    import marimo as mo
    return (mo,)


@app.cell
def _(mo):
    ui_simple = mo.ui.checkbox()
    ui_simple
    return (ui_simple,)


@app.cell
def _(ui_simple):
    ui_simple.value
    return


@app.cell
def _(mo):
    ui_composite = mo.ui.array([mo.ui.checkbox()])
    ui_composite
    return (ui_composite,)


@app.cell
def _(ui_composite):
    ui_composite.value[0]
    return


if __name__ == "__main__":
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions