Skip to content

feat: add reloadIsRestart to handle hot reload as a restart for web #179448#183233

Merged
bkonyi merged 15 commits into
flutter:masterfrom
arpitgandhi9:issue-179448
Apr 20, 2026
Merged

feat: add reloadIsRestart to handle hot reload as a restart for web #179448#183233
bkonyi merged 15 commits into
flutter:masterfrom
arpitgandhi9:issue-179448

Conversation

@arpitgandhi9

@arpitgandhi9 arpitgandhi9 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

This PR fixes the --no-hot flag on web-server not working properly. When running flutter run -d web-server --no-hot, the flag was ignored and hot reload still occurred instead of performing hot restart.

Problem
When --no-hot was passed to disable hot reload on web, pressing 'r' in the console would be ignored entirely. The terminal handler was checking canHotReload, which was false when --no-hot was set, but it didn't account for platforms like web where hot reload must always be implemented as a hot restart.

Solution
Added a reloadIsRestart property to the ResidentHandlers abstract class to indicate platforms where hot reload should be treated as restart. Updated the terminal handler's 'r' key logic to allow the command when either canHotReload is true OR reloadIsRestart is true. The web runner already automatically converts reloads to restarts when needed.

Changes Made
[resident_runner.dart]: Added reloadIsRestart to ResidentHandlers abstract class and implemented in ResidentRunner (returns false by default)
[run_cold.dart]: Implemented reloadIsRestart getter (returns false)
[run_hot.dart]: Implemented reloadIsRestart getter (returns false)
[resident_web_runner.dart]: Already had proper reloadIsRestart implementation
[terminal_handler_test.dart]: Added test case to verify 'r' key works when reloadIsRestart=true and canHotReload=false

Before/After Behavior
Before:

$ flutter run -d web-server --no-hot
> r  # User presses 'r'
# Nothing happens - command is ignored

After:

$ flutter run -d web-server --no-hot
> r  # User presses 'r'
Performing hot restart...  # ✅ Correctly performs hot restart

Testing
Added comprehensive test coverage with a new test case: "r - reloadIsRestart when canHotReload is false (web --no-hot case)". All 96 existing terminal handler tests pass.

Fixes
Fixes #179448

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 4, 2026
@arpitgandhi9

Copy link
Copy Markdown
Contributor Author

#179448

@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 a reloadIsRestart property to the ResidentHandlers class and modifies the TerminalHandler to handle hot reload as a restart for web platforms. It also includes a new test case to verify the behavior when reloadIsRestart is true and canHotReload is false. The changes ensure that hot reload is treated as a hot restart on platforms like web where in-place code updates are not supported. The code changes are well-structured and include a new test case to verify the intended behavior.

Note: Security Review did not run due to the size of the PR.

Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
Comment thread packages/flutter_tools/test/general.shard/terminal_handler_test.dart Outdated
@arpitgandhi9 arpitgandhi9 changed the title feat: add reloadIsRestart to handle hot reload as a restart for web feat: add reloadIsRestart to handle hot reload as a restart for web #179448 Mar 4, 2026
@bkonyi

bkonyi commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Hi @arpitgandhi9, thanks for the contribution!

Can you please update the PR description to include details about the changes made?

@bkonyi bkonyi requested review from bkonyi and jyameo March 9, 2026 17:15

@bkonyi bkonyi 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.

LGTM once the PR description is updated.

@jyameo jyameo 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.

lgtm!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 1, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 1, 2026
@auto-submit

auto-submit Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/183233, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Apr 1, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Apr 13, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 13, 2026
@auto-submit

auto-submit Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 13, 2026
@bkonyi bkonyi added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Apr 13, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 15, 2026
@bkonyi bkonyi added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Apr 16, 2026
@bkonyi bkonyi added this pull request to the merge queue Apr 20, 2026
Merged via the queue into flutter:master with commit 735966b Apr 20, 2026
160 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 20, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Apr 21, 2026
flutter/flutter@2844af6...3d0e822

