Skip to content

[Agent-Ready Dart Services] Automated Flutter "Prompt-to-Reload" Workflow #182155

@jwren

Description

@jwren

This feature aims to introduce a frictionless development loop by bridging the gap between an AI agent's code modifications and the live execution environment. By leveraging the Dart Model Context Protocol (MCP) and the latest Flutter discovery tools, the agent moves beyond simple code generation to become a runtime-aware development partner.


The Heart of the Workflow: Hot Reload

In Flutter development, Hot Reload is the indispensable "pulse" of the iteration cycle. It allows developers to inject updated source code files into the running Dart Virtual Machine (VM) without losing the application state or requiring a full restart.

By automating this step, the agent eliminates the need for the developer to manually switch focus to a terminal or IDE to trigger a reload. The "prompt-to-screen" latency is reduced to near-zero, making the AI-driven development feel native to the Flutter experience.


The Discovery Engine: dart tooling-daemon --list

The technical backbone of this automation is the newly landed dart tooling-daemon --list command (#183421). This provides the specific mechanism for the agent to connect to an existing session without user configuration:

  • DTD URI Discovery: The command utilizes the existing DTD package to locally store information about running Dart and Flutter processes.
  • Zero-Config Connection: Because the agent can programmatically call dart tooling-daemon --list [--machine], the developer no longer needs to find, copy, and paste debugger URIs. The agent autonomously establishes the communication link.

The End-to-End Automated Loop

  1. Natural Language Prompt: The developer provides a request (e.g., "Refactor the search bar to use the new branding colors and center the icon").
  2. Agent Modification: The agent analyzes the codebase and applies the necessary logic or UI changes.
  3. Atomic Save: The agent automatically saves the modified files to the disk.
  4. Process Discovery: The agent executes dart tooling-daemon --list to find the active Flutter process and its corresponding DTD URI. This may best be done through MCP modifications, an Agent Skill recommendation, a combination, or some other mechanism.
  5. Automated Hot Reload: Once the connection is established, the agent immediately triggers a Hot Reload.
  6. Instant Verification: The changes are reflected on the device or emulator instantly. If any runtime errors occur, the agent can use MCP tools to inspect the stack trace and propose a fix.

The above illustrates the goal for this effort, but there are number of additional tasks beyond the initial (PR #180098):

  • A few follow up cleanup tasks related to this initial task such as resolving the TODOs in running_apps.dart that were introduced.
  • Adding a dtdUri (string manipulation from the current http that we do have).
  • Additional tests to ensure that the trailing slash is consistent between different running apps/platform types
  • MCP work and testing
  • Agent Skill implementation & testing
  • Evals to ensure that the end to end will continue to work into the future
  • Documentation and education for users

Relative size: L

Metadata

Metadata

Assignees

Labels

toolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions