-
Notifications
You must be signed in to change notification settings - Fork 159
feat(genui): support functions in prompts and verify rendering #921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gspencergoog
wants to merge
29
commits into
flutter:main
Choose a base branch
from
gspencergoog:add_prompt_functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,886
−1,207
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a24693d
feat(genui): support functions in prompts and verify rendering
gspencergoog 4134cb3
feat(genui): refactor PromptBuilder to use spec schemas and async API
gspencergoog f9f9e21
Merge branch 'main' into add_prompt_functions
gspencergoog 1affaab
fix(genui): remove duplicate 'component' in required list in prompt
gspencergoog cb629b6
feat(genui): use $refs in A2uiSchemas and add custom component test
gspencergoog fb4a577
Merge branch 'main' into add_prompt_functions
gspencergoog 9c47110
Fix formatting
gspencergoog ab3593a
Merge branch 'main' into add_prompt_functions
gspencergoog b7bba17
fix(genui): resolve schema references in tests and fix async hangs in…
gspencergoog 341789f
Fix copyright
gspencergoog 6d21e7b
refactor(genui): use platform-agnostic URIs for schema reference reso…
gspencergoog 5fe5754
fix(genui): use type check instead of unsafe type cast for required p…
gspencergoog 6a4ad57
refactor(genui): compose enum constraints with DynamicString schema t…
gspencergoog 8aff417
feat(genui): implement secure error boundaries to prevent system stac…
gspencergoog f5c991b
fix(genui): add theme, anyComponent, and anyFunction schemas to catal…
gspencergoog ea68855
refactor(genui): extract duplicated schema asset loading into a stati…
gspencergoog c6858ab
refactor(genui): centralize A2UI schema URIs, asset keys, and local p…
gspencergoog fc669bd
Merge remote-tracking branch 'upstream/main' into add_prompt_functions
gspencergoog f27595c
refactor(genui): link schema assets to root submodule and support agn…
gspencergoog 0520535
chore(genui): remove obsolete nested submodule path exclusion from an…
gspencergoog c7fd032
Merge branch 'main' into add_prompt_functions
gspencergoog 0f94f83
feat(genui)!: change PromptBuilder to load schemas asynchronously and…
gspencergoog 47379fe
refactor(genui): restrict public exports of primitives constants and …
gspencergoog 7bc9578
refactor(genui): move show filter clauses to src/primitives.dart barr…
gspencergoog 49d8733
docs(genui): document restricted primitives exports breaking change i…
gspencergoog ed852c5
ci: enable checkout_submodules in publish workflow
gspencergoog 4b86f68
Merge branch 'main' into add_prompt_functions
gspencergoog d01af22
Added CHANGELOG entry for version bump
gspencergoog 5506f98
fix(genui): fix switchMap resource leak and add missing tests to rest…
gspencergoog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2025 The Flutter Authors. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:convert'; | ||
| import 'dart:typed_data'; | ||
|
|
||
| import 'package:catalog_gallery/sample_source.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('AssetSampleSource', () { | ||
| test('listSamples loads and parses samples from asset bundle', () async { | ||
| final binaryMessenger = | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger; | ||
|
|
||
| // Mock AssetManifest.bin | ||
| final manifestData = { | ||
| 'samples/hello.sample': [ | ||
| {'asset': 'samples/hello.sample'}, | ||
| ], | ||
| 'samples/world.sample': [ | ||
| {'asset': 'samples/world.sample'}, | ||
| ], | ||
| 'other/file.txt': [ | ||
| {'asset': 'other/file.txt'}, | ||
| ], | ||
| }; | ||
|
|
||
| final ByteData manifestByteData = const StandardMessageCodec() | ||
| .encodeMessage(manifestData)!; | ||
|
|
||
| binaryMessenger.setMockMessageHandler('flutter/assets', ( | ||
| ByteData? message, | ||
| ) async { | ||
| final String key = utf8.decode(message!.buffer.asUint8List()); | ||
| if (key == 'AssetManifest.bin' || key == 'AssetManifest.json') { | ||
| return manifestByteData; | ||
| } | ||
| if (key == 'samples/hello.sample') { | ||
| return ByteData.view(utf8.encode('hello content').buffer); | ||
| } | ||
| if (key == 'samples/world.sample') { | ||
| return ByteData.view(utf8.encode('world content').buffer); | ||
| } | ||
| return null; | ||
| }); | ||
|
|
||
| addTearDown(() { | ||
| binaryMessenger.setMockMessageHandler('flutter/assets', null); | ||
| }); | ||
|
|
||
| const source = AssetSampleSource(); | ||
| final samples = await source.listSamples(); | ||
|
|
||
| expect(samples, hasLength(2)); | ||
| expect(samples[0].name, 'hello'); | ||
| expect(await samples[0].load(), 'hello content'); | ||
| expect(samples[1].name, 'world'); | ||
| expect(await samples[1].load(), 'world content'); | ||
| }); | ||
| }); | ||
| } |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../submodules/a2ui/specification/v0_9/json/common_types.json |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../submodules/a2ui/specification/v0_9/json/server_to_client.json |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff is weird on this file; is this a symlink to a git submodule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ, do we need to modify the test runners to clone this package with submodules recursively, or is that the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the asset files are symbolic links pointing to the spec schemas inside the
submodules/a2uidirectory to keep from duplicating the schemas in multiple places.When publishing to
pub.devwithdart pub publish, pub automatically resolves the symlinks and bundles the actual file contents, so users of the package will get the actual files and don't need to check out the submodules.For CI testing, the test runners in
flutter_packages.yamlare already configured to checkout and update submodules recursively (submodules: recursive), so they are there during testing and validation.