Forge
csharpdeeb25a2
1using CascadeIDE.Features.Settings.Application;
2using CascadeIDE.Features.Shell.Application;
3using CascadeIDE.Features.HybridIndex.Application;
4using CascadeIDE.Models;
5
6namespace CascadeIDE.ViewModels;
7
8/// <summary>Реакции на изменение полей настроек и ключей API: диск, автономный агент, панели.</summary>
9public partial class MainWindowViewModel
10{
11 partial void OnMarkdownKrokiEnabledChanged(bool value)
12 {
13 _settings.Markdown.Diagrams.Kroki = value;
14 SaveSettingsIfChanged();
15 }
16
17 partial void OnMarkdownKrokiBaseUrlChanged(string value)
18 {
19 _settings.Markdown.Diagrams.KrokiUrl = ShellSettingsPresentationProjection.NormalizeKrokiBaseUrl(value);
20 SaveSettingsIfChanged();
21 }
22
23 partial void OnExternalMcpServersJsonChanged(string value) =>
24 ShellSettingsReactiveSideEffects.ApplyExternalMcpServersJson(
25 ShellSettingsPresentationProjection.NormalizeExternalMcpServersJson(value),
26 _settings,
27 Autonomous.CancelForHostReconfiguration,
28 CreateAutonomousAgentService,
29 m => _mcpClientService = m,
30 a => _autonomousAgentService = a,
31 Autonomous.ReplaceAgentService,
32 ChatPanel.DisposeCursorAcpSession,
33 SaveSettingsIfChanged);
34
35 partial void OnAcpAutoInjectIdeMcpChanged(bool value)
36 {
37 _settings.Mcp.AcpAutoInjectIdeMcp = value;
38 ChatPanel.DisposeCursorAcpSession();
39 SaveSettingsIfChanged();
40 }
41
42 partial void OnShowThinkingInHistoryChanged(bool value)
43 {
44 _settings.Ai.Chat.ShowThinkingInHistory = value;
45 SaveSettingsIfChanged();
46 }
47
48 partial void OnAiModeChanged(string value)
49 {
50 var n = ShellSettingsPresentationProjection.NormalizeAiMode(value);
51 if (ShellSettingsPresentationProjection.ShouldRewriteWithNormalizedValue(value, n))
52 {
53 AiMode = n;
54 return;
55 }
56
57 ShellSettingsReactiveSideEffects.ApplyAiModePersisted(
58 n,
59 _settings,
60 () => OnPropertyChanged(nameof(ActiveAiProvider)),
61 SaveSettingsIfChanged,
62 ChatPanel.DisposeCursorAcpSession,
63 ChatPanel.RefreshSendChatCommandState,
64 () => ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false));
65 }
66
67 partial void OnCloudActiveProviderChanged(string value)
68 {
69 var n = ShellSettingsPresentationProjection.NormalizeCloudProvider(value);
70 if (ShellSettingsPresentationProjection.ShouldRewriteWithNormalizedValue(value, n))
71 {
72 CloudActiveProvider = n;
73 return;
74 }
75
76 ShellSettingsReactiveSideEffects.ApplyCloudActiveProviderPersisted(
77 n,
78 _settings,
79 () => OnPropertyChanged(nameof(ActiveAiProvider)),
80 SaveSettingsIfChanged,
81 ChatPanel.DisposeCursorAcpSession,
82 ChatPanel.RefreshSendChatCommandState);
83 }
84
85 partial void OnAnthropicApiKeyChanged(string value)
86 {
87 _aiKeys.AnthropicApiKey = ShellSettingsPresentationProjection.NormalizeOptionalSecret(value);
88 SaveAiKeysIfChanged();
89 }
90
91 partial void OnOpenAiApiKeyChanged(string value)
92 {
93 _aiKeys.OpenAiApiKey = ShellSettingsPresentationProjection.NormalizeOptionalSecret(value);
94 SaveAiKeysIfChanged();
95 }
96
97 partial void OnDeepSeekApiKeyChanged(string value)
98 {
99 _aiKeys.DeepSeekApiKey = ShellSettingsPresentationProjection.NormalizeOptionalSecret(value);
100 SaveAiKeysIfChanged();
101 }
102
103 partial void OnSendMessageKeyChanged(string value)
104 {
105 _appData.Put("SendMessageKey", value);
106 NormalizeChatEnterChordPair();
107 }
108
109 partial void OnComposerNewLineKeyChanged(string value)
110 {
111 _appData.Put("ComposerNewLineKey", value);
112 NormalizeChatEnterChordPair();
113 }
114
115 partial void OnWorkspaceSplittersLockedChanged(bool value)
116 {
117 _settings.Workspace.SplittersLocked = value;
118 if (_lastSavedSettings is not null)
119 SaveSettingsIfChanged();
120 }
121
122 partial void OnHciIntegrationEnabledChanged(bool value)
123 {
124 _settings.HybridIndex.Enabled = value;
125 ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false);
126 SaveSettingsIfChanged();
127 }
128
129 partial void OnHciIndexDirChanged(string value)
130 {
131 var normalized = ShellSettingsPresentationProjection.NormalizeHybridIndexDir(value);
132 if (ShellSettingsPresentationProjection.ShouldRewriteWithNormalizedValue(value, normalized))
133 {
134 HciIndexDir = normalized;
135 return;
136 }
137
138 ShellSettingsReactiveSideEffects.ApplyHybridIndexDirPersisted(
139 normalized,
140 _settings,
141 _hybridIndex,
142 () => ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false),
143 SaveSettingsIfChanged,
144 RaiseHybridIndexPresentationProperties);
145 }
146
147 partial void OnHciDebounceMsChanged(int value)
148 {
149 var v = Math.Clamp(value, 0, 60_000);
150 if (v != value)
151 {
152 HciDebounceMs = v;
153 return;
154 }
155
156 _settings.HybridIndex.DebounceMs = v;
157 ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false);
158 SaveSettingsIfChanged();
159 }
160
161 partial void OnHciAutoReindexOnSolutionOpenChanged(bool value)
162 {
163 _settings.HybridIndex.AutoReindexOnSolutionOpen = value;
164 SaveSettingsIfChanged();
165 }
166
167 partial void OnHciWatchFilesChanged(bool value)
168 {
169 _settings.HybridIndex.WatchFiles = value;
170 ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false);
171 SaveSettingsIfChanged();
172 }
173
174 partial void OnHciScopeModeChanged(string value)
175 {
176 var n = ShellSettingsPresentationProjection.NormalizeHybridIndexScopeMode(value);
177 if (ShellSettingsPresentationProjection.ShouldRewriteWithNormalizedValue(value, n))
178 {
179 HciScopeMode = n;
180 return;
181 }
182
183 ShellSettingsReactiveSideEffects.ApplyHybridIndexScopeModePersisted(
184 n,
185 _settings,
186 () => ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false),
187 SaveSettingsIfChanged,
188 RaiseHybridIndexPresentationProperties);
189 }
190
191 partial void OnHciPauseWhenMcpStdioHostChanged(bool value)
192 {
193 _settings.HybridIndex.PauseWhenMcpStdioHost = value;
194 ApplyHybridCodebaseIndexOrchestrationForCurrentSolution(pokeWhenAutoReindex: false);
195 SaveSettingsIfChanged();
196 }
197
198 partial void OnIntercomTransportEnabledChanged(bool value)
199 {
200 _settings.Intercom.Transport.Enabled = value;
201 SaveSettingsIfChanged();
202 _ = ChatPanel.StartIntercomTransportAsync();
203 }
204
205 partial void OnIntercomTransportBaseUrlChanged(string value)
206 {
207 _settings.Intercom.Transport.BaseUrl = value?.Trim() ?? "";
208 SaveSettingsIfChanged();
209 }
210
211 partial void OnIntercomTransportLocalServerPathChanged(string value)
212 {
213 _settings.Intercom.Transport.LocalServerPath = value?.Trim() ?? "";
214 SaveSettingsIfChanged();
215 }
216
217 partial void OnIntercomTransportTeamIdChanged(string value)
218 {
219 _settings.Intercom.Transport.TeamId = value?.Trim() ?? "";
220 SaveSettingsIfChanged();
221 }
222
223 partial void OnIntercomTransportDefaultTopicIdChanged(string value)
224 {
225 _settings.Intercom.Transport.DefaultTopicId = value?.Trim() ?? "";
226 SaveSettingsIfChanged();
227 }
228
229 partial void OnIntercomTransportOAuthProviderChanged(string value)
230 {
231 _settings.Intercom.Transport.OAuthProvider = string.IsNullOrWhiteSpace(value) ? "github" : value.Trim();
232 SaveSettingsIfChanged();
233 }
234
235 partial void OnIntercomTransportDevTeamTokenChanged(string value)
236 {
237 _settings.Intercom.Transport.DevTeamToken = value?.Trim() ?? "";
238 SaveSettingsIfChanged();
239 }
240
241 partial void OnIntercomTransportSseReconnectBackoffMsChanged(int value)
242 {
243 var v = Math.Clamp(value, 500, 60_000);
244 if (v != value)
245 {
246 IntercomTransportSseReconnectBackoffMs = v;
247 return;
248 }
249
250 _settings.Intercom.Transport.SseReconnectBackoffMs = v;
251 SaveSettingsIfChanged();
252 }
253
254 partial void OnIntercomTransportAutoConnectOnSendChanged(bool value)
255 {
256 _settings.Intercom.Transport.AutoConnectOnSend = value;
257 SaveSettingsIfChanged();
258 }
259
260 partial void OnIntercomTransportSyncAgentChannelMessagesChanged(bool value)
261 {
262 _settings.Intercom.Transport.SyncAgentChannelMessages = value;
263 SaveSettingsIfChanged();
264 }
265}
266
View only · write via MCP/CIDE