Skip to content

feat(genui): add AsynchronousClientFunction base class - #1041

Merged
gspencergoog merged 1 commit into
flutter:mainfrom
gspencergoog:async-client-function
Sep 30, 2026
Merged

gspencergoog merged 1 commit into
flutter:mainfrom
gspencergoog:async-client-function

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Introduces AsynchronousClientFunction in packages/genui, establishing a symmetrical base class for asynchronous client-side functions returning a Future (via executeAsync), complementing the existing SynchronousClientFunction (executeSync) without breaking changes.

Resolves a2ui-project/a2ui#2066

Changes

  • packages/genui/lib/src/model/client_function.dart:
    • Added abstract class AsynchronousClientFunction implements ClientFunction requiring Future<Object?> executeAsync(JsonMap args, ExecutionContext context) and wrapping it lazily using an async* generator (yield await executeAsync(args, context)).
    • Added default @override ClientFunctionReturnType get returnType => ClientFunctionReturnType.any; to both SynchronousClientFunction and AsynchronousClientFunction.
    • Updated dartdoc comments to cross-reference SynchronousClientFunction, AsynchronousClientFunction, and the streaming ClientFunction interface.
  • packages/genui/pubspec.yaml:
    • Bumped version to 0.10.6 to match CHANGELOG.md and satisfy Firehose publish validation.
  • docs/contributing/design.md:
    • Documented ClientFunction, SynchronousClientFunction, and AsynchronousClientFunction under Section 3 (UI Model Layer).
  • packages/genui/CHANGELOG.md:
    • Added 0.10.6 release entry noting the addition of AsynchronousClientFunction.
  • packages/genui/test/model/client_function_test.dart:
    • Added unit tests covering synchronous/asynchronous execution, lazy evaluation, exception propagation into stream errors, null returns, and Catalog/DataContext integration.

Impact & Risks

  • Zero breaking changes: 100% backward-compatible. Existing implementations of SynchronousClientFunction (all basic catalog functions) and ClientFunction (such as FormatStringFunction) remain completely unaffected.

Testing

  • Ran flutter analyze packages/genui (0 issues).
  • Ran flutter test packages/genui/test/model/client_function_test.dart (all tests passing).
  • Ran full package test suite flutter test packages/genui (all 365 tests passing).
  • Verified formatting with dart format.

gemini-code-assist[bot]

This comment was marked as resolved.

@gspencergoog gspencergoog changed the title feat(genui): add AsynchronousClientFunction and sync/async aliases feat(genui)!: rename client functions to SyncClientFunction and AsyncClientFunction Sep 23, 2026
@gspencergoog gspencergoog changed the title feat(genui)!: rename client functions to SyncClientFunction and AsyncClientFunction feat(genui): add AsynchronousClientFunction base class Sep 23, 2026
@gspencergoog gspencergoog changed the title feat(genui): add AsynchronousClientFunction base class feat(genui): add AsynchronousClientFunction base class Sep 23, 2026

@andrewkolos andrewkolos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Add `AsynchronousClientFunction` to complement `SynchronousClientFunction`
and provide a symmetrical implementation pattern for asynchronous client
functions in GenUI without breaking changes.

- Added `AsynchronousClientFunction implements ClientFunction` with lazy `async*` execution calling `Future<Object?> executeAsync(JsonMap args, ExecutionContext context)`.
- Added default `returnType => ClientFunctionReturnType.any` on both `SynchronousClientFunction` and `AsynchronousClientFunction`.
- Updated documentation in `docs/contributing/design.md` and added release notes to `CHANGELOG.md`.
- Bumped `pubspec.yaml` to 0.10.6 to match `CHANGELOG.md`.
- Added comprehensive unit tests in `packages/genui/test/model/client_function_test.dart` including lazy evaluation verification.

