Skip to content

[flutter_tools] Implement Diagnostics extension slice and doctor integration - #191162

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
bkonyi:ft-ext-step03-diagnostics-slice
Aug 20, 2026
Merged

auto-submit[bot] merged 8 commits into
flutter:masterfrom
bkonyi:ft-ext-step03-diagnostics-slice

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements Step 3 of Flutter Tools Extensibility: the Diagnostics extension slice and doctor integration.

Architectural Overview

  1. package:flutter_tools_core:
    • Defines core, platform-agnostic diagnostic models: ValidationType, ValidationMessage, and ValidationResult.
  2. package:flutter_tools_extension:
    • Defines the DiagnosticsExtension interface and service contract (getTitle(), runDiagnostics()).
  3. package:flutter_tools_extension_linux_prototype:
    • Implements LinuxExtensionDiagnostics validator in the Linux prototype extension.
  4. packages/flutter_tools:
    • Implements DiagnosticsExtensionClient to query isolate extensions over RPC.
    • Introduces ExtensionDoctorValidator which adapts extension diagnostic results into Flutter tool DoctorValidator instances.
    • Wires ExtensionDoctorValidator into Doctor.validators via ExtensionManager.
    • Deprecates duplicate diagnostic types in doctor_validator.dart in favor of package:flutter_tools_core exports.

Related Issues

Part of #190692

Tests

  • Added packages/flutter_tools/packages/flutter_tools_core/test/diagnostics_test.dart
  • Added packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/test/linux_diagnostics_test.dart
  • Added packages/flutter_tools/test/general.shard/extension_protocol/diagnostics_service_test.dart
  • Added packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_integration_test.dart
  • Added packages/flutter_tools/test/integration.shard/tool_extensions_test.dart
  • Updated existing doctor and validator tests in commands.shard and general.shard.

…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.
@bkonyi
bkonyi requested a review from loic-sharma August 16, 2026 00:44
@bkonyi
bkonyi requested review from a team as code owners August 16, 2026 00:44
@bkonyi
bkonyi requested review from camsim99 and removed request for a team August 16, 2026 00:44
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 16, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically platform-linux Building on or for Linux specifically a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Aug 16, 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 in flutter doctor diagnostics, adding core data models, interfaces, and host-side adapters to delegate diagnostic checks to active tool extensions. The review feedback suggests simplifying the aggregation of ValidationType using enum indices, replacing unsafe casts on RPC results with whereType filtering to prevent runtime errors, using firstWhere with fallbacks instead of byName to handle unknown deserialization types robustly, and utilizing Dart's pattern matching for safe promotion of extensionManager instead of the bang operator.

Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart Outdated
Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart Outdated
Comment thread packages/flutter_tools/packages/flutter_tools_core/lib/src/diagnostics.dart Outdated
Comment thread packages/flutter_tools/packages/flutter_tools_core/lib/src/diagnostics.dart Outdated
Comment thread packages/flutter_tools/lib/src/doctor.dart Outdated
@bkonyi
bkonyi marked this pull request as draft August 16, 2026 00:47
- 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.
@bkonyi
bkonyi marked this pull request as ready for review August 16, 2026 15:39

@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 running diagnostic validation checks via tool extensions in flutter doctor. It migrates diagnostic data models to the flutter_tools_core package for sharing, implements an ExtensionManager to manage extension connections, and adds an ExtensionDoctorValidator to delegate diagnostics to active extensions. Feedback suggests caching DiagnosticsExtensionClient instances to preserve state, replacing risky null assertions and direct casts on RPC responses with robust error handling to prevent crashes, and pre-fetching extension titles to avoid placeholder UI display.

Comment thread packages/flutter_tools/lib/src/experimental/extension_manager.dart
Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart
Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart
Comment thread packages/flutter_tools/lib/src/doctor.dart
- 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.
Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart
Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart
super(extension.title);

/// The active extension service executing diagnostic checks.
final DiagnosticsExtension extension;

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.

