fix: Always invalidate server-side input values for incoming wire messages#2220
Merged
fix: Always invalidate server-side input values for incoming wire messages#2220
Conversation
…sages
The client sends a value over the wire in two cases: either it's a
genuinely new value, or it was sent with {priority: "event"} which
bypasses client-side deduplication (InputNoResendDecorator). Either way,
the server should accept this value as new and cause dependents to
recalculate.
Previously, Value._set() used an identity check (self._value is value)
that silently dropped updates for CPython-interned objects like small
integers. This meant Shiny.setInputValue("x", 42, {priority: "event"})
would only fire the reactive effect once, even though R Shiny fires it
every time.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nputs)
Tests that sending interned strings like "" and "x=1" with
{priority: "event"} correctly fires the reactive effect every time.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Not browser-specific behavior, no need to run on all browsers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84d7798 to
cacdb9c
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes server-side deduplication of incoming input values so that Shiny.setInputValue(..., {priority: "event"}) reliably triggers reactive invalidation on every send (including CPython-interned values like small ints and empty strings), aligning behavior with R Shiny’s dedupe = FALSE.
Changes:
- Updated session input handling to force incoming wire messages to be treated as “new” values (always invalidating dependents).
- Added a new Playwright regression app + tests covering integer/list values under default vs event priority, plus a dedicated string regression for #1600.
- Added a changelog entry describing the fix.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shiny/session/_session.py |
Adjusts server-side input update logic so incoming client values always trigger reactive invalidation. |
tests/playwright/shiny/inputs/input_setinputvalue_dedupe/app.py |
Adds a minimal Shiny app used to exercise setInputValue dedupe vs event semantics. |
tests/playwright/shiny/inputs/input_setinputvalue_dedupe/test_input_setinputvalue_dedupe.py |
Adds Playwright coverage for the regression scenarios (ints/lists/strings; default vs event). |
CHANGELOG.md |
Documents the bug fix for server-side input deduplication. |
Add `force=False` keyword arg to `_set()` that skips the identity short-circuit. This avoids fabricating a MISSING transition that would spuriously invalidate is_set() dependents on every input message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Confirms that force-setting the same value re-fires value dependents but does not spuriously invalidate is_set() dependents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Click both buttons per iteration so the event-priority assertion acts as a synchronization point, proving the default-priority click has been processed before asserting its count stayed at 1. Co-Authored-By: Claude Opus 4.6 <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.
Summary
Value._valuetoMISSINGbefore calling_set()in_manage_inputsso the server always accepts incoming Input values as new values{priority: "event"}which bypasses client-side dedup (InputNoResendDecorator). Either way, the server should invalidate dependents.Value._set()used identity (is) which silently dropped updates for CPython-interned objects (small ints, short strings), breakingpriority: "event"behaviorResolves #2219
Resolves #1600
Test plan
🤖 Generated with Claude Code