-
Notifications
You must be signed in to change notification settings - Fork 330
Register VM service with DTD #8436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CC @jakemac53 |
@@ -738,6 +746,12 @@ public void onAppStarting(DaemonEvent.AppStarting event) { | |||
@Override | |||
public void onAppDebugPort(@NotNull DaemonEvent.AppDebugPort debugInfo) { | |||
app.setWsUrl(debugInfo.wsUri); | |||
this.appVmServiceUri = debugInfo.wsUri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we get any sort of identifier that we can use as a map key that we can look up when we get the app stopped event for this particular app?
While the MCP server today only supports one connected app, we do want to have it support multiple in the future, so ideally the IDE plugins wouldn't be assuming just one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IJ can register multiple apps to DTD. There's an app name that's a unique identifier, or the VM service URI is unique too.
This is an example of the params we send with two apps running at the same time:
2025-08-08 09:28:04 io.flutter.run.daemon.FlutterAppDaemonEventListener [INFO ] Successful request ConnectedApp.registerVmService to DTD with params: {"uri":"ws://127.0.0.1:50489/m1aDg3zyHq4=/ws","name":"752c8ff1-86dd-4c91-abab-825747059057"}
2025-08-08 09:29:33 io.flutter.run.daemon.FlutterAppDaemonEventListener [INFO ] Successful request ConnectedApp.registerVmService to DTD with params: {"uri":"ws://127.0.0.1:51041/iUbSRQCLBfg=/ws","name":"65328744-2368-46bf-9e23-70066b219342"}
The unregisterVmService
takes the URI as a param also, so I imagine you would use that as the key?
/fyi @DanTup who did the analogous work for VS Code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🎉
final JsonObject params = new JsonObject(); | ||
params.addProperty("uri", debugInfo.wsUri); | ||
params.addProperty("name", debugInfo.appId); | ||
sendDtdRequest("ConnectedApp.registerVmService", params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how we want to test this (And I'd love to get your thoughts), but in anticipation, maybe we should introduce some constants somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for now I can add these methods as constants. Maybe a separate file that links to DTD documentation would be helpful.
I haven't thought much about testing; I suppose one part would be testing dtdService.sendRequest
in the Dart plugin. And ultimately integration testing in the Dart plugin.
Some clean up in #8442 |
Awesome. Thanks for following up! |
I added some notes above on how to test this |
Addresses #8261
How to test that this works: