diff --git a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt index 9ab5e16f..d22804f2 100644 --- a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt +++ b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt @@ -9,11 +9,13 @@ import com.intellij.openapi.startup.StartupActivity import com.smallcloud.refactai.io.CloudMessageService import com.smallcloud.refactai.listeners.UninstallListener import com.smallcloud.refactai.lsp.LSPActiveDocNotifierService +import com.smallcloud.refactai.notifications.emitInfo import com.smallcloud.refactai.notifications.notificationStartup import com.smallcloud.refactai.panes.sharedchat.ChatPaneInvokeAction import com.smallcloud.refactai.privacy.PrivacyService import com.smallcloud.refactai.settings.AppSettingsState import com.smallcloud.refactai.settings.settingsStartup +import com.smallcloud.refactai.utils.isJcefCanStart import java.util.concurrent.atomic.AtomicBoolean import com.smallcloud.refactai.lsp.LSPProcessHolder.Companion.getInstance as getLSPProcessHolder @@ -32,6 +34,9 @@ class Initializer : StartupActivity, Disposable { PluginInstaller.addStateListener(UninstallListener()) UpdateChecker.instance ApplicationManager.getApplication().getService(CloudMessageService::class.java) + if (!isJcefCanStart()) { + emitInfo(RefactAIBundle.message("notifications.chatCanNotStartWarning"), false) + } } getLSPProcessHolder(project) project.getService(LSPActiveDocNotifierService::class.java) diff --git a/src/main/kotlin/com/smallcloud/refactai/notifications/Notifications.kt b/src/main/kotlin/com/smallcloud/refactai/notifications/Notifications.kt index f2d2896c..0e5c593a 100644 --- a/src/main/kotlin/com/smallcloud/refactai/notifications/Notifications.kt +++ b/src/main/kotlin/com/smallcloud/refactai/notifications/Notifications.kt @@ -221,7 +221,13 @@ fun emitInfo(msg: String, needToDeleteLast: Boolean = true) { if (needToDeleteLast) removeLastNotification() val project = getLastUsedProject() val notification = NotificationGroupManager.getInstance().getNotificationGroup("Refact AI Notification Group") - .createNotification(Resources.titleStr, msg, NotificationType.INFORMATION) + .createNotification(Resources.titleStr, msg, NotificationType.INFORMATION).setListener(object : Adapter() { + override fun hyperlinkActivated(notification: Notification, event: HyperlinkEvent) { + val url: URL = event.url + BrowserUtil.browse(url) + notification.expire() + } + }) notification.icon = Resources.Icons.LOGO_RED_16x16 notification.addAction(NotificationAction.createSimple(RefactAIBundle.message("notifications.settingsAndPrivacy")) { diff --git a/src/main/kotlin/com/smallcloud/refactai/panes/RefactAIToolboxPaneFactory.kt b/src/main/kotlin/com/smallcloud/refactai/panes/RefactAIToolboxPaneFactory.kt index 617ae6ab..ad8f14ac 100644 --- a/src/main/kotlin/com/smallcloud/refactai/panes/RefactAIToolboxPaneFactory.kt +++ b/src/main/kotlin/com/smallcloud/refactai/panes/RefactAIToolboxPaneFactory.kt @@ -8,10 +8,10 @@ import com.intellij.openapi.wm.ToolWindowFactory import com.intellij.openapi.wm.ToolWindowManager import com.intellij.ui.content.Content import com.intellij.ui.content.ContentFactory -import com.intellij.ui.jcef.JBCefApp import com.smallcloud.refactai.Resources import com.smallcloud.refactai.panes.sharedchat.ChatPanes import com.smallcloud.refactai.utils.getLastUsedProject +import com.smallcloud.refactai.utils.isJcefCanStart class RefactAIToolboxPaneFactory : ToolWindowFactory { @@ -20,15 +20,7 @@ class RefactAIToolboxPaneFactory : ToolWindowFactory { super.init(toolWindow) } - override fun isApplicable(project: Project): Boolean { - return try { - JBCefApp.isSupported() && JBCefApp.isStarted() - JBCefApp.isSupported() - } catch (_: Exception) { - false - } - } - + override fun isApplicable(project: Project): Boolean = isJcefCanStart() override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { val contentFactory = ContentFactory.getInstance() diff --git a/src/main/kotlin/com/smallcloud/refactai/utils/JCefUtils.kt b/src/main/kotlin/com/smallcloud/refactai/utils/JCefUtils.kt new file mode 100644 index 00000000..7aa092df --- /dev/null +++ b/src/main/kotlin/com/smallcloud/refactai/utils/JCefUtils.kt @@ -0,0 +1,12 @@ +package com.smallcloud.refactai.utils + +import com.intellij.ui.jcef.JBCefApp + +fun isJcefCanStart(): Boolean { + return try { + JBCefApp.isSupported() && JBCefApp.isStarted() + JBCefApp.isSupported() + } catch (_: Exception) { + false + } +} \ No newline at end of file diff --git a/src/main/resources/bundles/RefactAI.properties b/src/main/resources/bundles/RefactAI.properties index 14ef11a9..efbaec34 100644 --- a/src/main/resources/bundles/RefactAI.properties +++ b/src/main/resources/bundles/RefactAI.properties @@ -90,3 +90,4 @@ statusBar.notificationAstVecdbLimitMsg=AST or VecDB file number limit reached, y errorReport.actionText=Open GitHub Issue notifications.embeddedWarning=You may have noticed Refact.ai is slower in version 2024.2. We're sorry! The fix is in 2024.3, so please upgrade when it's available! +notifications.chatCanNotStartWarning=The chat feature could not start in your JetBrains IDE. Please refer to the documentation for setup and troubleshooting steps.