Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit746e960

Browse files
committed
feat(settings): 优化GitHub模型加载和占位符替换机制
改进GitHub Copilot模型初始化流程,使用增量加载替代全量刷新。为未加载的GitHub模型添加占位符显示,确保用户选择的模型在异步加载完成后正确替换。
1 parent92f55fc commit746e960

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

‎core/src/main/kotlin/cc/unitmesh/devti/settings/model/LLMModelManager.kt‎

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,46 @@ class LLMModelManager(
247247
}
248248
}
249249
}else {
250-
// Initialize GitHub Copilot in background andupdate UI when ready
250+
// Initialize GitHub Copilot in background andincrementally add models
251251
AutoDevAppScope.workerScope().launch {
252252
try {
253253
GithubCopilotManager.getInstance().initialize()
254-
// After initialization, update the UI on the EDT
254+
// Get fresh GitHub models after initialization
255+
val freshGithubModels= manager.getSupportedModels(forceRefresh=false)
256+
257+
// Add GitHub models incrementally without clearing existing items
255258
SwingUtilities.invokeLater {
256-
updateAllDropdowns(
257-
defaultModelDropdown,
258-
planLLMDropdown,
259-
actLLMDropdown,
260-
completionLLMDropdown,
261-
embeddingLLMDropdown,
262-
fastApplyLLMDropdown
263-
)
259+
freshGithubModels?.forEach { model->
260+
val modelItem=ModelItem("Github:${model.id}", model.id,false)
261+
262+
// Check if we need to replace placeholder items
263+
fun ComboBox<ModelItem>.replaceOrAddModel(newItem:ModelItem) {
264+
// Look for placeholder with same modelId
265+
for (iin0 untilthis.itemCount) {
266+
val existingItem=this.getItemAt(i)
267+
if (existingItem.modelId== newItem.modelId&&
268+
existingItem.displayName.contains("(loading...)")) {
269+
// Replace placeholder with real model
270+
this.removeItemAt(i)
271+
this.insertItemAt(newItem, i)
272+
this.selectedItem= newItem
273+
return
274+
}
275+
}
276+
// No placeholder found, just add the model
277+
this.addItem(newItem)
278+
}
279+
280+
if (model.isEmbedding) {
281+
embeddingLLMDropdown.replaceOrAddModel(modelItem)
282+
}else {
283+
defaultModelDropdown.replaceOrAddModel(modelItem)
284+
planLLMDropdown.replaceOrAddModel(modelItem)
285+
actLLMDropdown.replaceOrAddModel(modelItem)
286+
completionLLMDropdown.replaceOrAddModel(modelItem)
287+
fastApplyLLMDropdown.replaceOrAddModel(modelItem)
288+
}
289+
}
264290
}
265291
}catch (e:Exception) {
266292
// Silently handle initialization failures
@@ -301,13 +327,25 @@ class LLMModelManager(
301327
fun ComboBox<ModelItem>.selectModelById(modelId:String) {
302328
if (modelId.isEmpty())return
303329

330+
// First try to find existing item
304331
for (iin0 untilthis.itemCount) {
305332
val item=this.getItemAt(i)
306333
if (item.modelId== modelId) {
307334
this.selectedItem= item
308-
break
335+
return
309336
}
310337
}
338+
339+
// If not found, check if it's likely a GitHub Copilot model
340+
val userModels=LlmConfig.load()
341+
val isUserCustomModel= userModels.any { it.name== modelId }
342+
343+
if (!isUserCustomModel&& modelId.isNotEmpty()) {
344+
// This is likely a GitHub Copilot model that's not loaded yet
345+
val placeholderItem=ModelItem("Github:$modelId (loading...)", modelId,false)
346+
this.addItem(placeholderItem)
347+
this.selectedItem= placeholderItem
348+
}
311349
}
312350

313351
// Set default model

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp