Skip to content

Commit 7ebd9d8

Browse files
committed
fix(clients): existing modelIds and hosts are overwritten by deserialization
When deserializing clients shared states always add to existing modelsIds and hosts.
1 parent a1c4e75 commit 7ebd9d8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/clients/gemini/GeminiClientSharedState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients.gemini
22

33
import com.github.blarc.ai.commits.intellij.plugin.settings.clients.LLMClientSharedState
44
import com.intellij.openapi.components.*
5-
import com.intellij.util.xmlb.XmlSerializerUtil
65
import com.intellij.util.xmlb.annotations.XCollection
76

87
@Service(Service.Level.APP)
@@ -26,6 +25,7 @@ class GeminiClientSharedState : PersistentStateComponent<GeminiClientSharedState
2625
override fun getState(): GeminiClientSharedState = this
2726

2827
override fun loadState(state: GeminiClientSharedState) {
29-
XmlSerializerUtil.copyBean(state, this)
28+
modelIds += state.modelIds
29+
hosts += state.hosts
3030
}
3131
}

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/clients/ollama/OllamaClientSharedState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients.ollama
22

33
import com.github.blarc.ai.commits.intellij.plugin.settings.clients.LLMClientSharedState
44
import com.intellij.openapi.components.*
5-
import com.intellij.util.xmlb.XmlSerializerUtil
65
import com.intellij.util.xmlb.annotations.XCollection
76

87
@Service(Service.Level.APP)
@@ -23,6 +22,7 @@ class OllamaClientSharedState : PersistentStateComponent<OllamaClientSharedState
2322
override fun getState(): OllamaClientSharedState = this
2423

2524
override fun loadState(state: OllamaClientSharedState) {
26-
XmlSerializerUtil.copyBean(state, this)
25+
modelIds += state.modelIds
26+
hosts += state.hosts
2727
}
2828
}

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/clients/qianfan/QianfanClientSharedState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients.qianfan
22

33
import com.github.blarc.ai.commits.intellij.plugin.settings.clients.LLMClientSharedState
44
import com.intellij.openapi.components.*
5-
import com.intellij.util.xmlb.XmlSerializerUtil
65
import com.intellij.util.xmlb.annotations.XCollection
76
import dev.langchain4j.model.qianfan.QianfanChatModelNameEnum
87

@@ -27,6 +26,7 @@ class QianfanClientSharedState : PersistentStateComponent<QianfanClientSharedSta
2726
override fun getState(): QianfanClientSharedState = this
2827

2928
override fun loadState(state: QianfanClientSharedState) {
30-
XmlSerializerUtil.copyBean(state, this)
29+
hosts += state.hosts
30+
modelIds += state.modelIds
3131
}
3232
}

0 commit comments

Comments
 (0)