@@ -20,6 +20,7 @@ import java.util.*
20
20
// Most of the settings are global, but we use project configurable to set isProjectSpecificLLMClient property
21
21
class AppSettingsConfigurable (val project : Project , cs : CoroutineScope ) : BoundConfigurable(message("settings.general.group.title")) {
22
22
23
+ private val projectSettings = project.service<ProjectSettings >()
23
24
private val llmClientTable = LLMClientTable ()
24
25
private lateinit var llmClientConfigurationComboBox: ComboBox <LLMClientConfiguration >
25
26
private var isProjectSpecificLLMClientCheckBox = JBCheckBox (message(" settings.llmClient.projectSpecific" ))
@@ -34,7 +35,7 @@ class AppSettingsConfigurable(val project: Project, cs: CoroutineScope) : BoundC
34
35
row {
35
36
label(message(" settings.llmClient" )).widthGroup(" labelPrompt" )
36
37
llmClientConfigurationComboBox = comboBox(AppSettings2 .instance.llmClientConfigurations, AICommitsListCellRenderer ())
37
- .bindItem(getter = { getActiveLLMClientConfiguration() }, setter = { setActiveLLMClientConfiguration(it) })
38
+ .bindItem(getter = { projectSettings. getActiveLLMClientConfiguration() }, setter = { setActiveLLMClientConfiguration(it) })
38
39
.widthGroup(" input" )
39
40
.component
40
41
cell(isProjectSpecificLLMClientCheckBox)
@@ -79,15 +80,15 @@ class AppSettingsConfigurable(val project: Project, cs: CoroutineScope) : BoundC
79
80
AICommitsListCellRenderer ()
80
81
)
81
82
.widthGroup(" input" )
82
- .bindItem(getter = { getActiveLocale() }, setter = { setActiveLocale(it)} )
83
+ .bindItem(getter = { projectSettings.locale }, setter = { setActiveLocale(it)} )
83
84
84
85
browserLink(message(" settings.more-prompts" ), AICommitsBundle .URL_PROMPTS_DISCUSSION .toString())
85
86
.align(AlignX .RIGHT )
86
87
}
87
88
row {
88
89
label(message(" settings.prompt" )).widthGroup(" labelPrompt" )
89
90
promptComboBox = comboBox(AppSettings2 .instance.prompts.values, AICommitsListCellRenderer ())
90
- .bindItem(getter = { getActivePrompt() }, { setActivePrompt(it) })
91
+ .bindItem(getter = { projectSettings.activePrompt }, { setActivePrompt(it) })
91
92
.widthGroup(" input" )
92
93
.component
93
94
cell(isProjectSpecificPromptCheckBox)
@@ -137,14 +138,6 @@ class AppSettingsConfigurable(val project: Project, cs: CoroutineScope) : BoundC
137
138
}
138
139
}
139
140
140
- private fun getActiveLLMClientConfiguration (): LLMClientConfiguration ? {
141
- return if (isProjectSpecificLLMClientCheckBox.isSelected) {
142
- project.service<ProjectSettings >().getActiveLLMClientConfiguration()
143
- } else {
144
- AppSettings2 .instance.getActiveLLMClientConfiguration()
145
- }
146
- }
147
-
148
141
private fun setActiveLLMClientConfiguration (llmClientConfiguration : LLMClientConfiguration ? ) {
149
142
llmClientConfiguration?.let {
150
143
if (isProjectSpecificLLMClientCheckBox.isSelected) {
@@ -155,38 +148,22 @@ class AppSettingsConfigurable(val project: Project, cs: CoroutineScope) : BoundC
155
148
}
156
149
}
157
150
158
- private fun getActivePrompt (): Prompt ? {
159
- return if (isProjectSpecificPromptCheckBox.isSelected) {
160
- project.service<ProjectSettings >().activePrompt
161
- } else {
162
- AppSettings2 .instance.activePrompt
163
- }
164
- }
165
-
166
151
private fun setActivePrompt (prompt : Prompt ? ) {
167
152
prompt?.let {
168
153
if (isProjectSpecificPromptCheckBox.isSelected) {
169
- project.service<ProjectSettings >().activePrompt = prompt
154
+ project.service<ProjectSettings >().activePrompt = it
170
155
} else {
171
- AppSettings2 .instance.activePrompt = prompt
156
+ AppSettings2 .instance.activePrompt = it
172
157
}
173
158
}
174
159
}
175
160
176
- private fun getActiveLocale (): Locale {
177
- return if (isProjectSpecificPromptCheckBox.isSelected) {
178
- project.service<ProjectSettings >().locale
179
- } else {
180
- AppSettings2 .instance.locale
181
- }
182
- }
183
-
184
161
private fun setActiveLocale (locale : Locale ? ) {
185
162
locale?.let {
186
163
if (isProjectSpecificPromptCheckBox.isSelected) {
187
- project.service<ProjectSettings >().locale = locale
164
+ project.service<ProjectSettings >().locale = it
188
165
} else {
189
- AppSettings2 .instance.locale = locale
166
+ AppSettings2 .instance.locale = it
190
167
}
191
168
}
192
169
}
0 commit comments