Repository navigation
Add typed DataChangeEvent.jsonValue and deprecate string value - #27
Merged
Merged
Conversation
DataChangeEvent.value is a String, so ChoicePicker emitted "a,b", CheckBox "true" and Slider "42.0" even though the data model holds an array, boolean and number. Add jsonValue: JsonElement (defaulting from value so existing constructors keep compiling), populate it from the widgets, use it for the v0.8 dataChange wire message, and deprecate value. Docs, migration skill and CHANGELOG updated. Fixes #26 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Fixes #26
Problem
DataChangeEvent.valueis aString, so input widgets flatten what they emit even though the data model holds typed values:value["a","b"]"a,b"true"true"42.0"42.0"The v0.8
dataChangemessage (an a2ui-4k extension; the v0.8 spec defines onlyuserActionanderror) sent that string on the wire.Change
Option 1 from #26, which avoids breaking the API:
DataChangeEvent.jsonValue: JsonElement, defaulting toJsonPrimitive(value), so existing code that creates the event keeps compiling and old serialized events still decode.jsonValuewith the same value they write to the data model. Their stringvalueis unchanged.dataChangemessage sendsjsonValue.value(warning level, noReplaceWith, since the types differ). It can be removed in a future minor release.Docs (events, checkbox, slider, getting-started), the 0.8→0.9 migration skill and the CHANGELOG are updated.
Compatibility
event.valueproduces a deprecation warning.copy()signatures change, so code compiled against the old version must be recompiled.dataChange.valueis now typed instead of a string (noted under Changed in the CHANGELOG).Testing
UiEventTest: both fields kept side by side, JSON round-trip with an array value, decoding old JSON withoutjsonValue, and the v0.8 message preserving array, boolean and number types.🤖 Generated with Claude Code