Skip to content

Commit 44bc6eb

Browse files
Merge pull request #3213 from continuedev/pe/jb-apply-bugfix
bugfix: use correct config.json when applying
2 parents 2593515 + 7e466e7 commit 44bc6eb

File tree

1 file changed

+32
-6
lines changed
  • extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue

1 file changed

+32
-6
lines changed

extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt

+32-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import java.net.NetworkInterface
5151
import java.nio.charset.Charset
5252
import java.nio.file.Paths
5353
import java.util.*
54+
import kotlin.coroutines.resume
5455

5556

5657
fun uuid(): String {
@@ -106,7 +107,9 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) :
106107
for (event in events) {
107108
if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith(
108109
".continue\\config.json"
109-
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json")
110+
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(
111+
".continuerc.json"
112+
)
110113
) {
111114
return object : AsyncFileListener.ChangeApplier {
112115
override fun afterVfsChange() {
@@ -662,18 +665,41 @@ class IdeProtocolClient(
662665
var llm = getModelByRole(config, "applyCodeBlock")
663666

664667
if (llm == null) {
665-
val models = (config as? Map<*, *>)?.get("models") as? List<Map<*, *>>
666-
llm = models?.find { model -> model["title"] == curSelectedModelTitle } as Map<String, Any>
667-
668-
if (llm == null) {
669-
showToast("error", "Model '$curSelectedModelTitle' not found in config.")
668+
llm = try {
669+
suspendCancellableCoroutine { continuation ->
670+
continuePluginService.coreMessenger?.request(
671+
"config/getSerializedProfileInfo",
672+
null,
673+
null
674+
) { response ->
675+
val models =
676+
((response as Map<String, Any>)["config"] as Map<String, Any>)["models"] as List<Map<String, Any>>
677+
val foundModel = models.find { it["title"] == curSelectedModelTitle }
678+
679+
if (foundModel == null) {
680+
launch {
681+
showToast(
682+
"error",
683+
"Model '$curSelectedModelTitle' not found in config."
684+
)
685+
}
686+
continuation.resume(null)
687+
} else {
688+
continuation.resume(foundModel)
689+
}
690+
}
691+
}
692+
} catch (e: Exception) {
693+
launch { showToast("error", "Failed to fetch model configuration") }
670694
respond(null)
671695
return@launch
672696
}
673697
}
674698

699+
675700
val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: ""
676701

702+
677703
val prompt =
678704
"The following code was suggested as an edit:\n```\n${text}\n```\nPlease apply it to the previous code."
679705

0 commit comments

Comments
 (0)