Skip to content

Improve simple chat and make some cross-repo cleanups.#905

Merged
polina-c merged 65 commits into
flutter:mainfrom
polina-c:sc-plus
May 12, 2026
Merged

Improve simple chat and make some cross-repo cleanups.#905
polina-c merged 65 commits into
flutter:mainfrom
polina-c:sc-plus

Conversation

@polina-c
Copy link
Copy Markdown
Collaborator

@polina-c polina-c commented May 10, 2026

Contributes to #907
Fixes #808

Simple chat

  1. Factor out agent from transport to improve readability
  2. Rename code elements to match terminology
  3. Inspired by @yjbanov 's recent demo, introduced modes: text-only, basic catalog, custom catalog (default)
  4. Stop using class Conversation
  5. Hard code default initial user message to enable faster demos

Cross-repo cleanups

  1. Fix integration tests and add them to CI
  2. Rename 'eval' to 'e2e'
  3. Rename getApiKey to apiKey, because 'get' prefix in methods is dart antipattern
  4. Add BasicCatalogItems.asNoAssetCatalog, that excludes items that require assets (audio, video, images)

Video

Screen.Recording.2026-05-11.at.3.26.19.PM.mov

gemini-code-assist[bot]

This comment was marked as outdated.

@polina-c polina-c marked this pull request as ready for review May 11, 2026 00:35
@polina-c polina-c requested a review from ditman May 11, 2026 00:35
@polina-c polina-c changed the title Improve simple chat and some cross-repor cleanups. Improve simple chat and make some cross-repo cleanups. May 11, 2026
@polina-c
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the simple_chat example to support multiple application modes—text-only, basic catalog, and a custom climbing location catalog—while introducing a new e2e test suite. It also updates the macOS build configuration to use the FlutterGeneratedPluginSwiftPackage and improves error handling in the audio_player widget. Feedback includes correcting a likely typo in the Gemini model name, removing a redundant system prompt fragment, adjusting the logging severity for surface removal, and refining the text controller reset logic to preserve user input.

Comment thread examples/simple_chat/lib/agent/ai_client.dart
Comment thread examples/simple_chat/lib/chat_session.dart Outdated
Comment thread examples/simple_chat/lib/chat_session.dart Outdated
Comment thread examples/simple_chat/lib/main.dart
Copy link
Copy Markdown
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Some small comments. Nothing blocking. My biggest concern is exposing the "no asset" version of the basic catalog through its API (it's hard to remove later, and it's something that apps can do very easily themselves when they need it)

Comment thread .github/workflows/flutter_packages.yaml
- [ ] I read the [Contributors Guide].
- [ ] I have added sample code updates to the [changelog].
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] If my PR is a fork PR, I've checked that [e2e tests] passed.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can tests be run by end users? We have this same message in google/A2UI, and it's not super relevant unless flutter code is being touched (?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In a2ui it is relevant if python code is touched, because service is in python.
We have all kinds of dependencies, and we may add more e2e tests. Added condition for changed code. Thank you!

Comment thread .vscode/launch.json
String? debugApiKey;

String getApiKey() {
String apiKey() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this renaming? Shouldn't a function name contain a verb?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread examples/e2e/test/simple_chat_test.dart Outdated
await tester.pumpAndSettle();
// We can't use pumpAndSettle() because some catalog widgets (e.g. Image's
// loadingBuilder shows a CircularProgressIndicator) have indeterminate
// animations that never settle.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do they never settle because the network is not available, or because the image that we're attempting to load has a bad URL?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

CircularProgressIndicator messes up somehow with pumpAndSettle. This fix is suggested by agent. Updated comment. I do not know details and i do not feel it is worth to spend time investigation.


When user asks about climbing locations, never use other components.
''',
..._basicCatalog.systemPromptFragments,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should the default systemprompts be placed before the custom catalog fragments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure. The example works this way well, and it may break if i change the prompt. Leaving it as is.

Comment thread examples/simple_chat/lib/chat_session.dart Outdated

## Video

https://github.com/user-attachments/assets/469fb2cf-09cf-463c-8c9c-b9c0cb39203b
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This demo looks super good. Kudos!

Comment on lines +108 to +117
/// Creates a basic catalog without items that require assets.
///
/// This is useful for the app, that do not work with images, audio or video.
static Catalog asNoAssetCatalog({
List<String> systemPromptFragments = const [],
}) => asCatalog(
systemPromptFragments: systemPromptFragments,
).copyWithout(itemsToRemove: [audioPlayer, image, video]);

/// Creates a catalog containing all basic catalog items.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a fan of exposing an uglier version of the catalog. I think this should be added by the application itself, rather than our API.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Asset related catalog items require addisional configuration of assets. They cannot be just plugged in. So, it results in extra troubleshooting for early adopters.

Added more comments to both methods to make it clear. Thank you!

@polina-c polina-c merged commit 874e292 into flutter:main May 12, 2026
30 checks passed
@polina-c polina-c deleted the sc-plus branch May 12, 2026 23:39
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.

Code of simple_chat is over-complicated.

2 participants