Skip to content

Create a DTD service for managing connected apps #60540

Open
@kenzieschmoll

Description

@kenzieschmoll

Background

The Dart Tooling Daemon (DTD) is either started by DDS / DevTools server, in the case where an app is started from the CLI, or an IDE plugin / extension (VS Code, Android Studio, or IntelliJ), in the case where an app is started from the IDE. This means that DTD may be connected to a development workflow that has one or many running apps.

For DTD clients like DevTools and the new Dart Tooling MCP Server, a client may need to fetch the list of active debug sessions (the running Dart / Flutter apps). In the case where DTD is started from a 1P supported IDE (VS Code or Android Studio / IntelliJ), the IDE provides an EditorService from which a client can get the list of active debug sessions, and therefore the list of the active VM Service URIs. However, in the case where a 1P supported IDE did NOT start DTD, this service will be unavailable and there is no way to get the VM service URI of the running app(s).

The following is a proposed solution to this problem, allowing DTD to have awareness of the connected Dart & Flutter applications that the DTD clients are interacting with.

Proposed solution

Create a new service ConnectedAppService directly in DTD that provides the methods:

  • [Protected] void registerVmService(String uri)
  • List<String> getVmServiceUris()

[Protected] here means that the only DTD client that started DTD (either the IDE or DDS / DevTools server) should be able to call this method. We can use the same client secret that we require for the setIDEWorkspaceRoots method.

The ConnectedAppService can maintain a set of VmService objects for the VM service URIs that have been registered, which will allow the service to automatically clean up VmService instances when they are shutdown.

[OPTIONAL] Instead of (or in addition to) getVmServiceUris(), we could implement a stream for the VM Service URIs that DTD clients can subscribe to. Upon a client subscribing to this stream, all the current VM Service URIs should be sent. The stream should be updated with vmServiceRegistered and vmServiceShutdown events so that the client can update its set of URIs. This may not be necessary since the client can just request getVmServiceUris() whenever an operation needs to know about the current set of VM service instances.

Implementation plan

  1. Build the ConnectedAppService in DTD. CC @bkonyi
  2. [DDS] For the case of an app started from the CLI (dart or flutter), call the new method ConnectedAppService.registerVmService. This should be called whenever DDS (or DevTools server inside DDS) is responsible for starting DTD.
  3. [Dart-Code extension] Call the new method ConnectedAppService.registerVmService when a new debug session is started. CC @DanTup
  4. [IntelliJ Plugin] Call the new method ConnectedAppService.registerVmService when a new debug session is started. CC @jwren @pq
  5. In the Dart Tooling MCP Server (the first DTD client that will be using this new service), initially call ConnectedAppService.getVmServiceUris only when the EditorService.getDebugSessions method is not available. This will ensure that the Dart Tooling MCP Server is backwards compatible with older IDE plugin / extension versions. After some safe time period (12-18 months?), switch over to using ConnectedAppService.getVmServiceUris exclusively. CC @jakemac53

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-dart-cliUse area-dart-cli for issues related to the 'dart' command like tool.dart-cli-tooling-daemonIssues related to the 'dart tooling-daemon' toolpkg-dtdFor issues related to the Dart Tooling Daemon (package:dtd or pkg/dtd_impl within the Dart SDK)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions