Skip to content

Commit ede6e2c

Browse files
authored
Merge pull request #2670 from digma-ai/message-for-eap-users
Message for eap users Closes #2669
2 parents 6c1adf8 + c41b170 commit ede6e2c

File tree

6 files changed

+147
-0
lines changed

6 files changed

+147
-0
lines changed

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ tasks {
316316
//see https://kotlin.github.io/analysis-api/testing-in-k2-locally.html
317317
"idea.kotlin.plugin.use.k2" to "true",
318318

319+
//"jcef.remote.enabled" to true,
320+
//"jcef.remote.debug" to true,
321+
//"ide.browser.jcef.log.level" to "error",
322+
319323
//"idea.ProcessCanceledException" to "disabled"
320324

321325

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pluginRepositoryUrl=https://github.com/digma-ai/digma-intellij-plugin.git
1515
#buildProfile=p241
1616
#buildProfile=p242
1717
#buildProfile=p243
18+
#buildProfile=p251
1819

1920
##build with real ide, will load the ide dependencies in the project. refresh gradle after change.
2021
##its is necessary when need to debug something for a specific IDE

ide-common/src/main/kotlin/org/digma/intellij/plugin/posthog/ActivityMonitor.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,32 @@ class ActivityMonitor(private val project: Project, cs: CoroutineScope) : Dispos
901901
}
902902

903903

