Repository navigation
Conversation
Infrastructure for gating widget traits that are expensive to sync and that nothing on the server reads. A renderer lists them in _muted_traits(); the browser comm then drops them from outgoing updates (with their binary buffers). No renderer mutes anything yet. SHINYWIDGETS_NATIVE_EVENTS=1 turns muting off for every output.
This was referenced Nov 13, 2026
…ent-mute-traits # Conflicts: # js/src/comm.test.ts # js/src/output.ts # shinywidgets/static/output.js
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.
Part of #479. Stacked on #484 (main ← #483 ← #484 ← this ← #488); the plotly PR on top is where behavior changes.
Some widgets sync traits from the browser to Python that are expensive and that nothing on the server reads. plotly.py's per-point selection report is the motivating case (#479), but nothing about the mechanism is plotly-specific. This PR lets a renderer say "don't sync these traits from the browser", and the browser then drops them from outgoing updates, including their binary buffers. No renderer uses it yet, so this changes no behavior on its own.
It also adds
SHINYWIDGETS_NATIVE_EVENTS=1, a single switch that turns muting off for every output. That's the escape hatch for a deployment you can't edit app code for, and it will apply to any renderer that mutes something later.Where to look
js/src/comm.ts:ShinyComm.send()filters anupdatemessage'sstate(and the matchingbuffer_paths/buffers) against the muted set. If nothing is left it isn't sent, and the comm reports idle itself, since nothing will ack a message that never went out and ipywidgets holds later changes until the in-flight one is idle.shinywidgets/_render_widget_base.py: a renderer overrides_muted_traits(widget); after each render the base class sends the browser a{"shinywidgets": "mute", "traits": [...]}request. Each render restates the full set.js/src/output.ts: routes that request to the model's comm, next to the existing bind requests.Custom messages are never filtered, only
updates.Interaction with #481
#481 edits the same
ShinyComm.send().mainis merged into the stack, with the one real collision resolved: both sides declaredconst onIdle, so I kept a single declaration at the top ofsend(). The mute filter runs first and the size guard second, so a message that only sets muted traits is never measured. Both sets of vitest tests pass together.Testing
1,true) and off values.shinywidgets/static/output.jsis the rebuilt bundle.