Could this be a DiagnosticsExtensionClient? (I expect this will also require updating ExtensionManager.diagnosticExtensions to return a List<DiagnosticsExtensionClient)

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.

ExtensionDoctorValidator accepts DiagnosticsExtension so that in-process prototype extensions and test implementations can be validated without requiring a full isolate RPC connection.

@loic-sharma loic-sharma Aug 19, 2026 •

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.

Could tests use something like FakeDiagnosticsExtensionClient implements DiagnosticsExtensionClient to avoid the full isolate RPC connection? I don't feel strongly about this, feel free to skip or punt this until later if you'd prefer.

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.

They could, but that would also mean they'd need to stub out all the methods related to sending messages to the extension isolate.

Comment thread packages/flutter_tools/lib/src/experimental/diagnostics.dart
Comment thread packages/flutter_tools/lib/src/experimental/extension_manager.dart Outdated
bkonyi added 2 commits August 18, 2026 19:03
…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.
loic-sharma
loic-sharma previously approved these changes Aug 19, 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!

…ostics-slice

# Conflicts:
#	packages/flutter_tools/lib/executable.dart
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2026
@auto-submit

auto-submit Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/191162, because Pull request flutter/flutter/191162 is not in a mergeable state.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2026
…ostics-slice

# Conflicts:
#	packages/flutter_tools/lib/executable.dart
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 20, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 20, 2026
Merged via the queue into flutter:master with commit 458c576 Aug 20, 2026
33 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 20, 2026
@bkonyi
bkonyi deleted the ft-ext-step03-diagnostics-slice branch August 20, 2026 20:11
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 22, 2026
Roll Flutter from c2437523d308 to 65c9a8dc60bc (195 revisions)

flutter/flutter@c243752...65c9a8d