904+
fun register251EAPPatchEvent(appName: String) {
905+
906+
val osType = System.getProperty("os.name")
907+
val ideInfo = ApplicationInfo.getInstance()
908+
val ideName = ideInfo.versionName
909+
val ideVersion = ideInfo.fullVersion
910+
val ideBuildNumber = ideInfo.build.asString()
911+
val pluginVersion = SemanticVersionUtil.getPluginVersionWithoutBuildNumberAndPreRelease("unknown")
912+
val uiVersion = UIVersioningService.getInstance().getCurrentUiVersion()
913+
val isJcefSupported = JBCefApp.isSupported()
914+
915+
registerCustomEvent("2025EAPWithJCEFRemote patch activated", mapOf(
916+
"app.name" to appName,
917+
"os.type" to osType,
918+
"ide.name" to ideName,
919+
"ide.version" to ideVersion,
920+
"ide.build" to ideBuildNumber,
921+
"plugin.version" to pluginVersion,
922+
"ui.version" to uiVersion,
923+
"user.type" to if (UniqueGeneratedUserId.isDevUser) "internal" else "external",
924+
"jcef.supported" to isJcefSupported,
925+
INSTALL_STATUS_PROPERTY_NAME to getCurrentInstallStatus()
926+
))
927+
}
928+
929+
904930
private fun registerSessionDetails() {
905931

906932
SessionMetadataProperties.getInstance().put(CURRENT_INSTALL_STATUS_KEY, InstallStatus.Active)

src/main/java/org/digma/intellij/plugin/toolwindow/DigmaSidePaneToolWindowFactory.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Collections;
2727
import java.util.function.*;
2828

29+
import static org.digma.intellij.plugin.ui.common.JcefRemoteUtilsKt.*;
2930
import static org.digma.intellij.plugin.ui.common.MainToolWindowPanelKt.createMainToolWindowPanel;
3031

3132

@@ -47,6 +48,21 @@ public final class DigmaSidePaneToolWindowFactory implements ToolWindowFactory {
4748
@Override
4849
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
4950

51+
Log.log(LOGGER::info, project, "creating main tool window for project {}", project);
52+
53+
//patch for jcef issue:
54+
//https://github.com/digma-ai/digma-intellij-plugin/issues/2668
55+
//https://github.com/digma-ai/digma-intellij-plugin/issues/2669
56+
//https://youtrack.jetbrains.com/issue/IDEA-367610/jcef-initialization-crash-in-latest-2025.1-EAP-NullPointerException-Cannot-read-field-jsQueryFunction-because-config-is-null
57+
if (is2025EAPWithJCEFRemoteEnabled()){
58+
Log.log(LOGGER::info, project, "Jcef remote enabled for EAP , creating user message panel", project);
59+
sendPosthogEvent("Main");
60+
var messagePanel = create2025EAPMessagePanel(project);
61+
var content = ContentFactory.getInstance().createContent(messagePanel, null, false);
62+
toolWindow.getContentManager().addContent(content);
63+
return;
64+
}
65+
5066

5167
//initialize AnalyticsService early so the UI can detect the connection status when created
5268
AnalyticsService.getInstance(project);
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package org.digma.intellij.plugin.ui.common
2+
3+
import com.intellij.openapi.application.ApplicationInfo
4+
import com.intellij.openapi.project.Project
5+
import com.intellij.ui.jcef.JBCefApp
6+
import com.intellij.util.ui.JBUI.Borders.empty
7+
import org.digma.intellij.plugin.common.findActiveProject
8+
import org.digma.intellij.plugin.posthog.ActivityMonitor
9+
import org.digma.intellij.plugin.ui.common.statuspanels.createSlackLinkPanel
10+
import org.digma.intellij.plugin.ui.common.statuspanels.createTextPaneWithHtml
11+
import org.digma.intellij.plugin.ui.common.statuspanels.wrapWithScrollable
12+
import org.digma.intellij.plugin.ui.list.listBackground
13+
import java.awt.BorderLayout
14+
import javax.swing.JPanel
15+
16+
17+
fun is2025EAPWithJCEFRemoteEnabled(): Boolean {
18+
19+
return if (ApplicationInfo.getInstance().build.baselineVersion == 251){
20+
//just touch it so it will initialize static variables
21+
val isJcefSupported = JBCefApp.isSupported()
22+
//do something with the variable so that the compiler will not optimize and remove this code
23+
println("isJCEFSupported = $isJcefSupported")
24+
25+
//this is the return value
26+
java.lang.Boolean.getBoolean("jcef.remote.enabled")
27+
28+
} else {
29+
false
30+
}
31+
}
32+
33+
34+
fun sendPosthogEvent(appName:String) {
35+
36+
findActiveProject()?.let { project ->
37+
ActivityMonitor.getInstance(project).register251EAPPatchEvent(appName)
38+
}
39+
40+
}
41+
42+
43+
fun create2025EAPMessagePanel(project:Project): JPanel {
44+
45+
val mainPanel = JPanel(BorderLayout())
46+
mainPanel.isOpaque = false
47+
mainPanel.border = empty()
48+
mainPanel.background = listBackground()
49+
50+
val htmlText = getMessageHtml()
51+
val textPane = createTextPaneWithHtml(htmlText)
52+
53+
mainPanel.add(textPane, BorderLayout.CENTER)
54+
55+
val slackPanel = createSlackLinkPanel(project)
56+
mainPanel.add(slackPanel,BorderLayout.SOUTH)
57+
58+
return wrapWithScrollable(mainPanel)
59+
}
60+
61+
62+
fun getMessageHtml(): String {
63+
64+
val title = "Digma 2025.1 EAP workaround"
65+
val paragraph = "The latest Jetbrains 2025.1 EAP has an issue with JCEF that prevents Digma from working," +
66+
"Please add the following system properties to fix, and restart your IDE:"
67+
val paragraph2 = "Open the Idea help menu, search for 'Edit Custom Properties', add 'jcef.remote.enabled=false' and restart your IDE"
68+
69+
return "<html>" +
70+
"<head>" +
71+
"<style>" +
72+
"h3 {text-align: center;}" +
73+
"p {text-align: center;}" +
74+
"div {text-align: center;}" +
75+
"</style>" +
76+
"</head>" +
77+
"<body>" +
78+
"<h3>$title</h3>" +
79+
"<p>$paragraph</p>" +
80+
"<p>$paragraph2</p>" +
81+
"</body>" +
82+
"</html>"
83+
}
84+

src/main/kotlin/org/digma/intellij/plugin/ui/recentactivity/RecentActivityToolWindowFactory.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import org.digma.intellij.plugin.analytics.AnalyticsService
1212
import org.digma.intellij.plugin.log.Log
1313
import org.digma.intellij.plugin.recentactivity.RecentActivityToolWindowShower
1414
import org.digma.intellij.plugin.ui.RecentActivityToolWindowCardsController
15+
import org.digma.intellij.plugin.ui.common.create2025EAPMessagePanel
16+
import org.digma.intellij.plugin.ui.common.is2025EAPWithJCEFRemoteEnabled
17+
import org.digma.intellij.plugin.ui.common.sendPosthogEvent
1518
import org.digma.intellij.plugin.ui.common.statuspanels.createAggressiveUpdatePanel
1619
import org.digma.intellij.plugin.ui.common.statuspanels.createNoConnectionPanel
1720
import java.awt.CardLayout
@@ -25,6 +28,19 @@ class RecentActivityToolWindowFactory : ToolWindowFactory {
2528

2629
Log.log(logger::info, project, "creating recent activity tool window for project {}", project)
2730

31+
//patch for jcef issue:
32+
//https://github.com/digma-ai/digma-intellij-plugin/issues/2668
33+
//https://github.com/digma-ai/digma-intellij-plugin/issues/2669
34+
//https://youtrack.jetbrains.com/issue/IDEA-367610/jcef-initialization-crash-in-latest-2025.1-EAP-NullPointerException-Cannot-read-field-jsQueryFunction-because-config-is-null
35+
if (is2025EAPWithJCEFRemoteEnabled()){
36+
Log.log(logger::info, project, "Jcef remote enabled for EAP , creating user message panel", project)
37+
sendPosthogEvent("Recent Activity")
38+
val messagePanel = create2025EAPMessagePanel(project)
39+
val content = ContentFactory.getInstance().createContent(messagePanel, null, false)
40+
toolWindow.contentManager.addContent(content)
41+
return
42+
}
43+
2844
//initialize AnalyticsService early so the UI can detect the connection status when created
2945
AnalyticsService.getInstance(project)
3046

0 commit comments

Comments
 (0)