Skip to content

Suppress marimo-ui-value-update echo for user-initiated changes#9262

Merged
manzt merged 2 commits intomainfrom
push-ltuwuvrsukuw
Apr 20, 2026
Merged

Suppress marimo-ui-value-update echo for user-initiated changes#9262
manzt merged 2 commits intomainfrom
push-ltuwuvrsukuw

Conversation

@manzt
Copy link
Copy Markdown
Collaborator

@manzt manzt commented Apr 18, 2026

The kernel broadcasts a marimo-ui-value-update after every UI element value change, including user-initiated ones where the frontend already has the value. The echo is invisible over WebSocket but lands stale on high-latency transports, where broadcastMessage applies it and visibly snaps widgets backward mid-drag (the slider lag in marimo-team/marimo-lsp#515).

These changes gate the broadcast behind a notify_frontend kwarg that defaults off to scope the feature for code-mode only.

The kernel broadcasts a `marimo-ui-value-update` after every UI element
value change, including user-initiated ones where the frontend already
has the value. The echo is invisible over WebSocket but lands stale on
high-latency transports, where `broadcastMessage` applies it and visibly
snaps widgets backward mid-drag (the slider lag in
marimo-team/marimo-lsp#515).

These changes gate the broadcast behind a `notify_frontend` kwarg that
defaults off to scope the feature for code-mode only.
Copilot AI review requested due to automatic review settings April 18, 2026 16:11
@manzt manzt added the bug Something isn't working label Apr 18, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 19, 2026 0:42am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents redundant marimo-ui-value-update “echo” messages for user-initiated UI interactions by gating the broadcast behind a new notify_frontend keyword argument (defaulting to False) and enabling it only for kernel-initiated updates (e.g., code-mode set_ui_value).

Changes:

  • Add notify_frontend: bool = False (kw-only) to set_ui_element_value so UI value broadcasts can be explicitly enabled/disabled.
  • Gate the marimo-ui-value-update broadcast behind if notify_frontend:.
  • Thread notify_frontend through the AppKernelRunner / InternalApp call chain and enable it from code-mode UI update flushing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
marimo/_runtime/runtime.py Adds notify_frontend flag and conditionally broadcasts marimo-ui-value-update.
marimo/_runtime/app/kernel_runner.py Forwards notify_frontend into the kernel runtime call.
marimo/_code_mode/_context.py Enables notify_frontend=True for code-mode batched UI updates on context exit.
marimo/_ast/app.py Extends internal app UI update methods to accept/forward notify_frontend.

Comment on lines 2001 to +2004
updated_components.append(component)
# Broadcast the new value to the frontend so the
# rendered widget reflects kernel-initiated changes
# (e.g. from code_mode's set_ui_value).
broadcast_notification(
UIElementMessageNotification(
ui_element=object_id,
message={
"type": "marimo-ui-value-update",
"value": value,
},
),
self.stream,
)
if notify_frontend:
broadcast_notification(
UIElementMessageNotification(
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new notify_frontend gate changes observable behavior (whether a marimo-ui-value-update UIElementMessageNotification is emitted). There are existing runtime/messaging tests, but none appear to assert the presence/absence of this notification. Please add coverage that verifies: (1) default behavior does not broadcast a value-update message, and (2) notify_frontend=True does broadcast the expected message payload, to prevent regressions on high-latency transports.

Copilot uses AI. Check for mistakes.
@manzt manzt requested a review from mscolnick April 18, 2026 16:31
manzt added a commit to marimo-team/marimo-lsp that referenced this pull request Apr 18, 2026
Fixes #515

The kernel broadcasts this message after every UI value change. Over LSP
it arrives ~one round-trip stale and clobbers the user's in-progress
state. Marimo-lsp doesn't surface code_mode yet, so the only legitimate
use of these echoes (propagating programmatic value changes) doesn't
apply, and dropping them entirely is safe.

This is a temporary guard we can remove once the upstream
`notify_frontend` gate (marimo-team/marimo#9262) ships and we can
upgrade.
manzt added a commit to marimo-team/marimo-lsp that referenced this pull request Apr 18, 2026
Fixes #515

The kernel broadcasts this message after every UI value change. Over LSP
it arrives ~one round-trip stale and clobbers the user's in-progress
state. Marimo-lsp doesn't surface code_mode yet, so the only legitimate
use of these echoes (propagating programmatic value changes) doesn't
apply, and dropping them entirely is safe.

This is a temporary guard we can remove once the upstream
`notify_frontend` gate (marimo-team/marimo#9262) ships and we can
upgrade.
Comment thread marimo/_ast/app.py Outdated
self,
request: UpdateUIElementCommand,
*,
notify_frontend: bool = False,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth removing the default so it's always explicit? seems like you covered all the cases anyways

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's great call.

@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (manzt)[https://github.com/manzt]
❌ @Copilot
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@manzt
Copy link
Copy Markdown
Collaborator Author

manzt commented Apr 19, 2026

i tried the copilot agent from my phone to make the naming fix, no CLA lol

@manzt manzt merged commit d21f51c into main Apr 20, 2026
28 of 43 checks passed
@manzt manzt deleted the push-ltuwuvrsukuw branch April 20, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants