Skip to content

Conversation

@gspencergoog
Copy link
Collaborator

@gspencergoog gspencergoog commented Aug 6, 2025

I've been working on standardizing the AI model abstraction within flutter_genui to improve flexibility and testability. This pull request introduces a new AiModel interface and refactors the GeminiAiClient to conform to it. As a direct benefit, I've added a new integration test for the travel_app example, which utilizes a mock AI client made possible by this standardization. Additionally, I've included several new unit tests for various UI components in the travel_app and made a minor update to the generic_chat example.

Highlights

  • Standardized AI Model Abstraction: I've introduced a new AiModel abstract class and updated the AiClient interface to use this abstraction. This provides a standardized way to represent and interact with different AI models, making the system more flexible and extensible.
  • Refactored Gemini AI Client: The GeminiAiClient has been refactored to fully integrate with the new AiModel interface. This involved renaming the GeminiModel enum to GeminiModelType and creating a GeminiModel class that extends AiModel, ensuring compatibility and proper model management.
  • New Integration Test for Travel App: I've added a new integration test for the travel_app example. This test simulates user interactions and verifies the application's UI behavior when responding to AI-generated content, leveraging a MockAiClient made possible by the AiModel standardization.
  • Renamed and Enhanced Travel App Widgets: To improve clarity and facilitate testing, I've renamed the main application widget from MyApp to TravelApp and the main page widget from MyHomePage to TravelPlannerPage in the travel_app example. Their constructors now also support dependency injection of AiClient instances.

There are still some places where we depend on firebase_ai that we shouldn't (in ai_client.dart, for instance), because of the lack of a generic Schema, Content, and Part substitute.

Fixes #39
Addresses part of #60

Adds comprehensive unit tests for the travel_app package.

- Creates new tests for previously untested widgets:
  - `options_filter_chip.dart`
  - `section_header.dart`
- Enhances existing tests for better coverage and assertions:
  - `itinerary_item_test.dart`
  - `trailhead_test.dart`
  - `travel_carousel_test.dart`
  - `asset_images_test.dart`
- Cleans up unused test files and dependencies.
@gspencergoog
Copy link
Collaborator Author

/gemini summary

@gspencergoog gspencergoog marked this pull request as ready for review August 6, 2025 23:10
Copy link
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 significantly improves the codebase by adding a comprehensive suite of tests, including a new integration test for the travel_app. The refactoring to standardize the AiModel and AiClient interface is a great step towards a more flexible and testable architecture. My review includes a few suggestions to improve type safety and code consistency. The PR description is minimal; consider expanding it to follow the repository's contribution guidelines, as mentioned in the style guide.

@flutter flutter deleted a comment from gemini-code-assist bot Aug 6, 2025
import 'package:flutter_genui/flutter_genui.dart';
import 'package:flutter_genui/src/ai_client/tools.dart';

class FakeAiClient implements AiClient {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this go to test/test_infra too?

Or, to avoid duplicates we can export it from pkgs/flutter_genui/lib/testing.dart?

Copy link
Collaborator Author

@gspencergoog gspencergoog Aug 7, 2025

Choose a reason for hiding this comment

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

Hrm. Yeah, I thought about that, but decided to duplicate for now. It felt weird exporting a fake in the public interface because they often are specific to the tests you're writing.

I can move it, though.

Copy link
Collaborator

@polina-c polina-c left a comment

Choose a reason for hiding this comment

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

One comment, then LGTM

@gspencergoog gspencergoog merged commit ec627b8 into flutter:main Aug 7, 2025
4 checks passed
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.

Minimal test coverage to make sure examples are starting without failures

2 participants