Skip to content

Commit 13ce6b9

Browse files
authored
feat: adds mutagen daemon controller (#58)
fixes coder/internal#380 Adds MutagenController service, which manages the lifecycle of the `mutagen` daemon and exposes methods to query and modify sync sessions. Sync sessions themselves are a placeholder which will need to be filled out and plumbed thru to the actual API. This just handles daemon lifecycle for now.
1 parent 368f068 commit 13ce6b9

17 files changed

+1082
-56
lines changed

App/App.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@
6262
</PackageReference>
6363
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.2.0" />
6464
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.1" />
65+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
66+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.1" />
6567
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.250108002" />
6668
</ItemGroup>
6769

6870
<ItemGroup>
6971
<ProjectReference Include="..\CoderSdk\CoderSdk.csproj" />
72+
<ProjectReference Include="..\MutagenSdk\MutagenSdk.csproj" />
7073
<ProjectReference Include="..\Vpn.Proto\Vpn.Proto.csproj" />
7174
<ProjectReference Include="..\Vpn\Vpn.csproj" />
7275
</ItemGroup>

App/App.xaml.cs

+21-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
using Coder.Desktop.App.ViewModels;
77
using Coder.Desktop.App.Views;
88
using Coder.Desktop.App.Views.Pages;
9+
using Coder.Desktop.Vpn;
10+
using Microsoft.Extensions.Configuration;
911
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.Extensions.Hosting;
1013
using Microsoft.UI.Xaml;
14+
using Microsoft.Win32;
1115

1216
namespace Coder.Desktop.App;
1317

@@ -17,12 +21,28 @@ public partial class App : Application
1721

1822
private bool _handleWindowClosed = true;
1923

24+
#if !DEBUG
25+
private const string MutagenControllerConfigSection = "AppMutagenController";
26+
#else
27+
private const string MutagenControllerConfigSection = "DebugAppMutagenController";
28+
#endif
29+
2030
public App()
2131
{
22-
var services = new ServiceCollection();
32+
var builder = Host.CreateApplicationBuilder();
33+
34+
(builder.Configuration as IConfigurationBuilder).Add(
35+
new RegistryConfigurationSource(Registry.LocalMachine, @"SOFTWARE\Coder Desktop"));
36+
37+
var services = builder.Services;
38+
2339
services.AddSingleton<ICredentialManager, CredentialManager>();
2440
services.AddSingleton<IRpcController, RpcController>();
2541

42+
services.AddOptions<MutagenControllerConfig>()
43+
.Bind(builder.Configuration.GetSection(MutagenControllerConfigSection));
44+
services.AddSingleton<ISyncSessionController, MutagenController>();
45+
2646
// SignInWindow views and view models
2747
services.AddTransient<SignInViewModel>();
2848
services.AddTransient<SignInWindow>();

0 commit comments

Comments
 (0)