Repository navigation
fix: preserve reactive UI updates for app.clone().embed() - #12288
Open
hai-dep-try wants to merge 1 commit into
Open
hai-dep-try wants to merge 1 commit into
hai-dep-try wants to merge 1 commit into
Conversation
Track parent caller cells in AppKernelRunnerRegistry and reuse cloned App instances across reactive cell re-runs while resetting them on explicit cell execution or deletion. Fixes marimo-team#4249. Signed-off-by: hai-dep-try <duchain18@gmail.com>
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Closes #4249
Fixes reactive UI updates when embedding a cloned app directly via
await app.clone().embed()(without assigning the clone to a separate cell's global variable).Root cause
Kernel.set_ui_element_valuepreviously only discovered parent cells to re-run by scanningself.globalsfor references tochild_context.app._app. Becauseapp.clone()returned an unbound temporaryAppobject, no parent cell was scheduled andset_ui_element_valuereturnedFalse.app.clone()again inside the cell created a brand newAppandAppKernelRunner, discarding the child's updated UI state.Changes
marimo/_runtime/context/types.py: Trackclone_seqperExecutionContextcell run.marimo/_ast/app.py:AppKernelRunnerRegistryduringApp.embed().Appinstances across reactive re-runs of the same cell keyed by(id(ctx), cell_id, source_app, clone_seq)inApp.clone(), and clean up tracked state onremove_runner/shutdown.marimo/_runtime/runtime.py:self.graph.cells) inreferring_cellsinsideKernel.set_ui_element_value.Kernel.run/Kernel.delete_cellso manual cell re-execution creates fresh clones.tests/_ast/test_app.py: Add regression tests coveringapp.clone().embed()reactive UI updates, multiple independent clones in one cell, and reset on explicit cell re-execution.Verification
ruff check marimo/_ast/app.py marimo/_runtime/context/types.py marimo/_runtime/runtime.py->All checks passed!ruff format --check marimo/_ast/app.py marimo/_runtime/context/types.py marimo/_runtime/runtime.py tests/_ast/test_app.py->4 files already formattedpytest tests/_ast/test_app.py tests/_runtime/test_context.py -v->111 passed, 3 skipped(3 matplotlib-optional tests skipped in local venv).👋 First time contributor introduction
Hi! I'm a Python developer contributing a fix for reactive embedded cloned apps (
#4249). Looking forward to your feedback!📋 Pre-Review Checklist
✅ Merge Checklist