@@ -7,6 +7,7 @@ import com.intellij.execution.process.ProcessTerminatedListener
77import com.intellij.execution.runners.ExecutionEnvironment
88import com.intellij.execution.target.value.TargetValue
99import com.intellij.execution.wsl.WslPath
10+ import com.intellij.ide.util.PropertiesComponent
1011import com.intellij.javascript.debugger.CommandLineDebugConfigurator
1112import com.intellij.javascript.nodejs.NodeCommandLineUtil
1213import com.intellij.javascript.nodejs.NodeCommandLineUtil.createConsole
@@ -15,8 +16,13 @@ import com.intellij.javascript.nodejs.execution.NodeBaseRunProfileState
1516import com.intellij.javascript.nodejs.execution.NodeTargetRun
1617import com.intellij.javascript.nodejs.execution.NodeTargetRunOptions
1718import com.intellij.javascript.nodejs.npm.*
19+ import com.intellij.notification.NotificationAction
20+ import com.intellij.openapi.diagnostic.thisLogger
1821import com.intellij.openapi.project.Project
22+ import com.intellij.openapi.ui.MessageType
23+ import com.intellij.openapi.wm.ToolWindowManager
1924import com.intellij.util.execution.ParametersListUtil
25+ import com.intellij.xdebugger.impl.XDebuggerManagerImpl
2026import dev.nx.console.telemetry.TelemetryService
2127import dev.nx.console.utils.*
2228
@@ -57,7 +63,57 @@ class NxCommandLineState(
5763 " ${nxProjects.first()} :${nxTargets.first()}${if (nxTargetsConfiguration.isBlank().not ()) " :$nxTargetsConfiguration " else " " } "
5864 )
5965
60- if (configurator == = null ) {
66+ if (configurator == = null || configurator is CommandLineDebugConfigurator ) {
67+ try {
68+ val hideNotificationPropertyKey =
69+ " dev.nx.console.hide_debug_source_map_notification"
70+ val lastNotificationTimeKey =
71+ " dev.nx.console.last_debug_source_map_notification_time"
72+
73+ val shouldHideNotification =
74+ PropertiesComponent .getInstance(project).getBoolean(hideNotificationPropertyKey)
75+
76+ // we don't want to spam users with notification but only show it in the correct
77+ // context
78+ val debugToolwindowIsVisible =
79+ ToolWindowManager .getInstance(project)
80+ .getToolWindow(XDebuggerManagerImpl .getNotificationGroup().toolWindowId)
81+ ?.isVisible
82+ ? : false
83+
84+ val currentTime = System .currentTimeMillis()
85+ val lastNotificationTime =
86+ PropertiesComponent .getInstance(project).getLong(lastNotificationTimeKey, 0 )
87+ val tenMinutesPassed = (currentTime - lastNotificationTime) > 600000
88+
89+ if (! shouldHideNotification && debugToolwindowIsVisible && tenMinutesPassed) {
90+ val notification =
91+ XDebuggerManagerImpl .getNotificationGroup()
92+ .createNotification(
93+ " For debugging to work with Nx Console, pl" +
94+ " ease ensure source maps are generated by the underlying tooling." ,
95+ MessageType .INFO
96+ )
97+ notification.addActions(
98+ setOf (
99+ NotificationAction .createSimpleExpiring(" OK" ) { notification.expire() },
100+ NotificationAction .createSimpleExpiring(" Don't show again" ) {
101+ notification.expire()
102+ PropertiesComponent .getInstance(project)
103+ .setValue(hideNotificationPropertyKey, true )
104+ }
105+ )
106+ )
107+ notification.notify(project)
108+ PropertiesComponent .getInstance(project)
109+ .setValue(lastNotificationTimeKey, currentTime.toString())
110+ }
111+ } catch (e: Throwable ) {
112+ // this is a completely un-critical operation, so we don't care if something goes
113+ // wrong during it
114+ thisLogger().debug(" Failed to show source map notification" , e)
115+ }
116+
61117 TelemetryService .getInstance(project)
62118 .featureUsed(" Nx Run - from context menu/target list/codelens - debug" )
63119 } else {
0 commit comments