2026-04-21 goderbauer@google.com Reland "Unpin google_mobile_ads" (flutter/flutter#180838)
2026-04-21 ishaquehassan@gmail.com fix: correct LicenseRegistry docs to reference NOTICES instead of LICENSE (flutter/flutter#184572)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from f8637ade3d92 to a234f0ed7245 (2 revisions) (flutter/flutter#185334)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from 3b338913f623 to f8637ade3d92 (9 revisions) (flutter/flutter#185331)
2026-04-21 kevmoo@users.noreply.github.com Fix non-minimal relative imports in flutter_tools (flutter/flutter#183971)
2026-04-21 sigurdm@google.com Reapply "Unpin sdk package dependencies" (flutter/flutter#185268)
2026-04-21 robert.ancell@canonical.com Remove unused private header (flutter/flutter#185260)
2026-04-20 chris@bracken.jp [iOS] Improve LaunchEngine implementation/API/docs (flutter/flutter#185200)
2026-04-20 41930132+hellohuanlin@users.noreply.github.com [ios][pv] Reland platform view hitTest approach (again) (flutter/flutter#185126)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from 75c2791c6274 to 3b338913f623 (3 revisions) (flutter/flutter#185304)
2026-04-20 srawlins@google.com ignore avoid_type_to_string lint rule (flutter/flutter#184765)
2026-04-20 jacksongardner@google.com Fix race condition in modifying release manifest. (flutter/flutter#185185)
2026-04-20 jason-simmons@users.noreply.github.com In the dev/bots/analyze.dart script, obtain the relevant set of paths from Git instead of crawling the filesystem (flutter/flutter#185058)
2026-04-20 jacksongardner@google.com [wimp] Implement images for wimp. (flutter/flutter#183913)
2026-04-20 47866232+chunhtai@users.noreply.github.com add the next batch for VPAT assessment (flutter/flutter#185053)
2026-04-20 engine-flutter-autoroll@skia.org Roll Packages from c2e3d1f to 01c505f (21 revisions) (flutter/flutter#185287)
2026-04-20 jacksongardner@google.com Avoid use of direct string injection in GitHub Workflow "run" steps. (flutter/flutter#185301)
2026-04-20 bkonyi@google.com Regenerate pubspec.lock (flutter/flutter#185290)
2026-04-20 jason-simmons@users.noreply.github.com Report an error if the git ls-tree command fails in the content_aware_hash script (flutter/flutter#185170)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from d8415c5d7b91 to 75c2791c6274 (40 revisions) (flutter/flutter#185284)
2026-04-20 bkonyi@google.com Move widget_preview_scaffold into pub workspace (flutter/flutter#185176)
2026-04-20 dacoharkes@google.com [record_use] Run build hooks and link hooks in separate targets (flutter/flutter#184880)
2026-04-20 arpitgandhi9@users.noreply.github.com feat: add reloadIsRestart to handle hot reload as a restart for web #179448 (flutter/flutter#183233)
2026-04-20 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from aDbXQm6WA0wFCAUp-... to LPa7NLiXEZP2A7IwZ... (flutter/flutter#185269)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@arpitgandhi9 arpitgandhi9 deleted the issue-179448 branch April 22, 2026 11:44
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11548)

flutter/flutter@2844af6...3d0e822

2026-04-21 goderbauer@google.com Reland "Unpin google_mobile_ads" (flutter/flutter#180838)
2026-04-21 ishaquehassan@gmail.com fix: correct LicenseRegistry docs to reference NOTICES instead of LICENSE (flutter/flutter#184572)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from f8637ade3d92 to a234f0ed7245 (2 revisions) (flutter/flutter#185334)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from 3b338913f623 to f8637ade3d92 (9 revisions) (flutter/flutter#185331)
2026-04-21 kevmoo@users.noreply.github.com Fix non-minimal relative imports in flutter_tools (flutter/flutter#183971)
2026-04-21 sigurdm@google.com Reapply "Unpin sdk package dependencies" (flutter/flutter#185268)
2026-04-21 robert.ancell@canonical.com Remove unused private header (flutter/flutter#185260)
2026-04-20 chris@bracken.jp [iOS] Improve LaunchEngine implementation/API/docs (flutter/flutter#185200)
2026-04-20 41930132+hellohuanlin@users.noreply.github.com [ios][pv] Reland platform view hitTest approach (again) (flutter/flutter#185126)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from 75c2791c6274 to 3b338913f623 (3 revisions) (flutter/flutter#185304)
2026-04-20 srawlins@google.com ignore avoid_type_to_string lint rule (flutter/flutter#184765)
2026-04-20 jacksongardner@google.com Fix race condition in modifying release manifest. (flutter/flutter#185185)
2026-04-20 jason-simmons@users.noreply.github.com In the dev/bots/analyze.dart script, obtain the relevant set of paths from Git instead of crawling the filesystem (flutter/flutter#185058)
2026-04-20 jacksongardner@google.com [wimp] Implement images for wimp. (flutter/flutter#183913)
2026-04-20 47866232+chunhtai@users.noreply.github.com add the next batch for VPAT assessment (flutter/flutter#185053)
2026-04-20 engine-flutter-autoroll@skia.org Roll Packages from c2e3d1f to 01c505f (21 revisions) (flutter/flutter#185287)
2026-04-20 jacksongardner@google.com Avoid use of direct string injection in GitHub Workflow "run" steps. (flutter/flutter#185301)
2026-04-20 bkonyi@google.com Regenerate pubspec.lock (flutter/flutter#185290)
2026-04-20 jason-simmons@users.noreply.github.com Report an error if the git ls-tree command fails in the content_aware_hash script (flutter/flutter#185170)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from d8415c5d7b91 to 75c2791c6274 (40 revisions) (flutter/flutter#185284)
2026-04-20 bkonyi@google.com Move widget_preview_scaffold into pub workspace (flutter/flutter#185176)
2026-04-20 dacoharkes@google.com [record_use] Run build hooks and link hooks in separate targets (flutter/flutter#184880)
2026-04-20 arpitgandhi9@users.noreply.github.com feat: add reloadIsRestart to handle hot reload as a restart for web #179448 (flutter/flutter#183233)
2026-04-20 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from aDbXQm6WA0wFCAUp-... to LPa7NLiXEZP2A7IwZ... (flutter/flutter#185269)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.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.

--no-hot flag on web-server is not working

3 participants