Skip to content

Skip echoing client-originated values via bool flag on ValueElement#5933

Draft
evnchn wants to merge 3 commits intozauberzeug:mainfrom
evnchn:fix/outbox-value-flag
Draft

Skip echoing client-originated values via bool flag on ValueElement#5933
evnchn wants to merge 3 commits intozauberzeug:mainfrom
evnchn:fix/outbox-value-flag

Conversation

@evnchn
Copy link
Copy Markdown
Collaborator

@evnchn evnchn commented Apr 3, 2026

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 ValueElement that tells the outbox to omit VALUE_PROP when 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_client flag, set to True when the LOOPBACK handler processes a client-originated value change
  • Outbox._build_element_dict() checks the flag via duck-typing (getattr); if set, strips VALUE_PROP from the props dict before sending
  • nicegui.js merges incoming props with existing element props ({ ...existing.props, ...element.props }) so that an omitted VALUE_PROP preserves the client's current value rather than blanking it
  • Reconnection safety: _to_dict() is unchanged and always returns full state — build_response is not affected by the flag
  • Flag reset: the flag resets to False on any server-originated value change (_handle_value_change with _send_update_on_value_change=True), ensuring server-set values are always sent

Progress

  • The PR title is a short phrase starting with a verb like "Add ...", "Fix ...", "Update ...", "Remove ...", etc.
  • The implementation is complete.
  • This PR does not address a security issue.
  • Pytests have been added/updated.
  • Documentation has been added/updated or is not necessary.
  • No breaking changes to the public API or migration steps are described above.

@evnchn

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>
@evnchn evnchn force-pushed the fix/outbox-value-flag branch from bec9cf8 to 693262f Compare April 3, 2026 15:14
evnchn and others added 2 commits April 4, 2026 00:01
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Type/scope: New or intentionally changed behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant