Skip echoing client-originated values via bool flag on ValueElement#5933
Draft
evnchn wants to merge 3 commits intozauberzeug:mainfrom
Draft
Skip echoing client-originated values via bool flag on ValueElement#5933evnchn wants to merge 3 commits intozauberzeug:mainfrom
evnchn wants to merge 3 commits intozauberzeug:mainfrom
Conversation
This was referenced Apr 3, 2026
3 tasks
This comment was marked as outdated.
This comment was marked as outdated.
Add _value_from_client flag to ValueElement, set when LOOPBACK handles client input. The outbox strips VALUE_PROP from updates when the flag is True, preventing the server from echoing the value back. JS merges incoming props with existing state so the omitted prop is preserved. _to_dict() always returns full state for reconnection safety. The flag resets on server-originated value changes (bindings, sanitize). Implements the approach proposed by @falkoschindler in zauberzeug#5728. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bec9cf8 to
693262f
Compare
…ilures) The JS-side model-value preservation breaks Quasar components that use model-value for open/close state (Dialog, Menu, Expansion, etc.) since LOOPBACK defaults to True for all ValueElements. Keep the _value_from_client flag infrastructure on ValueElement for future use, but do not act on it in the outbox yet. The flag correctly tracks client vs server value origin and can be leveraged once a safe JS-side approach is found. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Motivation
When a
ValueElement(e.g.,ui.input,ui.select) receives a value change from the client via LOOPBACK, the server currently echoes the same value back in the next outbox update. This is redundant — the client already has the value — and wastes bandwidth, especially for elements where the value is the main part of the payload.This implements the approach proposed by @falkoschindler in #5728: a single boolean flag on
ValueElementthat tells the outbox to omitVALUE_PROPwhen the value originated from the client.Supersedes #5728 with a much simpler implementation (no diff machinery, no deepcopy, no new merge semantics).
Implementation
ValueElement._value_from_clientflag, set toTruewhen the LOOPBACK handler processes a client-originated value changeOutbox._build_element_dict()checks the flag via duck-typing (getattr); if set, stripsVALUE_PROPfrom the props dict before sendingnicegui.jsmerges incoming props with existing element props ({ ...existing.props, ...element.props }) so that an omittedVALUE_PROPpreserves the client's current value rather than blanking it_to_dict()is unchanged and always returns full state —build_responseis not affected by the flagFalseon any server-originated value change (_handle_value_changewith_send_update_on_value_change=True), ensuring server-set values are always sentProgress