Skip to content

[tool] Migrate ResidentRunner, HotRunner, and ColdRunner to modular dependency injection - #192831

Merged
auto-submit[bot] merged 72 commits into
flutter:masterfrom
bkonyi:di/22b-resident-runner
Oct 7, 2026
Merged

auto-submit[bot] merged 72 commits into
flutter:masterfrom
bkonyi:di/22b-resident-runner

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 22b of the modular dependency injection migration.

  • Migrates ResidentRunner, HotRunner, ColdRunner, and ResidentWebRunner to modular constructor dependency injection.
  • Injects BuildSystem, BuildTargets, and Xcode through DaemonCommand, Daemon, AppDomain, AttachCommand, RunCommand.createRunner, WebDriverService.start, and WidgetPreviewStartCommand.
  • Makes toolContext non-nullable with const DelegatingToolContext() default in createHotRunner, createColdRunner, and setUpResidentRunner test helpers, and migrates unit tests in attach_test.dart, daemon_test.dart, cold_test.dart, hot_test.dart, resident_runner_test.dart, and resident_web_runner_test.dart.

Fork diff: bkonyi/flutter@master...di/22b-resident-runner

Part of #188471

@bkonyi bkonyi added the CICD Run CI/CD label Sep 15, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 15, 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 refactors the Flutter tools codebase by replacing references to global variables with dependency injection across multiple commands, runners, and test files to improve modularity. Feedback on the changes includes resolving a correctness bug in ResidentRunner where multiple distinct MemoryFileSystem instances are instantiated when fileSystem is null, and a recommendation to eliminate redundant instantiations of OperatingSystemUtils in AppDomain.

Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/daemon.dart
@bkonyi
bkonyi force-pushed the di/22b-resident-runner branch from 5e29d66 to ea53f23 Compare September 17, 2026 13:45
# Conflicts:
#	packages/flutter_tools/lib/src/resident_runner.dart
# Conflicts:
#	packages/flutter_tools/test/general.shard/cold_test.dart
#	packages/flutter_tools/test/general.shard/hot_test.dart
# Conflicts:
#	packages/flutter_tools/lib/src/commands/run.dart
#	packages/flutter_tools/lib/src/resident_runner.dart
bkonyi added 5 commits October 2, 2026 17:11
# Conflicts:
#	packages/flutter_tools/lib/src/commands/daemon.dart
#	packages/flutter_tools/lib/src/commands/run.dart
#	packages/flutter_tools/lib/src/drive/web_driver_service.dart
#	packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
#	packages/flutter_tools/lib/src/web/web_runner.dart
#	packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
#	packages/flutter_tools/test/general.shard/drive/web_driver_service_test.dart
# Conflicts:
#	packages/flutter_tools/lib/src/commands/daemon.dart
#	packages/flutter_tools/lib/src/commands/run.dart
#	packages/flutter_tools/lib/src/commands/widget_preview.dart
#	packages/flutter_tools/lib/src/drive/web_driver_service.dart
#	packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
#	packages/flutter_tools/lib/src/web/web_runner.dart
#	packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
#	packages/flutter_tools/test/commands.shard/permeable/widget_preview/widget_preview_test.dart
#	packages/flutter_tools/test/general.shard/drive/web_driver_service_test.dart
# Conflicts:
#	packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
@bkonyi
bkonyi requested review from chingjun and removed request for a team October 5, 2026 16:54
chingjun
chingjun previously approved these changes Oct 6, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 6, 2026
@auto-submit

auto-submit Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192831, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit

auto-submit Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

# Conflicts:
#	packages/flutter_tools/lib/src/resident_runner.dart
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 7, 2026
Merged via the queue into flutter:master with commit 9a3453c Oct 7, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2026
richyo-codes pushed a commit to richyo-codes/flutter that referenced this pull request Oct 8, 2026
…eview and trigger hot restart (flutter#193968)

Reverts: [[flutter_tools] Intercept prohibited hot reloads in widget
preview and trigger hot
restart](flutter#193447)

Initiated by: @bkonyi

Reason for reverting: conflicting changes with
flutter#192831 are causing failures due
to concurrent merge

Original PR Author: @bkonyi

Reviewed By: @srawlins

The original PR description is provided below:

When hot reload fails due to unsupported changes (such as class
hierarchy modifications, global initializer changes, or file
additions/deletions) in `flutter widget-preview`, automatically fall
back to a hot restart instead of leaving the previewer in a failed
reload state.

### Changes
- **`ResidentWebRunner`**: Attach `updateFSReport` to the failed
`OperationResult` when `_updateDevFS` fails so callers can inspect
`UpdateFSReport.hotReloadRejected`.
- **`WidgetPreviewStartCommand`**: Introduce `handleReload()` (invoked
inside `_triggerReload` for `.hotReload` requests so the fallback
remains serialized with other reload and restart requests, and add a
`@visibleForTesting` `widgetPreviewApp` setter), which checks if
`restart()` returned an `OperationResult` with
`UpdateFSReport(hotReloadRejected: true)`. When rejected, log a status
message (`kHotReloadRejectedMessage`) and invoke `restart(fullRestart:
true)`.

Fixes flutter#192697

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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