From 3ff8bbadb2ea30d67e1581784cc8400bb59a3545 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:39:12 -0700 Subject: [PATCH 1/3] Fix "Open Flutter DevTools" action --- src/io/flutter/run/OpenDevToolsAction.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/io/flutter/run/OpenDevToolsAction.java b/src/io/flutter/run/OpenDevToolsAction.java index d2c7ac569..b7529c987 100644 --- a/src/io/flutter/run/OpenDevToolsAction.java +++ b/src/io/flutter/run/OpenDevToolsAction.java @@ -26,12 +26,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; import java.util.Objects; public class OpenDevToolsAction extends DumbAwareAction { private static final @NotNull Logger LOG = PluginLogger.createLogger(OpenDevToolsAction.class); private static final String title = "Open Flutter DevTools in Browser"; - private final @Nullable ObservatoryConnector myConnector; + private @Nullable ObservatoryConnector myConnector; private final Computable myIsApplicable; public OpenDevToolsAction() { @@ -72,6 +73,16 @@ public void actionPerformed(@NotNull final AnActionEvent event) { return; } + // If this action was triggered as a command by the user, there will not be + // a connector for the running app. not be already set. Therefore, see if + // there is a running app, and set the connector if so. + if (myConnector == null) { + final List apps = FlutterApp.allFromProjectProcess(project); + if (!apps.isEmpty()) { + myConnector = apps.get(0).getConnector(); + } + } + AsyncUtils.whenCompleteUiThread(Objects.requireNonNull(DevToolsService.getInstance(project).getDevToolsInstance()), (instance, ex) -> { if (project.isDisposed()) { return; From f8d1de8e33393d4ba4bda90d2b4c41229d12c28b Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:46:39 -0700 Subject: [PATCH 2/3] Update comment --- src/io/flutter/run/OpenDevToolsAction.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/io/flutter/run/OpenDevToolsAction.java b/src/io/flutter/run/OpenDevToolsAction.java index b7529c987..0ae10d9d1 100644 --- a/src/io/flutter/run/OpenDevToolsAction.java +++ b/src/io/flutter/run/OpenDevToolsAction.java @@ -73,9 +73,10 @@ public void actionPerformed(@NotNull final AnActionEvent event) { return; } - // If this action was triggered as a command by the user, there will not be - // a connector for the running app. not be already set. Therefore, see if - // there is a running app, and set the connector if so. + // This action is registered in plugin.xml with the default constructor. + // Therefore, if a user triggers this from the IDE, even if there is a + // running Flutter app myConnector will be null. In that case, check for a + // Flutter app first and use its connector instead. if (myConnector == null) { final List apps = FlutterApp.allFromProjectProcess(project); if (!apps.isEmpty()) { From 5547c01007b69b54b810f4252e24f887e832acf2 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 20 Oct 2025 14:30:53 -0700 Subject: [PATCH 3/3] Added a TODO --- src/io/flutter/run/OpenDevToolsAction.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/io/flutter/run/OpenDevToolsAction.java b/src/io/flutter/run/OpenDevToolsAction.java index 0ae10d9d1..91ce00af1 100644 --- a/src/io/flutter/run/OpenDevToolsAction.java +++ b/src/io/flutter/run/OpenDevToolsAction.java @@ -5,6 +5,7 @@ */ package io.flutter.run; +import com.intellij.execution.process.ProcessHandler; import com.intellij.ide.browsers.BrowserLauncher; import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -77,6 +78,8 @@ public void actionPerformed(@NotNull final AnActionEvent event) { // Therefore, if a user triggers this from the IDE, even if there is a // running Flutter app myConnector will be null. In that case, check for a // Flutter app first and use its connector instead. + // TODO(https://github.com/flutter/flutter-intellij/issues/8583): Open the + // running app instead of the first one listed in the project processes. if (myConnector == null) { final List apps = FlutterApp.allFromProjectProcess(project); if (!apps.isEmpty()) {