Skip to content

Add typed DataChangeEvent.jsonValue and deprecate string value - #27

Merged
contextablemark merged 2 commits into
mainfrom
fix/data-change-event-json-value
Oct 17, 2026
Merged

contextablemark merged 2 commits into
mainfrom
fix/data-change-event-json-value

Conversation

@contextablemark

Copy link
Copy Markdown
Member

Fixes #26

Problem

DataChangeEvent.value is a String, so input widgets flatten what they emit even though the data model holds typed values:

Widget Data model value
ChoicePicker ["a","b"] "a,b"
CheckBox true "true"
Slider 42.0 "42.0"

The v0.8 dataChange message (an a2ui-4k extension; the v0.8 spec defines only userAction and error) sent that string on the wire.

Change

Option 1 from #26, which avoids breaking the API:

  • Add DataChangeEvent.jsonValue: JsonElement, defaulting to JsonPrimitive(value), so existing code that creates the event keeps compiling and old serialized events still decode.
  • ChoicePicker, CheckBox and Slider populate jsonValue with the same value they write to the data model. Their string value is unchanged.
  • The v0.8 dataChange message sends jsonValue.
  • Deprecate value (warning level, no ReplaceWith, 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

  • Source: compatible. Reading event.value produces a deprecation warning.
  • JVM binary: the constructor and copy() signatures change, so code compiled against the old version must be recompiled.
  • Behavior: v0.8 dataChange.value is now typed instead of a string (noted under Changed in the CHANGELOG).

Testing

  • New tests in UiEventTest: both fields kept side by side, JSON round-trip with an array value, decoding old JSON without jsonValue, and the v0.8 message preserving array, boolean and number types.
  • JVM (495 tests), Android unit and iOS simulator tests pass; the JS target and the example app compile.
  • No widget-level tests: the widgets create the event inside Compose click handlers, and the project has no Compose UI test setup.

🤖 Generated with Claude Code

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>
@contextablemark
contextablemark merged commit 9139d2a into main Oct 17, 2026
1 check passed
@contextablemark contextablemark mentioned this pull request Oct 17, 2026
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.

DataChangeEvent.value is a String, so multi-select (and number/boolean) changes lose their JSON type

1 participant