Sitelet https://github.com/flutter/flutter/pull/191445
Skip to content

[flutter_tools] Implement Configuration extension slice and flutter config integration - #191445

Merged
auto-submit[bot] merged 23 commits into
flutter:masterfrom
bkonyi:ft-ext-step04-configuration-slice
Aug 26, 2026
Merged

auto-submit[bot] merged 23 commits into
flutter:masterfrom
bkonyi:ft-ext-step04-configuration-slice

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements Step 4 of Flutter Tools Extensibility: the Configuration extension slice and flutter config integration.

Architectural Overview

  1. package:flutter_tools_core:
    • Defines core, platform-agnostic configuration models: FeatureFlag and ConfigOption.
  2. package:flutter_tools_extension:
    • Defines the ConfigurationExtension interface and service contract (config.getTitle, config.getFeatureFlags, config.getConfigurations).
  3. package:flutter_tools_extension_linux_prototype:
    • Implements LinuxConfigurationExtension in the Linux prototype extension.
  4. packages/flutter_tools:
    • Implements ConfigurationExtensionClient to query isolate extensions over RPC.
    • Implements ExtensionArgParserMixin to dynamically contribute CLI options to ConfigCommand.
    • Exposes ExtensionManager.configurationExtensions and integrates active extension configuration settings and feature flags dynamically into flutter config (settingsText and arg parsing).

Related Issues

Part of #190692

Tests

  • Added packages/flutter_tools/packages/flutter_tools_core/test/config_test.dart
  • Added packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/test/linux_config_test.dart
  • Added packages/flutter_tools/test/general.shard/extension_protocol/config_service_test.dart
  • Added packages/flutter_tools/test/commands.shard/hermetic/config_test.dart
  • Added tests in packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_integration_test.dart
  • Added integration tests in packages/flutter_tools/test/integration.shard/tool_extensions_test.dart

bkonyi added 9 commits August 16, 2026 00:43
…gration

Implements core diagnostic models (ValidationResult, ValidationMessage) in package:flutter_tools_core, DiagnosticsExtension interface in package:flutter_tools_extension, LinuxExtensionDiagnostics in package:flutter_tools_extension_linux_prototype, ExtensionDoctorValidator, RpcDiagnosticsExtension, and IsolateDiagnosticsExtension host adapter integration in flutter_tools.
- Use firstWhere with fallback when deserializing ValidationType and ValidationMessageType from JSON in package:flutter_tools_core to handle unrecognized types gracefully.
- Use pattern matching for extensionManager in DoctorValidatorsProvider instead of bang operator.
- Add tests for unknown diagnostic enum types.
- Cache DiagnosticsExtensionClient per ExtensionConnection in ExtensionManager.
- Safely handle title and diagnostics RPC responses with try/catch and type validation.
- Pre-fetch diagnostics extension titles during Doctor.startValidatorTasks.
…ent and validation aggregation

- Initialize diagnostics extension clients and fetch titles during ExtensionManager initialization.
- Replace dynamic client map in ExtensionManager with an immutable list and assert on initialization.
- Use exhaustive switch statement for ValidationType aggregation in ExtensionDoctorValidator.
- Remove manual prefetch loop from Doctor.startValidatorTasks.
…ostics-slice

# Conflicts:
#	packages/flutter_tools/lib/executable.dart
…ostics-slice

# Conflicts:
#	packages/flutter_tools/lib/executable.dart
…guration-slice

# Conflicts:
#	packages/flutter_tools/lib/src/experimental/extension_manager.dart
#	packages/flutter_tools/packages/flutter_tools_core/lib/flutter_tools_core.dart
#	packages/flutter_tools/packages/flutter_tools_extension/lib/flutter_tools_extension.dart
#	packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/lib/flutter_tools_extension_linux_prototype.dart
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_integration_test.dart
#	packages/flutter_tools/test/integration.shard/tool_extensions_test.dart
@bkonyi
bkonyi requested a review from a team as a code owner August 20, 2026 19:39
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 20, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-linux Owned by the Linux platform team labels Aug 20, 2026

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

Copy link
Copy Markdown
Contributor

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 introduces support for tool extensions to dynamically register custom configuration options and feature flags in the flutter config command. It adds core models, RPC client adapters, and a dynamic argument parser mixin to rebuild the command's parser at runtime. Feedback focuses on improving robustness and preventing runtime crashes. Key recommendations include wrapping asynchronous RPC calls in try-catch blocks to handle remote isolate failures gracefully, caching fetched settings to avoid duplicate RPC requests, performing defensive checks against duplicate option and subcommand names during parser reconstruction, and safely handling potentially null RPC responses instead of using the null-assertion operator.

Comment thread packages/flutter_tools/lib/src/commands/config.dart
Comment thread packages/flutter_tools/lib/src/commands/config.dart Outdated
Comment thread packages/flutter_tools/lib/src/experimental/config.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/config.dart
Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
Comment thread packages/flutter_tools/lib/src/experimental/config.dart
Comment thread packages/flutter_tools/lib/src/experimental/config.dart Outdated
Comment thread packages/flutter_tools/lib/src/experimental/config.dart Outdated
bkonyi added 4 commits August 20, 2026 19:48
…n slice