Addresses a2ui-project/a2ui#2066
@gspencergoog
gspencergoog merged commit f63f4ad into flutter:main Sep 30, 2026
43 checks passed
sunamo added a commit to sunamo/genui that referenced this pull request Oct 2, 2026
* build: task dev pousti flutter pres FlutterAutoHotReload (auto hot reload)

* Submodule URL na SSH

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: replace CoreCatalogItems with BasicCatalogItems in READMEs (flutter#966)

* fix(genui): show a literal CheckBox value (flutter#1038)

`CheckBox.value` is a `booleanReference`: a literal, a `{"path": ...}`
binding and a `{"call": ...}` are all valid. The widget bound to a data
model path and never read the literal, so a component that said the
setting was on rendered unchecked and announced itself unchecked, with
nothing logged to say the value had been dropped.

`Slider` and `TextField` already fall back to the literal until the path
holds something. This does the same, so the three inputs of the basic
catalog now treat their value the same way.

* Fix/email validation regex (flutter#1026)

Fix the email validation function by correcting the regex escape pattern.

The previous implementation used an escaped `$` in a raw string, which caused the regex to match a literal `$` character instead of the end-of-string anchor.

Update the regex pattern to properly validate email formats.

# Description

This PR fixes an issue in the email validation function where the regular expression pattern did not correctly handle the end-of-string anchor.

The previous implementation incorrectly escaped the `$` character inside a Dart raw string. As a result, the regex engine treated it as a literal character instead of the end-of-string matcher, causing valid email addresses to fail validation.

This change updates the regex pattern to use the correct `$` anchor and ensures email validation behaves as expected.

## Related Issues

Fixes a2ui-project/a2ui#2854

* fix: fix validation checks and preserve error messages in basic catalog (flutter#1045)

* Add RESUME.cs.md project summary and remove tracked build output

* Add GitHub origin section to RESUME.cs.md

* Upgrade RESUME.cs.md to schema version 3

* Add README and rewrite RESUME.cs.md description and origin

* Add deletion recommendation reason to RESUME.cs.md

* Add commit history to RESUME.cs.md

* feat(genui): add `AsynchronousClientFunction` base class (flutter#1041)

## Summary

Introduces `AsynchronousClientFunction` in `packages/genui`, establishing a symmetrical base class for asynchronous client-side functions returning a `Future` (via `executeAsync`), complementing the existing `SynchronousClientFunction` (`executeSync`) without breaking changes.

Resolves a2ui-project/a2ui#2066

## Changes

- **`packages/genui/lib/src/model/client_function.dart`**:
  - Added `abstract class AsynchronousClientFunction implements ClientFunction` requiring `Future<Object?> executeAsync(JsonMap args, ExecutionContext context)` and wrapping it lazily using an `async*` generator (`yield await executeAsync(args, context)`).
  - Added default `@override ClientFunctionReturnType get returnType => ClientFunctionReturnType.any;` to both `SynchronousClientFunction` and `AsynchronousClientFunction`.
  - Updated dartdoc comments to cross-reference `SynchronousClientFunction`, `AsynchronousClientFunction`, and the streaming `ClientFunction` interface.
- **`packages/genui/pubspec.yaml`**:
  - Bumped version to `0.10.6` to match `CHANGELOG.md` and satisfy Firehose publish validation.
- **`docs/contributing/design.md`**:
  - Documented `ClientFunction`, `SynchronousClientFunction`, and `AsynchronousClientFunction` under Section 3 (UI Model Layer).
- **`packages/genui/CHANGELOG.md`**:
  - Added `0.10.6` release entry noting the addition of `AsynchronousClientFunction`.
- **`packages/genui/test/model/client_function_test.dart`**:
  - Added unit tests covering synchronous/asynchronous execution, lazy evaluation, exception propagation into stream errors, null returns, and Catalog/DataContext integration.

## Impact & Risks

- **Zero breaking changes**: 100% backward-compatible. Existing implementations of `SynchronousClientFunction` (all basic catalog functions) and `ClientFunction` (such as `FormatStringFunction`) remain completely unaffected.

* fix: make Slider continuous by default (flutter#1039)

## Summary

Makes `Slider` continuous (`divisions: null`) by default, resolving assertion crashes on sub-unit ranges and eliminating 2-position switch behavior over the standard `[0.0, 1.0]` range.

Note that once v1.0 is implemented, the `steps` argument will provide the `divisions` settings again.

Fixes a2ui-project/a2ui#2737

## Changes

- **Continuous default**: Removed `divisions: (sliderData.max - sliderData.min).toInt()` in favor of continuous movement (`divisions: null`), as specified in A2UI v0.9 / v0.9.1.
- **Value clamping**: Added defensive `.clamp(sliderData.min, sliderData.max)` on slider value binding.
- **Display value & literal fallback**: Updated the thumb label to use `currentVal` (which is clamped to `[min, max]`, ensuring the label matches the visual thumb position) and formatted values via `_formatSliderValue` with 6-decimal precision to present whole numbers cleanly (`"10"`) and preserve fractional decimals (`"0.5"`, `"0.005"`) rather than truncating with `toStringAsFixed(0)`.
- **Tests**: Expanded `packages/genui/test/catalog/core_widgets/slider_test.dart` with tests for default continuous behavior (`divisions: null`), sub-unit ranges (`min: 0, max: 0.5`), literal value fallback, number formatting, and out-of-bounds label clamping.
- **Linter fixes**: Resolved 80-character line limit and added explicit type annotations required by `flutter analyze`.

## Impact & Risks

- **Breaking changes**: None. In A2UI v0.9.1, `Slider` does not specify discrete steps; continuous movement is the expected default.
- **Risk**: Low. All 347 tests in `packages/genui` pass.

* fix: address review feedback on validation checks and truthiness (flutter#1047)

* Add announcement about package replacement. (flutter#1046)

* Update README and RESUME summary to schema 6

* Fill build and test status fields in RESUME

---------

Co-authored-by: smutekutek <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Victor Eronmosele <[email protected]>
Co-authored-by: Diego López <[email protected]>
Co-authored-by: cubegao <[email protected]>
Co-authored-by: jacobsimionato <[email protected]>
Co-authored-by: Greg Spencer <[email protected]>
Co-authored-by: Polina Cherkasova <[email protected]>
sunamo added a commit to sunamo/genui that referenced this pull request Oct 4, 2026
* build: task dev pousti flutter pres FlutterAutoHotReload (auto hot reload)

* Submodule URL na SSH

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: replace CoreCatalogItems with BasicCatalogItems in READMEs (flutter#966)

* fix(genui): show a literal CheckBox value (flutter#1038)

`CheckBox.value` is a `booleanReference`: a literal, a `{"path": ...}`
binding and a `{"call": ...}` are all valid. The widget bound to a data
model path and never read the literal, so a component that said the
setting was on rendered unchecked and announced itself unchecked, with
nothing logged to say the value had been dropped.

`Slider` and `TextField` already fall back to the literal until the path
holds something. This does the same, so the three inputs of the basic
catalog now treat their value the same way.

* Fix/email validation regex (flutter#1026)

Fix the email validation function by correcting the regex escape pattern.

The previous implementation used an escaped `$` in a raw string, which caused the regex to match a literal `$` character instead of the end-of-string anchor.

Update the regex pattern to properly validate email formats.

# Description

This PR fixes an issue in the email validation function where the regular expression pattern did not correctly handle the end-of-string anchor.

The previous implementation incorrectly escaped the `$` character inside a Dart raw string. As a result, the regex engine treated it as a literal character instead of the end-of-string matcher, causing valid email addresses to fail validation.

This change updates the regex pattern to use the correct `$` anchor and ensures email validation behaves as expected.

## Related Issues

Fixes a2ui-project/a2ui#2854

* fix: fix validation checks and preserve error messages in basic catalog (flutter#1045)

* Add RESUME.cs.md project summary and remove tracked build output

* Add GitHub origin section to RESUME.cs.md

* Upgrade RESUME.cs.md to schema version 3

* Add README and rewrite RESUME.cs.md description and origin

* Add deletion recommendation reason to RESUME.cs.md

* Add commit history to RESUME.cs.md

* feat(genui): add `AsynchronousClientFunction` base class (flutter#1041)

## Summary

Introduces `AsynchronousClientFunction` in `packages/genui`, establishing a symmetrical base class for asynchronous client-side functions returning a `Future` (via `executeAsync`), complementing the existing `SynchronousClientFunction` (`executeSync`) without breaking changes.

Resolves a2ui-project/a2ui#2066

## Changes

- **`packages/genui/lib/src/model/client_function.dart`**:
  - Added `abstract class AsynchronousClientFunction implements ClientFunction` requiring `Future<Object?> executeAsync(JsonMap args, ExecutionContext context)` and wrapping it lazily using an `async*` generator (`yield await executeAsync(args, context)`).
  - Added default `@override ClientFunctionReturnType get returnType => ClientFunctionReturnType.any;` to both `SynchronousClientFunction` and `AsynchronousClientFunction`.
  - Updated dartdoc comments to cross-reference `SynchronousClientFunction`, `AsynchronousClientFunction`, and the streaming `ClientFunction` interface.
- **`packages/genui/pubspec.yaml`**:
  - Bumped version to `0.10.6` to match `CHANGELOG.md` and satisfy Firehose publish validation.
- **`docs/contributing/design.md`**:
  - Documented `ClientFunction`, `SynchronousClientFunction`, and `AsynchronousClientFunction` under Section 3 (UI Model Layer).
- **`packages/genui/CHANGELOG.md`**:
  - Added `0.10.6` release entry noting the addition of `AsynchronousClientFunction`.
- **`packages/genui/test/model/client_function_test.dart`**:
  - Added unit tests covering synchronous/asynchronous execution, lazy evaluation, exception propagation into stream errors, null returns, and Catalog/DataContext integration.

## Impact & Risks

- **Zero breaking changes**: 100% backward-compatible. Existing implementations of `SynchronousClientFunction` (all basic catalog functions) and `ClientFunction` (such as `FormatStringFunction`) remain completely unaffected.

* fix: make Slider continuous by default (flutter#1039)

## Summary

Makes `Slider` continuous (`divisions: null`) by default, resolving assertion crashes on sub-unit ranges and eliminating 2-position switch behavior over the standard `[0.0, 1.0]` range.

Note that once v1.0 is implemented, the `steps` argument will provide the `divisions` settings again.

Fixes a2ui-project/a2ui#2737

## Changes

- **Continuous default**: Removed `divisions: (sliderData.max - sliderData.min).toInt()` in favor of continuous movement (`divisions: null`), as specified in A2UI v0.9 / v0.9.1.
- **Value clamping**: Added defensive `.clamp(sliderData.min, sliderData.max)` on slider value binding.
- **Display value & literal fallback**: Updated the thumb label to use `currentVal` (which is clamped to `[min, max]`, ensuring the label matches the visual thumb position) and formatted values via `_formatSliderValue` with 6-decimal precision to present whole numbers cleanly (`"10"`) and preserve fractional decimals (`"0.5"`, `"0.005"`) rather than truncating with `toStringAsFixed(0)`.
- **Tests**: Expanded `packages/genui/test/catalog/core_widgets/slider_test.dart` with tests for default continuous behavior (`divisions: null`), sub-unit ranges (`min: 0, max: 0.5`), literal value fallback, number formatting, and out-of-bounds label clamping.
- **Linter fixes**: Resolved 80-character line limit and added explicit type annotations required by `flutter analyze`.

## Impact & Risks

- **Breaking changes**: None. In A2UI v0.9.1, `Slider` does not specify discrete steps; continuous movement is the expected default.
- **Risk**: Low. All 347 tests in `packages/genui` pass.

* fix: address review feedback on validation checks and truthiness (flutter#1047)

* Add announcement about package replacement. (flutter#1046)

* Update README and RESUME summary to schema 6

* Fill build and test status fields in RESUME

* Add article source fields to RESUME.cs.md

* Update repository type in RESUME.cs.md to sample

* Fill origin_checked date in RESUME.cs.md

* Replace n/a with found/not found/not run in RESUME.cs.md (schema 10)

* Set repository type to notmine_sample in RESUME.cs.md

* Set repository type to forked_notmine_sample in RESUME.cs.md

* Rename type values in RESUME.cs.md to hyphenated form

* Add file extension counts to RESUME (schema 11)

---------

Co-authored-by: smutekutek <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Victor Eronmosele <[email protected]>
Co-authored-by: Diego López <[email protected]>
Co-authored-by: cubegao <[email protected]>
Co-authored-by: jacobsimionato <[email protected]>
Co-authored-by: Greg Spencer <[email protected]>
Co-authored-by: Polina Cherkasova <[email protected]>
sunamo added a commit to sunamo/genui that referenced this pull request Nov 3, 2026
* build: task dev pousti flutter pres FlutterAutoHotReload (auto hot reload)

* Submodule URL na SSH

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: replace CoreCatalogItems with BasicCatalogItems in READMEs (flutter#966)

* fix(genui): show a literal CheckBox value (flutter#1038)

`CheckBox.value` is a `booleanReference`: a literal, a `{"path": ...}`
binding and a `{"call": ...}` are all valid. The widget bound to a data
model path and never read the literal, so a component that said the
setting was on rendered unchecked and announced itself unchecked, with
nothing logged to say the value had been dropped.

`Slider` and `TextField` already fall back to the literal until the path
holds something. This does the same, so the three inputs of the basic
catalog now treat their value the same way.

* Fix/email validation regex (flutter#1026)

Fix the email validation function by correcting the regex escape pattern.

The previous implementation used an escaped `$` in a raw string, which caused the regex to match a literal `$` character instead of the end-of-string anchor.

Update the regex pattern to properly validate email formats.

# Description

This PR fixes an issue in the email validation function where the regular expression pattern did not correctly handle the end-of-string anchor.

The previous implementation incorrectly escaped the `$` character inside a Dart raw string. As a result, the regex engine treated it as a literal character instead of the end-of-string matcher, causing valid email addresses to fail validation.

This change updates the regex pattern to use the correct `$` anchor and ensures email validation behaves as expected.

## Related Issues

Fixes a2ui-project/a2ui#2854

* fix: fix validation checks and preserve error messages in basic catalog (flutter#1045)

* Add RESUME.cs.md project summary and remove tracked build output

* Add GitHub origin section to RESUME.cs.md

* Upgrade RESUME.cs.md to schema version 3

* Add README and rewrite RESUME.cs.md description and origin

* Add deletion recommendation reason to RESUME.cs.md

* Add commit history to RESUME.cs.md

* feat(genui): add `AsynchronousClientFunction` base class (flutter#1041)

## Summary

Introduces `AsynchronousClientFunction` in `packages/genui`, establishing a symmetrical base class for asynchronous client-side functions returning a `Future` (via `executeAsync`), complementing the existing `SynchronousClientFunction` (`executeSync`) without breaking changes.

Resolves a2ui-project/a2ui#2066

## Changes

- **`packages/genui/lib/src/model/client_function.dart`**:
  - Added `abstract class AsynchronousClientFunction implements ClientFunction` requiring `Future<Object?> executeAsync(JsonMap args, ExecutionContext context)` and wrapping it lazily using an `async*` generator (`yield await executeAsync(args, context)`).
  - Added default `@override ClientFunctionReturnType get returnType => ClientFunctionReturnType.any;` to both `SynchronousClientFunction` and `AsynchronousClientFunction`.
  - Updated dartdoc comments to cross-reference `SynchronousClientFunction`, `AsynchronousClientFunction`, and the streaming `ClientFunction` interface.
- **`packages/genui/pubspec.yaml`**:
  - Bumped version to `0.10.6` to match `CHANGELOG.md` and satisfy Firehose publish validation.
- **`docs/contributing/design.md`**:
  - Documented `ClientFunction`, `SynchronousClientFunction`, and `AsynchronousClientFunction` under Section 3 (UI Model Layer).
- **`packages/genui/CHANGELOG.md`**:
  - Added `0.10.6` release entry noting the addition of `AsynchronousClientFunction`.
- **`packages/genui/test/model/client_function_test.dart`**:
  - Added unit tests covering synchronous/asynchronous execution, lazy evaluation, exception propagation into stream errors, null returns, and Catalog/DataContext integration.

## Impact & Risks

- **Zero breaking changes**: 100% backward-compatible. Existing implementations of `SynchronousClientFunction` (all basic catalog functions) and `ClientFunction` (such as `FormatStringFunction`) remain completely unaffected.

* fix: make Slider continuous by default (flutter#1039)

## Summary

Makes `Slider` continuous (`divisions: null`) by default, resolving assertion crashes on sub-unit ranges and eliminating 2-position switch behavior over the standard `[0.0, 1.0]` range.

Note that once v1.0 is implemented, the `steps` argument will provide the `divisions` settings again.

Fixes a2ui-project/a2ui#2737

## Changes

- **Continuous default**: Removed `divisions: (sliderData.max - sliderData.min).toInt()` in favor of continuous movement (`divisions: null`), as specified in A2UI v0.9 / v0.9.1.
- **Value clamping**: Added defensive `.clamp(sliderData.min, sliderData.max)` on slider value binding.
- **Display value & literal fallback**: Updated the thumb label to use `currentVal` (which is clamped to `[min, max]`, ensuring the label matches the visual thumb position) and formatted values via `_formatSliderValue` with 6-decimal precision to present whole numbers cleanly (`"10"`) and preserve fractional decimals (`"0.5"`, `"0.005"`) rather than truncating with `toStringAsFixed(0)`.
- **Tests**: Expanded `packages/genui/test/catalog/core_widgets/slider_test.dart` with tests for default continuous behavior (`divisions: null`), sub-unit ranges (`min: 0, max: 0.5`), literal value fallback, number formatting, and out-of-bounds label clamping.
- **Linter fixes**: Resolved 80-character line limit and added explicit type annotations required by `flutter analyze`.

## Impact & Risks

- **Breaking changes**: None. In A2UI v0.9.1, `Slider` does not specify discrete steps; continuous movement is the expected default.
- **Risk**: Low. All 347 tests in `packages/genui` pass.

* fix: address review feedback on validation checks and truthiness (flutter#1047)

* Add announcement about package replacement. (flutter#1046)

* Update README and RESUME summary to schema 6

* Fill build and test status fields in RESUME

* Add article source fields to RESUME.cs.md

* Update repository type in RESUME.cs.md to sample

* Fill origin_checked date in RESUME.cs.md

* Replace n/a with found/not found/not run in RESUME.cs.md (schema 10)

* Set repository type to notmine_sample in RESUME.cs.md

* Set repository type to forked_notmine_sample in RESUME.cs.md

* Rename type values in RESUME.cs.md to hyphenated form

* Add file extension counts to RESUME (schema 11)

---------

Co-authored-by: smutekutek <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Victor Eronmosele <[email protected]>
Co-authored-by: Diego López <[email protected]>
Co-authored-by: cubegao <[email protected]>
Co-authored-by: jacobsimionato <[email protected]>
Co-authored-by: Greg Spencer <[email protected]>
Co-authored-by: Polina Cherkasova <[email protected]>
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.

[FEATURE]: Rename ClientFunction to AsynchronousClientFunction in Flutter renderer

2 participants