From b442182cd9eba1676dab8b88b3451c19462b6f25 Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 15:38:44 +0300 Subject: [PATCH 1/7] fix AccessDeniedException v2 http://github.com/smallcloudai/refact-intellij/issues/44 --- build.gradle.kts | 2 +- src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 996b08c1..39eee5a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { group = "com.smallcloud" -version = getVersionString("1.2.5") +version = getVersionString("1.2.6") repositories { mavenCentral() diff --git a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt index bf972596..559df725 100644 --- a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt +++ b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt @@ -25,6 +25,7 @@ import java.nio.file.StandardCopyOption import java.util.concurrent.Future import java.util.concurrent.TimeUnit import kotlin.io.path.Path +import kotlin.io.path.deleteIfExists import com.smallcloud.refactai.account.AccountManager.Companion.instance as AccountManager import com.smallcloud.refactai.io.InferenceGlobalContext.Companion.instance as InferenceGlobalContext @@ -99,6 +100,7 @@ class LSPProcessHolder: Disposable { } else { val path = Paths.get(BIN_PATH) path.parent.toFile().mkdirs() + path.deleteIfExists() Files.copy(input, path, StandardCopyOption.REPLACE_EXISTING) setExecutable(path.toFile()) } From c73abd0c5fcefbced43fe03fc6ac63c0396d139c Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 16:56:26 +0300 Subject: [PATCH 2/7] rudiment setting --- build.gradle.kts | 2 +- src/main/kotlin/com/smallcloud/refactai/PluginState.kt | 2 +- .../kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 39eee5a9..3d7b0775 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { group = "com.smallcloud" -version = getVersionString("1.2.6") +version = getVersionString("1.2.7") repositories { mavenCentral() diff --git a/src/main/kotlin/com/smallcloud/refactai/PluginState.kt b/src/main/kotlin/com/smallcloud/refactai/PluginState.kt index 9eabebaa..3a288aeb 100644 --- a/src/main/kotlin/com/smallcloud/refactai/PluginState.kt +++ b/src/main/kotlin/com/smallcloud/refactai/PluginState.kt @@ -67,7 +67,7 @@ class PluginState : Disposable { val instance: PluginState get() = ApplicationManager.getApplication().getService(PluginState::class.java) fun startup(settings: AppSettingsState) { - instance.isEnabled = settings.pluginIsEnabled + instance.isEnabled = true } } } diff --git a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt index 559df725..9571a2b2 100644 --- a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt +++ b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil.getTempDirectory import com.intellij.openapi.util.io.FileUtil.setExecutable import com.intellij.util.concurrency.AppExecutorUtil +import com.intellij.util.io.delete import com.intellij.util.messages.MessageBus import com.intellij.util.messages.Topic import com.smallcloud.refactai.Resources @@ -25,7 +26,7 @@ import java.nio.file.StandardCopyOption import java.util.concurrent.Future import java.util.concurrent.TimeUnit import kotlin.io.path.Path -import kotlin.io.path.deleteIfExists +import kotlin.io.path.exists import com.smallcloud.refactai.account.AccountManager.Companion.instance as AccountManager import com.smallcloud.refactai.io.InferenceGlobalContext.Companion.instance as InferenceGlobalContext @@ -100,7 +101,9 @@ class LSPProcessHolder: Disposable { } else { val path = Paths.get(BIN_PATH) path.parent.toFile().mkdirs() - path.deleteIfExists() + if (path.exists()) { + path.delete() + } Files.copy(input, path, StandardCopyOption.REPLACE_EXISTING) setExecutable(path.toFile()) } From cd08884cead92c6a229bb335b8e27844b66d3268 Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 18:53:21 +0300 Subject: [PATCH 3/7] fix multiple startups --- .../com/smallcloud/refactai/Initializer.kt | 21 ++++++++++++------- .../com/smallcloud/refactai/PluginState.kt | 11 ---------- .../refactai/lsp/LSPProcessHolder.kt | 11 ++++------ .../smallcloud/refactai/modes/ModeProvider.kt | 15 ++----------- .../refactai/privacy/PrivacyService.kt | 16 +++----------- .../refactai/status_bar/StatusBarWidget.kt | 6 ------ 6 files changed, 22 insertions(+), 58 deletions(-) diff --git a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt index a7283024..77a246ec 100644 --- a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt +++ b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt @@ -5,12 +5,11 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.ProjectActivity +import com.intellij.openapi.startup.StartupActivity import com.smallcloud.refactai.account.LoginStateService import com.smallcloud.refactai.account.login import com.smallcloud.refactai.io.ConnectivityManager import com.smallcloud.refactai.io.InferenceGlobalContext -import com.smallcloud.refactai.listeners.LastEditorGetterListener import com.smallcloud.refactai.listeners.UninstallListener import com.smallcloud.refactai.lsp.LSPProcessHolder import com.smallcloud.refactai.notifications.notificationStartup @@ -19,12 +18,16 @@ import com.smallcloud.refactai.settings.AppSettingsState import com.smallcloud.refactai.settings.settingsStartup import com.smallcloud.refactai.statistic.UsageStats import com.smallcloud.refactai.struct.DeploymentMode +import java.util.concurrent.atomic.AtomicBoolean + +class Initializer : StartupActivity, Disposable { + override fun runActivity(project: Project) { + PrivacyService.instance.projectOpened(project) + val shouldInitialize = !(initialized.getAndSet(true) || ApplicationManager.getApplication().isUnitTestMode) + if (!shouldInitialize) { + return + } -class Initializer : ProjectActivity, Disposable { - override suspend fun execute(project: Project) { - initialize(project) - } - private fun initialize(project: Project) { Logger.getInstance("SMCInitializer").info("Bin prefix = ${Resources.binPrefix}") ConnectivityManager.instance.startup() @@ -46,7 +49,6 @@ class Initializer : ProjectActivity, Disposable { settingsStartup() notificationStartup() UsageStats.instance - PrivacyService.instance.projectOpened(project) PluginInstaller.addStateListener(UninstallListener()) UpdateChecker.instance LSPProcessHolder.instance.startup() @@ -55,4 +57,7 @@ class Initializer : ProjectActivity, Disposable { override fun dispose() { } + companion object { + private val initialized = AtomicBoolean(false) + } } diff --git a/src/main/kotlin/com/smallcloud/refactai/PluginState.kt b/src/main/kotlin/com/smallcloud/refactai/PluginState.kt index 3a288aeb..95076386 100644 --- a/src/main/kotlin/com/smallcloud/refactai/PluginState.kt +++ b/src/main/kotlin/com/smallcloud/refactai/PluginState.kt @@ -11,7 +11,6 @@ interface ExtraInfoChangedNotifier { fun tooltipMessageChanged(newMsg: String?) {} fun inferenceMessageChanged(newMsg: String?) {} fun loginMessageChanged(newMsg: String?) {} - fun pluginEnableChanged(newVal: Boolean) {} companion object { val TOPIC = Topic.create("Extra Info Changed Notifier", ExtraInfoChangedNotifier::class.java) @@ -21,15 +20,6 @@ interface ExtraInfoChangedNotifier { class PluginState : Disposable { private val messageBus: MessageBus = ApplicationManager.getApplication().messageBus - var isEnabled: Boolean = false - set(value) { - if (value == field) return - field = value - messageBus - .syncPublisher(ExtraInfoChangedNotifier.TOPIC) - .pluginEnableChanged(field) - } - var tooltipMessage: String? = null get() = AppSettingsState.instance.tooltipMessage set(newMsg) { @@ -67,7 +57,6 @@ class PluginState : Disposable { val instance: PluginState get() = ApplicationManager.getApplication().getService(PluginState::class.java) fun startup(settings: AppSettingsState) { - instance.isEnabled = true } } } diff --git a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt index 9571a2b2..f481cb4f 100644 --- a/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt +++ b/src/main/kotlin/com/smallcloud/refactai/lsp/LSPProcessHolder.kt @@ -3,13 +3,13 @@ package com.smallcloud.refactai.lsp import com.google.gson.Gson import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.openapi.Disposable +import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil.getTempDirectory import com.intellij.openapi.util.io.FileUtil.setExecutable import com.intellij.util.concurrency.AppExecutorUtil -import com.intellij.util.io.delete import com.intellij.util.messages.MessageBus import com.intellij.util.messages.Topic import com.smallcloud.refactai.Resources @@ -26,7 +26,6 @@ import java.nio.file.StandardCopyOption import java.util.concurrent.Future import java.util.concurrent.TimeUnit import kotlin.io.path.Path -import kotlin.io.path.exists import com.smallcloud.refactai.account.AccountManager.Companion.instance as AccountManager import com.smallcloud.refactai.io.InferenceGlobalContext.Companion.instance as InferenceGlobalContext @@ -101,16 +100,12 @@ class LSPProcessHolder: Disposable { } else { val path = Paths.get(BIN_PATH) path.parent.toFile().mkdirs() - if (path.exists()) { - path.delete() - } Files.copy(input, path, StandardCopyOption.REPLACE_EXISTING) setExecutable(path.toFile()) } } settingsChanged() - capsTask = schedulerCaps.scheduleWithFixedDelay({ capabilities = getCaps() if (capabilities.cloudName.isNotEmpty()) { @@ -217,7 +212,9 @@ class LSPProcessHolder: Disposable { } companion object { - private val BIN_PATH = Path(getTempDirectory(), "refact-lsp${getExeSuffix()}").toString() + private val BIN_PATH = Path(getTempDirectory(), + ApplicationInfo.getInstance().build.toString().replace(Regex("[^A-Za-z0-9 ]"), "_") + + "_refact_lsp${getExeSuffix()}").toString() @JvmStatic val instance: LSPProcessHolder get() = ApplicationManager.getApplication().getService(LSPProcessHolder::class.java) diff --git a/src/main/kotlin/com/smallcloud/refactai/modes/ModeProvider.kt b/src/main/kotlin/com/smallcloud/refactai/modes/ModeProvider.kt index 11447ade..c3199b9f 100644 --- a/src/main/kotlin/com/smallcloud/refactai/modes/ModeProvider.kt +++ b/src/main/kotlin/com/smallcloud/refactai/modes/ModeProvider.kt @@ -49,8 +49,6 @@ class ModeProvider( private var activeMode: Mode? = null, private val pluginState: PluginState = PluginState.instance, ) : Disposable, InferenceGlobalContextChangedNotifier { - private val isEnabled: Boolean - get() = pluginState.isEnabled @Transient private val messageBus: MessageBus = ApplicationManager.getApplication().messageBus @@ -123,37 +121,28 @@ class ModeProvider( } fun beforeDocumentChangeNonBulk(event: DocumentEvent?, editor: Editor) { - if (!isEnabled) return if (event?.newFragment.toString() == DUMMY_IDENTIFIER) return beforeTextChangeEventsQueue.add(DocumentEventExtra(event, editor, currentTimeMillis())) } fun onTextChange(event: DocumentEvent?, editor: Editor, force: Boolean) { - if (!isEnabled) return if (event?.newFragment.toString() == DUMMY_IDENTIFIER) return onTextChangeEventsQueue.add(DocumentEventExtra(event, editor, currentTimeMillis(), force)) } fun onCaretChange(event: CaretEvent) { - if (!isEnabled) return activeMode?.onCaretChange(event) } - fun focusGained() { - if (!isEnabled) return - } + fun focusGained() {} - fun focusLost() { - if (!isEnabled) return - } + fun focusLost() {} fun onTabPressed(editor: Editor, caret: Caret?, dataContext: DataContext) { - if (!isEnabled) return activeMode?.onTabPressed(editor, caret, dataContext) } fun onEscPressed(editor: Editor, caret: Caret?, dataContext: DataContext) { - if (!isEnabled) return activeMode?.onEscPressed(editor, caret, dataContext) } diff --git a/src/main/kotlin/com/smallcloud/refactai/privacy/PrivacyService.kt b/src/main/kotlin/com/smallcloud/refactai/privacy/PrivacyService.kt index 1d16d99b..6388b850 100644 --- a/src/main/kotlin/com/smallcloud/refactai/privacy/PrivacyService.kt +++ b/src/main/kotlin/com/smallcloud/refactai/privacy/PrivacyService.kt @@ -3,8 +3,6 @@ package com.smallcloud.refactai.privacy import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ProjectManager -import com.intellij.openapi.project.VetoableProjectManagerListener import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFileManager import com.smallcloud.refactai.settings.PrivacyState @@ -73,14 +71,10 @@ data class PrivacyMember( } -class PrivacyService : VetoableProjectManagerListener, Disposable { +class PrivacyService : Disposable { private var privacyTree: MutableMap = emptyMap().toMutableMap() - init { - ProjectManager.getInstance().addProjectManagerListener(this) - } - - override fun projectOpened(project: Project) { + fun projectOpened(project: Project) { val path = project.basePath val virtualFile = VirtualFileManager.getInstance().findFileByNioPath(Path.of(path)) val node = virtualFile?.let { getMember(it) } @@ -231,11 +225,7 @@ class PrivacyService : VetoableProjectManagerListener, Disposable { get() = ApplicationManager.getApplication().getService(PrivacyService::class.java) } - override fun canClose(project: Project): Boolean { - return true - } - override fun dispose() { - ProjectManager.getInstance().removeProjectManagerListener(this) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt b/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt index 1bc89c99..09993b7c 100644 --- a/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt +++ b/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt @@ -100,10 +100,6 @@ class SMCStatusBarWidget(project: Project) : EditorBasedWidget(project), CustomS override fun inferenceMessageChanged(newMsg: String?) { update(newMsg) } - - override fun pluginEnableChanged(newVal: Boolean) { - update(null) - } }) ApplicationManager.getApplication() .messageBus @@ -158,8 +154,6 @@ class SMCStatusBarWidget(project: Project) : EditorBasedWidget(project), CustomS } private fun getIcon(): Icon { - if (!PluginState.instance.isEnabled) - return AllIcons.Diff.GutterCheckBoxIndeterminate if (!AccountManager.isLoggedIn && InferenceGlobalContext.isCloud) { return LOGO_12x12 } From 5b5b857368e49144dc79baab8e1a21770b3b849b Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 19:20:22 +0300 Subject: [PATCH 4/7] all --- .../smallcloud/refactai/aitoolbox/table/renderers/colorize.kt | 4 ++-- .../refactai/panes/gptchat/ui/CustomSearchTextArea.kt | 4 ++-- .../smallcloud/refactai/panes/gptchat/ui/HistoryComponent.kt | 2 +- .../smallcloud/refactai/settings/AppSettingsConfigurable.kt | 4 ++-- .../com/smallcloud/refactai/status_bar/StatusBarWidget.kt | 2 +- src/main/resources/bundles/RefactAI.properties | 3 +-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt b/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt index 67eb90ca..74dafa53 100644 --- a/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt +++ b/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt @@ -1,6 +1,6 @@ package com.smallcloud.refactai.aitoolbox.table.renderers -import com.intellij.util.IconUtil +import com.intellij.openapi.util.IconLoader import java.awt.Color import java.awt.image.RGBImageFilter import javax.swing.Icon @@ -23,5 +23,5 @@ private class FullColorizeFilter(val color: Color) : RGBImageFilter() { internal fun colorize(originalIcon: Icon, foreground: Color): Icon { - return IconUtil.filterIcon(originalIcon, { FullColorizeFilter(foreground) }, null) + return IconLoader.filterIcon(originalIcon) { FullColorizeFilter(foreground) } } \ No newline at end of file diff --git a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt index e3faf376..79aa68ad 100644 --- a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt +++ b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt @@ -15,6 +15,7 @@ import com.intellij.openapi.keymap.KeymapUtil import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.LightEditActionFactory import com.intellij.openapi.ui.ComboBox +import com.intellij.openapi.util.IconLoader import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil @@ -24,7 +25,6 @@ import com.intellij.ui.components.JBLabel import com.intellij.ui.components.JBScrollPane import com.intellij.ui.components.panels.NonOpaquePanel import com.intellij.ui.scale.JBUIScale -import com.intellij.util.IconUtil import com.intellij.util.ui.JBInsets import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil @@ -67,7 +67,7 @@ private class FullColorizeFilter(val color: Color) : RGBImageFilter() { internal fun colorize(originalIcon: Icon, foreground: Color): Icon { - return IconUtil.filterIcon(originalIcon, { FullColorizeFilter(foreground) }, null) + return IconLoader.filterIcon(originalIcon) { FullColorizeFilter(foreground) } } private fun getFilenameFromEditor(editor: Editor?): String { diff --git a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/HistoryComponent.kt b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/HistoryComponent.kt index 965ae8e4..56eb2306 100644 --- a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/HistoryComponent.kt +++ b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/HistoryComponent.kt @@ -69,7 +69,7 @@ class HistoryComponent(private val state: State): JBPanel(), N mainPanel.isOpaque = false mainPanel.border = JBUI.Borders.emptyLeft(8) add(mainPanel) - var helloString = RefactAIBundle.message("aiToolbox.panes.chat.helloString", "\uD83D\uDC4B") + var helloString = RefactAIBundle.message("aiToolbox.panes.chat.helloString") if (!AccountManager.isLoggedIn) { helloString += " ${RefactAIBundle.message("aiToolbox.panes.chat.dontForgetLogin")}" } diff --git a/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsConfigurable.kt b/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsConfigurable.kt index 9defa279..79d3c9e5 100644 --- a/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsConfigurable.kt +++ b/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsConfigurable.kt @@ -52,7 +52,7 @@ class AppSettingsConfigurable : Configurable { override fun isModified(): Boolean { var modified = (mySettingsComponent!!.tokenText.isNotEmpty() && (AccountManager.apiKey == null || - mySettingsComponent!!.tokenText != AccountManager.apiKey)) + mySettingsComponent!!.tokenText.trim() != AccountManager.apiKey)) modified = modified || (mySettingsComponent!!.tokenText.isEmpty() && AccountManager.apiKey != null) modified = modified || (mySettingsComponent!!.modelText.isNotEmpty() @@ -84,7 +84,7 @@ class AppSettingsConfigurable : Configurable { } override fun apply() { - AccountManager.apiKey = mySettingsComponent!!.tokenText.ifEmpty { null } + AccountManager.apiKey = mySettingsComponent!!.tokenText.trim().ifEmpty { null } InferenceGlobalContext.model = mySettingsComponent!!.modelText.ifEmpty { null } InferenceGlobalContext.inferenceUri = makeRightUrl(mySettingsComponent!!.contrastUrlText.ifEmpty { null }) diff --git a/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt b/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt index 09993b7c..4a3e5399 100644 --- a/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt +++ b/src/main/kotlin/com/smallcloud/refactai/status_bar/StatusBarWidget.kt @@ -234,7 +234,7 @@ class SMCStatusBarWidget(project: Project) : EditorBasedWidget(project), CustomS component!!.icon = getIcon() component!!.toolTipText = newMsg ?: getTooltipText() myStatusBar!!.updateWidget(ID()) - val statusBar = WindowManager.getInstance().getStatusBar(myProject) + val statusBar = WindowManager.getInstance().getStatusBar(project) statusBar?.component?.updateUI() }, ModalityState.any() diff --git a/src/main/resources/bundles/RefactAI.properties b/src/main/resources/bundles/RefactAI.properties index 13e8cce3..844ef304 100644 --- a/src/main/resources/bundles/RefactAI.properties +++ b/src/main/resources/bundles/RefactAI.properties @@ -86,8 +86,7 @@ aiToolbox.panes.toolbox.placeholder=Don't forget to log in! aiToolbox.panes.chat.alsoSend=Also send selected text aiToolbox.panes.chat.addFileForContext=Attach {0} -aiToolbox.panes.chat.helloString=Hi! {0}\n\ - This chat has more features, and it's more responsive than a free one you might find on the web. +aiToolbox.panes.chat.helloString=Welcome to Refact chat! How can I assist you today? Please type your question below. aiToolbox.panes.chat.dontForgetLogin=Don't forget to log in! aiToolbox.panes.chat.placeholderSelfhosted=No chats available From 5e238f82b3348b0b1ab8bd5ff930b78928e76fde Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 19:35:16 +0300 Subject: [PATCH 5/7] all2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ceddf08f..d0148581 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -org.gradle.jvmargs=-Xmx2048m \ No newline at end of file +org.gradle.jvmargs=-Xmx512m \ No newline at end of file From 7126e73c05af6258b32eeee3edb0ba29eddd16ac Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Wed, 6 Dec 2023 19:40:50 +0300 Subject: [PATCH 6/7] typo --- .../com/smallcloud/refactai/settings/AppSettingsState.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsState.kt b/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsState.kt index a64d7e62..7f7d8d46 100644 --- a/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsState.kt +++ b/src/main/kotlin/com/smallcloud/refactai/settings/AppSettingsState.kt @@ -39,7 +39,6 @@ class AppSettingsState : PersistentStateComponent, Disposable var loginMessage: String? = null var tooltipMessage: String? = null var inferenceMessage: String? = null - var pluginIsEnabled: Boolean = true var useAutoCompletion: Boolean = true var useMultipleFilesCompletion: Boolean = false var startupLoggedIn: Boolean = false @@ -112,10 +111,6 @@ class AppSettingsState : PersistentStateComponent, Disposable override fun inferenceMessageChanged(newMsg: String?) { instance.inferenceMessage = newMsg } - - override fun pluginEnableChanged(newVal: Boolean) { - instance.pluginIsEnabled = newVal - } }) messageBus .connect(PluginState.instance) From 09eccf51edad3b67b1b190183776f40c4b22d042 Mon Sep 17 00:00:00 2001 From: reymondzzzz Date: Thu, 7 Dec 2023 11:27:08 +0300 Subject: [PATCH 7/7] all3 --- gradle.properties | 2 +- src/main/kotlin/com/smallcloud/refactai/Initializer.kt | 6 +++--- .../refactai/aitoolbox/table/renderers/colorize.kt | 4 ++-- .../refactai/panes/gptchat/ui/CustomSearchTextArea.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index d0148581..ceddf08f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -org.gradle.jvmargs=-Xmx512m \ No newline at end of file +org.gradle.jvmargs=-Xmx2048m \ No newline at end of file diff --git a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt index 77a246ec..64ac7f38 100644 --- a/src/main/kotlin/com/smallcloud/refactai/Initializer.kt +++ b/src/main/kotlin/com/smallcloud/refactai/Initializer.kt @@ -5,7 +5,7 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.StartupActivity +import com.intellij.openapi.startup.ProjectActivity import com.smallcloud.refactai.account.LoginStateService import com.smallcloud.refactai.account.login import com.smallcloud.refactai.io.ConnectivityManager @@ -20,8 +20,8 @@ import com.smallcloud.refactai.statistic.UsageStats import com.smallcloud.refactai.struct.DeploymentMode import java.util.concurrent.atomic.AtomicBoolean -class Initializer : StartupActivity, Disposable { - override fun runActivity(project: Project) { +class Initializer : ProjectActivity, Disposable { + override suspend fun execute(project: Project) { PrivacyService.instance.projectOpened(project) val shouldInitialize = !(initialized.getAndSet(true) || ApplicationManager.getApplication().isUnitTestMode) if (!shouldInitialize) { diff --git a/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt b/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt index 74dafa53..67eb90ca 100644 --- a/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt +++ b/src/main/kotlin/com/smallcloud/refactai/aitoolbox/table/renderers/colorize.kt @@ -1,6 +1,6 @@ package com.smallcloud.refactai.aitoolbox.table.renderers -import com.intellij.openapi.util.IconLoader +import com.intellij.util.IconUtil import java.awt.Color import java.awt.image.RGBImageFilter import javax.swing.Icon @@ -23,5 +23,5 @@ private class FullColorizeFilter(val color: Color) : RGBImageFilter() { internal fun colorize(originalIcon: Icon, foreground: Color): Icon { - return IconLoader.filterIcon(originalIcon) { FullColorizeFilter(foreground) } + return IconUtil.filterIcon(originalIcon, { FullColorizeFilter(foreground) }, null) } \ No newline at end of file diff --git a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt index 79aa68ad..e3faf376 100644 --- a/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt +++ b/src/main/kotlin/com/smallcloud/refactai/panes/gptchat/ui/CustomSearchTextArea.kt @@ -15,7 +15,6 @@ import com.intellij.openapi.keymap.KeymapUtil import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.LightEditActionFactory import com.intellij.openapi.ui.ComboBox -import com.intellij.openapi.util.IconLoader import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil @@ -25,6 +24,7 @@ import com.intellij.ui.components.JBLabel import com.intellij.ui.components.JBScrollPane import com.intellij.ui.components.panels.NonOpaquePanel import com.intellij.ui.scale.JBUIScale +import com.intellij.util.IconUtil import com.intellij.util.ui.JBInsets import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil @@ -67,7 +67,7 @@ private class FullColorizeFilter(val color: Color) : RGBImageFilter() { internal fun colorize(originalIcon: Icon, foreground: Color): Icon { - return IconLoader.filterIcon(originalIcon) { FullColorizeFilter(foreground) } + return IconUtil.filterIcon(originalIcon, { FullColorizeFilter(foreground) }, null) } private fun getFilenameFromEditor(editor: Editor?): String {