Forge
csharpdeeb25a2
1#nullable enable
2using CascadeIDE.Features.AutonomousAgent;
3using CascadeIDE.Features.HybridIndex.Application;
4using CascadeIDE.Models;
5using CascadeIDE.Services;
6
7namespace CascadeIDE.Features.Settings.Application;
8
9/// <summary>
10/// Побочные эффекты реакций настроек главного окна: диск, MCP/autonomous, чат, HCI — вне длинных тел partial VM.
11/// </summary>
12internal static class ShellSettingsReactiveSideEffects
13{
14 public static void ApplyExternalMcpServersJson(
15 string normalizedJson,
16 CascadeIdeSettings settings,
17 Action cancelAutonomousForHostReconfiguration,
18 Func<McpClientService, AutonomousAgentService> createAutonomousAgentService,
19 Action<McpClientService> assignMcpClientService,
20 Action<AutonomousAgentService> assignAutonomousAgentService,
21 Action<AutonomousAgentService> replaceAutonomousAgentOnHost,
22 Action disposeCursorAcpSession,
23 Action saveSettingsIfChanged)
24 {
25 settings.Mcp.ExternalServersJson = normalizedJson;
26 cancelAutonomousForHostReconfiguration();
27 var mcp = new McpClientService(McpExternalServersJsonResolver.ResolveEffectiveJson(settings));
28 var autonomous = createAutonomousAgentService(mcp);
29 assignMcpClientService(mcp);
30 assignAutonomousAgentService(autonomous);
31 replaceAutonomousAgentOnHost(autonomous);
32 disposeCursorAcpSession();
33 saveSettingsIfChanged();
34 }
35
36 public static void ApplyAiModePersisted(
37 string normalizedMode,
38 CascadeIdeSettings settings,
39 Action notifyActiveAiProviderChanged,
40 Action saveSettingsIfChanged,
41 Action disposeCursorAcpSession,
42 Action refreshSendChatCommandState,
43 Action applyHybridCodebaseIndexOrchestration)
44 {
45 settings.Ai.Mode = normalizedMode;
46 notifyActiveAiProviderChanged();
47 saveSettingsIfChanged();
48 disposeCursorAcpSession();
49 refreshSendChatCommandState();
50 applyHybridCodebaseIndexOrchestration();
51 }
52
53 public static void ApplyCloudActiveProviderPersisted(
54 string normalizedProvider,
55 CascadeIdeSettings settings,
56 Action notifyActiveAiProviderChanged,
57 Action saveSettingsIfChanged,
58 Action disposeCursorAcpSession,
59 Action refreshSendChatCommandState)
60 {
61 settings.Ai.Cloud.ActiveProvider = normalizedProvider;
62 notifyActiveAiProviderChanged();
63 saveSettingsIfChanged();
64 disposeCursorAcpSession();
65 refreshSendChatCommandState();
66 }
67
68 public static void ApplyHybridIndexDirPersisted(
69 string normalizedDir,
70 CascadeIdeSettings settings,
71 HybridIndexOrchestrator hybridIndex,
72 Action applyHybridCodebaseIndexOrchestration,
73 Action saveSettingsIfChanged,
74 Action raiseHybridIndexPresentationProperties)
75 {
76 settings.HybridIndex.IndexDir = normalizedDir;
77 hybridIndex.SetIndexDirectoryRelative(HybridIndexIndexDirectoryRelative.ResolveOrDefault(settings.HybridIndex.IndexDir));
78 applyHybridCodebaseIndexOrchestration();
79 saveSettingsIfChanged();
80 raiseHybridIndexPresentationProperties();
81 }
82
83 public static void ApplyHybridIndexScopeModePersisted(
84 string normalizedScope,
85 CascadeIdeSettings settings,
86 Action applyHybridCodebaseIndexOrchestration,
87 Action saveSettingsIfChanged,
88 Action raiseHybridIndexPresentationProperties)
89 {
90 settings.HybridIndex.ScopeMode = normalizedScope;
91 applyHybridCodebaseIndexOrchestration();
92 saveSettingsIfChanged();
93 raiseHybridIndexPresentationProperties();
94 }
95}
96
View only · write via MCP/CIDE