2026-08-22 [email protected] Roll ICU from d578f2e8b7bd to 8cc91d9b6ab9 (1 revision) (flutter/flutter#191542)
2026-08-22 [email protected] Roll Skia from 666a9b3d5cf0 to ad2106c0bb64 (3 revisions) (flutter/flutter#191527)
2026-08-22 [email protected] Roll Fuchsia Test Scripts from KaOq3EE4qJ9fnaaaK... to 0iCv10IlKfiilEBOU... (flutter/flutter#191524)
2026-08-22 [email protected] [flutter_tools] Add tests for negative lookahead regex in test runner and batch entrypoints (flutter/flutter#191438)
2026-08-22 [email protected] Roll Skia from 0c37868737fa to 666a9b3d5cf0 (2 revisions) (flutter/flutter#191518)
2026-08-21 [email protected] Revert "[input] Migrate fuchsia.ui.pointerinjector to TouchSource (#190855) (flutter/flutter#191509)
2026-08-21 [email protected] Fixes windows gallery benchmarks by forcing mobile layout (flutter/flutter#191507)
2026-08-21 [email protected] [flutter_tools] Restrict WebAssetServer source resolution to source map extensions (flutter/flutter#191501)
2026-08-21 [email protected] Roll Skia from f6900c5b8439 to 0c37868737fa (2 revisions) (flutter/flutter#191504)
2026-08-21 [email protected] Refactor `FlutterDevice.connect` and VM service discovery (flutter/flutter#191221)
2026-08-21 [email protected] [flutter_tools] Fix crash when migrating flow-style exclude lists in analysis_options.yaml (flutter/flutter#191269)
2026-08-21 [email protected] [rules] Add packages/flutter_tools/gradle/AGENTS.md rules (flutter/flutter#191486)
2026-08-21 [email protected] [flutter_tools] refactor CLI argument architecture with typed option descriptors and bundles (PoC) (flutter/flutter#191018)
2026-08-21 [email protected] tools: Extract Dart SDK to temp directory before moving to final location (flutter/flutter#191263)
2026-08-21 [email protected] [web] Move CanvasKit fragment shader classes to canvaskit/fragment_shader.dart (flutter/flutter#191451)
2026-08-21 [email protected] Roll Fuchsia Linux SDK from GCQlmt6h-esJsNubS... to ic6GjOSn-KN508XyK... (flutter/flutter#191485)
2026-08-21 [email protected] [Widget Preview] Isolate PageStorage scope in widget preview group expansion tile (flutter/flutter#191378)
2026-08-21 [email protected] [flutter_tools] Deprecate --build and --no-build flags on flutter run (flutter/flutter#191358)
2026-08-21 [email protected] Roll Skia from 70988bed1b3b to f6900c5b8439 (2 revisions) (flutter/flutter#191481)
2026-08-21 [email protected] Roll Packages from 1785501 to 252bb33 (6 revisions) (flutter/flutter#191480)
2026-08-21 [email protected] Roll Fuchsia Linux SDK from 20IJas24bZiNmCZTK... to GCQlmt6h-esJsNubS... (flutter/flutter#191415)
2026-08-21 [email protected] Roll Skia from 2ba6971bd0d1 to 70988bed1b3b (2 revisions) (flutter/flutter#191476)
2026-08-21 [email protected] Roll Skia from 1d5f72537ba6 to 2ba6971bd0d1 (2 revisions) (flutter/flutter#191473)
2026-08-21 [email protected] Roll Skia from 2c25efd2e369 to 1d5f72537ba6 (1 revision) (flutter/flutter#191472)
2026-08-21 [email protected] Roll Skia from 09b1b810850a to 2c25efd2e369 (9 revisions) (flutter/flutter#191470)
2026-08-21 [email protected] [Impeller] fix position of cached single glyph text shadows (flutter/flutter#191325)
2026-08-21 [email protected] Roll Skia from abdf8821f313 to 09b1b810850a (15 revisions) (flutter/flutter#191458)
2026-08-21 [email protected] Document that programmatic TextEditingController changes do not run input formatters (flutter/flutter#190166)
2026-08-21 [email protected] Adds new gallery benchmarks to windows (skia and impeller) (flutter/flutter#191454)
2026-08-21 [email protected] iOS: Deprecate FlutterEngine.isGpuDisabled (flutter/flutter#191393)
2026-08-21 [email protected] Revert: [web] Unskip decoration image lerp tests (flutter/flutter#191462)
2026-08-20 [email protected] android_hardware_smoke_test: Improve reliability (flutter/flutter#191374)
2026-08-20 [email protected] Don't size or offset the Android platform view before it is laid out (flutter/flutter#190895)
2026-08-20 [email protected] [iOS][add2app] Skip building SwiftPM plugins when generating CocoaPods artifacts (flutter/flutter#190736)
2026-08-20 [email protected] Optimize JSONMessageCodec UTF-8 conversion (flutter/flutter#190529)
2026-08-20 [email protected] [FML] Replace deprecated wstring_convert with Win32 APIs (flutter/flutter#191394)
2026-08-20 [email protected] SliverFillRemaining extends beyond viewport size when fillOverscroll is true (flutter/flutter#191236)
2026-08-20 [email protected] [flutter_tools] Update argParser usageLineLength when --wrap-column is passed (flutter/flutter#191264)
2026-08-20 [email protected] [flutter_tools] Fix UNC path resolution in depfile parsing on Windows (flutter/flutter#191265)
2026-08-20 [email protected] [web] Unskip decoration image lerp tests (flutter/flutter#191426)
2026-08-20 [email protected] Do not inject 'type' and 'method' into service extension responses (flutter/flutter#190946)
2026-08-20 [email protected] [flutter_tools] Fix crash in symbolize command on stream error (flutter/flutter#191273)
2026-08-20 [email protected] [flutter_tools] Prevent deletion of shared native asset hooks outputs as stale (flutter/flutter#191272)
2026-08-20 [email protected] [flutter_tools] Support package wildcard assets in app pubspec (flutter/flutter#191266)
2026-08-20 [email protected] Add SliverClipRect and SliverClipRRect (flutter/flutter#179003)
2026-08-20 [email protected] [flutter_tools] Implement Diagnostics extension slice and doctor integration (flutter/flutter#191162)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD platform-linux Building on or for Linux specifically platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows 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.

2 participants