Skip to content

fix: send vue event names in widget construction state, skip redundant _events sync#51

Merged
maartenbreddels merged 2 commits into
masterfrom
fix/ipyvue-events-in-construction
Jun 15, 2026
Merged

fix: send vue event names in widget construction state, skip redundant _events sync#51
maartenbreddels merged 2 commits into
masterfrom
fix/ipyvue-events-in-construction

Conversation

@maartenbreddels

Copy link
Copy Markdown
Contributor

What

Two small, independent ipyvue.use_event changes that cut websocket messages for vue-widget-heavy pages:

  1. Send the event name with construction state. use_event now merges the event into the element's _events kwarg during the render phase, so the synced _events trait travels with the widget's comm_open. ipyvue's on_event only re-syncs _events when the event set differs, so this removes one update message per widget per event. When the element is memoized and the widget already exists, on_event falls back to syncing as before.

  2. Skip the _events sync during render-context close. When a render context closes, every widget's comm is about to close, so on_event(remove=True)'s trait sync produces one pointless update {_events: []} message per widget right before comm_close. Skipped when rc._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: _events set at construction, no re-sync on force_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 master renderer) and touches only reacton/ipyvue.py + a new test. It's stacked on #50 (the CI fix) purely so CI is green — retarget to master once #50 merges.

🤖 Generated with Claude Code

maartenbreddels and others added 2 commits June 15, 2026 17:28
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>
@maartenbreddels maartenbreddels changed the base branch from ci/fix-runners to master June 15, 2026 15:35
@maartenbreddels maartenbreddels merged commit 3a1f62a into master Jun 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant