Skip to content

Commit 1e0e57f

Browse files
committed
fix(llm): fix 223 version issue
1 parent 2ff987d commit 1e0e57f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

core/src/main/kotlin/cc/unitmesh/devti/llm2/GithubCopilotModelInitActivity.kt renamed to core/src/233/main/kotlin/cc/unitmesh/devti/llm2/GithubCopilotModelInitActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
77

88
/**
99
* 启动时初始化 GitHub Copilot 模型的 Activity
10+
* 仅适用于 IDEA 233+ 版本
1011
*/
1112
class GithubCopilotModelInitActivity : ProjectActivity {
1213
@RequiresBackgroundThread

core/src/main/kotlin/cc/unitmesh/devti/gui/AutoDevToolWindowFactory.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import cc.unitmesh.devti.gui.chat.ChatCodingService
66
import cc.unitmesh.devti.gui.chat.NormalChatCodingPanel
77
import cc.unitmesh.devti.gui.chat.message.ChatActionType
88
import cc.unitmesh.devti.inline.AutoDevInlineChatProvider
9+
import cc.unitmesh.devti.llm2.GithubCopilotDetector
10+
import cc.unitmesh.devti.llm2.GithubCopilotManager
911
import cc.unitmesh.devti.provider.observer.AgentObserver
1012
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback
1113
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.componentStateChanged
@@ -22,6 +24,10 @@ import com.intellij.openapi.wm.ToolWindowFactory
2224
import com.intellij.openapi.wm.ToolWindowManager
2325
import com.intellij.ui.content.Content
2426
import com.intellij.ui.content.ContentFactory
27+
import kotlinx.coroutines.CoroutineScope
28+
import kotlinx.coroutines.Dispatchers
29+
import kotlinx.coroutines.SupervisorJob
30+
import kotlinx.coroutines.launch
2531

2632
private const val NORMAL_CHAT = "AutoDev Chat"
2733
private const val SKETCH_TITLE = "Sketch"
@@ -64,6 +70,25 @@ class AutoDevToolWindowFactory : ToolWindowFactory, DumbAware {
6470
private fun initForIdea223(project: Project) {
6571
AutoDevInlineChatProvider.addListener(project)
6672
AgentObserver.register(project)
73+
initializeGithubCopilotModelsForIdea223(project)
74+
}
75+
76+
/**
77+
* Initialize GitHub Copilot models for IDEA 223 compatibility
78+
*/
79+
private fun initializeGithubCopilotModelsForIdea223(project: Project) {
80+
// 使用协程在后台线程执行初始化
81+
val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
82+
scope.launch {
83+
if (ApplicationManager.getApplication().isUnitTestMode) return@launch
84+
85+
// 只有当用户已配置 GitHub Copilot 时才进行初始化
86+
if (GithubCopilotDetector.isGithubCopilotConfigured()) {
87+
// 获取服务实例并初始化
88+
val manager = GithubCopilotManager.getInstance()
89+
manager.initialize()
90+
}
91+
}
6792
}
6893

6994
override fun init(toolWindow: ToolWindow) {

0 commit comments

Comments
 (0)