Light Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Batch anywidget model updates like UI element updates#8168

Merged
mscolnick merged 5 commits intomainfrom
push-xpqrollwszqq
Feb 10, 2026
Merged

Batch anywidget model updates like UI element updates#8168
mscolnick merged 5 commits intomainfrom
push-xpqrollwszqq

Conversation

Copy link
Collaborator

manzt commented Feb 6, 2026 *
edited
Loading

The anywidget refactors in #8156, #8159, and #8163 separated model lifecycle from widget binding and moved to a dedicated ModelCommand for frontend-to-backend communication.

However, unlike UpdateUIElementCommand which goes through SetUIElementRequestManager's drain-and-merge path, the new ModelCommand is processed immediately. Each rapid model update (e.g. dragging a map widget) triggered an individual cell re-execution.

These changes puts ModelCommand on the same shared queue as UpdateUIElementCommand so both go through the same batching pipeline. When multiple model updates arrive in quick succession, they are now drained and merged (last-write-wins per model ID on state keys), matching the existing UI element behavior.

The handler for model messages also now enqueues the resulting UpdateUIElementCommand back through the control queue instead of calling set_ui_element_value directly, so the downstream cell re-execution also benefits from batching.

manzt requested a review from dmadisetti as a code owner February 6, 2026 23:39
Copy link

vercel bot commented Feb 6, 2026 *
edited
Loading

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Preview, Comment Feb 10, 2026 10:31pm

vercel bot deployed to Preview February 6, 2026 23:39 View deployment
vercel bot deployed to Preview February 6, 2026 23:41 View deployment
mscolnick reviewed Feb 7, 2026
mscolnick reviewed Feb 7, 2026
mscolnick reviewed Feb 7, 2026
manzt force-pushed the push-xpqrollwszqq branch from a5229b7 to d97731a Compare February 8, 2026 16:37
vercel bot deployed to Preview February 8, 2026 16:38 View deployment
vercel bot deployed to Preview February 8, 2026 19:26 View deployment
manzt added the bug Something isn't working label Feb 9, 2026
vercel bot deployed to Preview February 9, 2026 18:50 View deployment
mscolnick previously approved these changes Feb 9, 2026
manzt force-pushed the push-xpqrollwszqq branch from fc72c3f to 9f962c8 Compare February 9, 2026 21:07
vercel bot deployed to Preview February 9, 2026 21:09 View deployment
pre-commit-ci bot dismissed mscolnick's stale review via f1f2972 February 9, 2026 21:12
vercel bot deployed to Preview February 9, 2026 21:13 View deployment
manzt force-pushed the push-xpqrollwszqq branch from f1f2972 to ed502bd Compare February 10, 2026 04:41
vercel bot deployed to Preview February 10, 2026 04:42 View deployment
manzt force-pushed the push-xpqrollwszqq branch from ed502bd to 1dbb193 Compare February 10, 2026 15:44
vercel bot deployed to Preview February 10, 2026 15:46 View deployment
manzt force-pushed the push-xpqrollwszqq branch from 1dbb193 to 65995d4 Compare February 10, 2026 18:25
vercel bot deployed to Preview February 10, 2026 18:31 View deployment
manzt force-pushed the push-xpqrollwszqq branch from 65995d4 to 5176b22 Compare February 10, 2026 20:22
vercel bot deployed to Preview February 10, 2026 20:23 View deployment
vercel bot deployed to Preview February 10, 2026 22:10 View deployment
manzt added 4 commits February 10, 2026 17:21
The anywidget refactors in #8156, #8159, and #8163 separated model
lifecycle from widget binding and moved to a dedicated ModelCommand for
frontend-to-backend communication.

However, unlike UpdateUIElementCommand which goes through
SetUIElementRequestManager's drain-and-merge path, ModelCommand was
processed immediately -- each rapid model update (e.g. dragging a map
widget) triggered an individual cell re-execution.

These changes puts `ModelCommand` on the same shared queue as
`UpdateUIElementCommand` so both go through the same batching pipeline.
When multiple model updates arrive in quick succession, they are now
drained and merged (last-write-wins per model ID on state keys),
matching the existing UI element behavior.

The handler for model messages also now enqueues the resulting
`UpdateUIElementCommand` back through the control queue instead of
calling `set_ui_element_value` directly, so the downstream cell
re-execution also benefits from batching.
When an anywidget fires rapid updates (e.g. dragging a matrix), each
ModelCommand was re-enqueuing a separate UpdateUIElementCommand back
onto the control queue. Because the batch merger only collapses
contiguous runs of the same type, these interleaved Model+UI pairs could
never be merged, so every single drag tick triggered its own full cell
re-execution.

Two changes fix this. First, handle_receive_model_message now calls
set_ui_element_value directly instead of re-enqueuing, eliminating the
interleaving entirely. Second, ModelCommand gets a token field (matching
UpdateUIElementCommand) so the dual-queue dedup works for both command
types. Previously only UI commands had tokens, so model commands left on
the control_queue after a set_ui_element_queue drain were each processed
individually rather than skipped. The dedup logic is unified into a
single _dedup method that handles both types.
manzt force-pushed the push-xpqrollwszqq branch from 1c52a67 to a620401 Compare February 10, 2026 22:21
vercel bot deployed to Preview February 10, 2026 22:22 View deployment
github-actions bot added the bash-focus Area to focus on during release bug bash label Feb 10, 2026
vercel bot deployed to Preview February 10, 2026 22:31 View deployment
mscolnick merged commit e93ea4b into main Feb 10, 2026
39 of 48 checks passed
mscolnick deleted the push-xpqrollwszqq branch February 10, 2026 23:48
Copy link

github-actions bot commented Feb 10, 2026

Development release published. You may be able to view the changes at https://marimo.app?v=0.19.10-dev45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

mscolnick mscolnick left review comments

dmadisetti Awaiting requested review from dmadisetti dmadisetti is a code owner

Assignees

No one assigned

Labels

bash-focus Area to focus on during release bug bash bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants