From 44843e443bf58b746ecd7c0b08eac75415a5b01a Mon Sep 17 00:00:00 2001 From: Maxim Popov Date: Fri, 31 Jul 2026 16:09:14 +0000 Subject: [PATCH] PY-90402 [debugger]: Handle disabled Python DAP Debugger plugin state in tooltips and GotIt prompts. Merge-request: IJ-MR-216490 Merged-by: Maxim Popov (cherry picked from commit 4d1666d1db4236fed8246c828036f585cebd18be) IJ-MR-216490 GitOrigin-RevId: 4cfc994c19699346f619c071a954ab766d8c1345 --- .../messages/PyBundle.properties | 2 ++ .../PyDapPluginInstallGotItListener.kt | 9 ++++++-- .../PyDebuggerBackendSwitcherAction.kt | 21 ++++++++++--------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties index 3b5e11fedc00..0b2bfe674c23 100644 --- a/python/pluginResources/messages/PyBundle.properties +++ b/python/pluginResources/messages/PyBundle.properties @@ -934,6 +934,7 @@ debugger.backend.debugpy.description=Python debugger backend built on the Debug debugger.backend.debugpy.disabled.tooltip=debugpy requires Python 3.9 or later debugger.backend.debugpy.disabled.remote.tooltip=debugpy is not supported for remote Python interpreters debugger.backend.debugpy.disabled.not.installed.tooltip=Install the Python DAP Debugger plugin to use the debugpy backend +debugger.backend.debugpy.disabled.not.enabled.tooltip=Enable the Python DAP Debugger plugin to use the debugpy backend debugger.backend.install.debugpy.plugin=Install Python DAP Debugger Plugin debugger.backend.enable.debugpy.plugin=Enable Python DAP Debugger Plugin debugger.backend.report.issue.debugpy=Report an Issue with debugpy @@ -1625,6 +1626,7 @@ advertiser.python.dap.plugin.enable.text=Enable Plugin debugger.dap.plugin.install.got.it.header=Try the Python DAP Debugger plugin debugger.dap.plugin.install.got.it.text=Install the Python DAP Debugger plugin for faster and more reliable Python debugging with debugpy +debugger.dap.plugin.enable.got.it.text=Enable the Python DAP Debugger plugin for faster and more reliable Python debugging with debugpy action.PyInstallPackage.text=Install action.PyInstallPackageAction.text=Advanced Package Install\u2026 diff --git a/python/src/com/jetbrains/python/debugger/PyDapPluginInstallGotItListener.kt b/python/src/com/jetbrains/python/debugger/PyDapPluginInstallGotItListener.kt index 60d0ddebe43f..d47b7d63a8ed 100644 --- a/python/src/com/jetbrains/python/debugger/PyDapPluginInstallGotItListener.kt +++ b/python/src/com/jetbrains/python/debugger/PyDapPluginInstallGotItListener.kt @@ -40,8 +40,13 @@ internal class PyDapPluginInstallGotItListener : XDebuggerManagerListener { if (isAcked()) return val project = session.project - val builder = GotItComponentBuilder { PyBundle.message("debugger.dap.plugin.install.got.it.text") } - .withHeader(PyBundle.message("debugger.dap.plugin.install.got.it.header")) + // Resolved lazily: the tooltip can appear up to 30 seconds later, and the plugin may be enabled meanwhile. + val builder = GotItComponentBuilder { + PyBundle.message( + if (isPythonDapPluginInstalledButDisabled()) "debugger.dap.plugin.enable.got.it.text" + else "debugger.dap.plugin.install.got.it.text" + ) + }.withHeader(PyBundle.message("debugger.dap.plugin.install.got.it.header")) showGotItWhenContentSelected(session, builder) { findBackendSwitcherButton(project) } diff --git a/python/src/com/jetbrains/python/debugger/PyDebuggerBackendSwitcherAction.kt b/python/src/com/jetbrains/python/debugger/PyDebuggerBackendSwitcherAction.kt index a974244339e6..b3df875495a7 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebuggerBackendSwitcherAction.kt +++ b/python/src/com/jetbrains/python/debugger/PyDebuggerBackendSwitcherAction.kt @@ -166,16 +166,17 @@ internal class PyDebuggerBackendSwitcherAction : ComboBoxAction(), DumbAware { if (backend == PyDebuggerBackend.DEBUGPY && !isDebugpyAvailableInProject(project)) { e.presentation.isEnabled = false @Suppress("DialogTitleCapitalization") - val disabledMsg = if (!isPythonDapPluginInstalledAndEnabled()) { - PyBundle.message("debugger.backend.debugpy.disabled.not.installed.tooltip") - } - else { - val sdk = getEffectiveSdk(project) - if (sdk != null && PythonSdkUtil.isRemote(sdk)) { - PyBundle.message("debugger.backend.debugpy.disabled.remote.tooltip") - } - else { - PyBundle.message("debugger.backend.debugpy.disabled.tooltip") + val disabledMsg = when { + isPythonDapPluginInstalledButDisabled() -> PyBundle.message("debugger.backend.debugpy.disabled.not.enabled.tooltip") + !isPythonDapPluginInstalledAndEnabled() -> PyBundle.message("debugger.backend.debugpy.disabled.not.installed.tooltip") + else -> { + val sdk = getEffectiveSdk(project) + if (sdk != null && PythonSdkUtil.isRemote(sdk)) { + PyBundle.message("debugger.backend.debugpy.disabled.remote.tooltip") + } + else { + PyBundle.message("debugger.backend.debugpy.disabled.tooltip") + } } } e.presentation.description = disabledMsg