* Check for option and subcommand name collisions before dynamic parser registration.
* Cache `_extensionSettingsGroups` in `ConfigCommand` to eliminate duplicate RPC queries during `settingsText`.
* Wrap extension queries in `ExtensionConfiguration` with try-catch blocks to prevent individual extension errors from aborting all configuration resolution.
* Handle null and malformed RPC responses safely in `ConfigurationExtensionClient`.
* Add regression tests for conflicting options, failing extensions, and invalid RPC payloads.
…on slice

- Initialize dynamic options prior to argument parsing in `FlutterCommandRunner` via robust command target resolution.
- Extract `cloneParser` helper on `ExtensionArgParserMixin` for cleaner argument parser cloning.
- Enhance RPC error handling and collection parsing with pattern matching in `ConfigurationExtensionClient`.
- Simplify deserialization using Dart 3 switch expressions in `FeatureFlag` and `ConfigOption`.
- Cache configuration extensions and enforce initialization lifecycle asserts in `ExtensionManager`.
@bkonyi
bkonyi requested review from a team as code owners August 21, 2026 00:00
@github-actions github-actions Bot added team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 21, 2026
bkonyi added 2 commits August 21, 2026 18:51
Adopt modern Dart 3+ language features across the configuration extension slice:

- Use map pattern matching and destructuring in `FeatureFlag.fromJson` and `ConfigOption.fromJson`.
- Implement safe, generic `_fetchList<T>` RPC helper in `ConfigurationExtensionClient`.
- Use exhaustive `switch (opt.type)` pattern matching in `cloneParser`.
- Use `MapEntry(:key, :value)` destructuring for subcommand registration.
- Replace verbose loops and conversions with collection comprehensions and spread operators.
- Extract named constants for prototype config keys.
…estructuring

Consolidate extension settings state to _extensionSettingsGroups in `ConfigCommand`:

- Remove redundant `_extensionFeatureFlags` and `_extensionConfigOptions` fields.
- Apply object destructuring patterns across all loops iterating over `ExtensionSettingsGroup`, `FeatureFlag`, and `ConfigOption` in `extensionArgParserCacheKey`, `buildDynamicArgParser`, `runCommand`, and `settingsText`.
- Simplify dynamic parser cache key computation.
@bkonyi
bkonyi requested a review from loic-sharma August 21, 2026 20:38
@bkonyi

bkonyi commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

cc @chingjun.

It looks like the Google testing is failing to pick up the G3Fix CL. Would you happen to know why that's happening?

@chingjun

Copy link
Copy Markdown
Contributor

cc @chingjun.

It looks like the Google testing is failing to pick up the G3Fix CL. Would you happen to know why that's happening?

This is caused by a recent migration. Just sent a CL to fix. Will probably land next week

Comment on lines +13 to +14
@override
String get title => 'Linux Custom Extension Prototype';

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.

I wonder if we should add a title argument to ToolExtensionEntryPoint.run? Currently the extension provides the title multiple times (ConfigurationExtension.title and DiagnosticsExtension.title).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! Centralizing the extension title at registration / capabilities level rather than on each service interface makes a lot of sense. Since ToolExtensionEntryPoint and capabilities were landed in Step 02, I'll follow up with a refactoring across the slices to consolidate extension metadata into the top-level registration.

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.

Sounds good 👍

Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/config.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command_runner.dart Outdated
…er option tests

- Unify base parser creation into createBaseArgParser in ExtensionArgParserMixin and ConfigCommand.
- Pre-clone baseArgParser inside ExtensionArgParserMixin.argParser before passing to buildDynamicArgParser.
- Add re-entrancy assertion in argParser getter and assign _baseArgParser only after construction completes.
- Document option skipping and help target resolution in FlutterCommandRunner.
- Add unit tests in flutter_command_runner_test.dart for dynamic option runner initialization.
Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
Comment thread packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
…eys with rebuildDynamicArgParser

- Remove extensionArgParserCacheKey and cache invalidation logic from ExtensionArgParserMixin.
- Add rebuildDynamicArgParser() to ExtensionArgParserMixin and call it in ConfigCommand.initializeDynamicOptions().
- Update runner unit tests in flutter_command_runner_test.dart.
Comment thread packages/flutter_tools/lib/src/experimental/extension_arg_parser.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command_runner.dart Outdated
loic-sharma
loic-sharma previously approved these changes Aug 25, 2026

@loic-sharma loic-sharma left a comment

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.

LGTM, nice work!

bkonyi added 2 commits August 25, 2026 16:51
…support subcommand hierarchies

- Traverse parent command hierarchy in _initializeDynamicOptions to initialize all ExtensionArgParserMixin commands.
- Add unit tests in flutter_command_runner_test.dart for subcommands, parent flags, inline option values, empty inline values, unknown flags, negated flags, and help subcommands.
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 25, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 25, 2026
Merged via the queue into flutter:master with commit 1145997 Aug 26, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 26, 2026
@bkonyi
bkonyi deleted the ft-ext-step04-configuration-slice branch August 26, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants