fix: send vue event names in widget construction state, skip redundant _events sync#51
Merged
Merged
Conversation
use_event now merges the event name into the element's _events kwarg during the render phase, so the synced trait is part of the comm open message. ipyvue's on_event only syncs _events when the event set differs, so the one update message per widget per event disappears without any ipyvue or protocol change. When the element is memoized and the widget already exists, on_event falls back to syncing as before. Halves the websocket message count for vuetify-heavy apps: 2145 -> 1121 messages on a 1024-button page load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When a render context closes, every widget in it is about to have its comm closed, so syncing the _events trait after removing each event handler only produces one pointless update message per widget (1024 messages when leaving the 1024-button benchmark page). Partial subtree removal keeps the old behavior: an element owned by a surviving parent must still get its handler detached and synced. Also adds tests pinning the use_event message behavior: _events rides along with the widget construction state, never re-syncs on force_update or close, and still syncs when the event set changes on a persisting widget. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Two small, independent
ipyvue.use_eventchanges that cut websocket messages for vue-widget-heavy pages:Send the event name with construction state.
use_eventnow merges the event into the element's_eventskwarg during the render phase, so the synced_eventstrait travels with the widget'scomm_open. ipyvue'son_eventonly re-syncs_eventswhen the event set differs, so this removes oneupdatemessage per widget per event. When the element is memoized and the widget already exists,on_eventfalls back to syncing as before.Skip the
_eventssync during render-context close. When a render context closes, every widget's comm is about to close, soon_event(remove=True)'s trait sync produces one pointlessupdate {_events: []}message per widget right beforecomm_close. Skipped whenrc._closing; partial subtree removals still sync (a widget owned by a surviving parent must get its handler detached).Verification
pytest reacton/ipyvue_test.py— 3 new tests covering:_eventsset at construction, no re-sync onforce_update/close, and still syncing when the event set changes on a persisting widget. Full suite stays green (167 passed, 4 skipped).Note on the base
This is independent of the reconciler rewrite (verified against the current
masterrenderer) and touches onlyreacton/ipyvue.py+ a new test. It's stacked on #50 (the CI fix) purely so CI is green — retarget tomasteronce #50 merges.🤖 Generated with Claude Code