Files
ClaudeDo/src/ClaudeDo.Installer/Pages/PathsPage/PathsPageViewModel.cs
CubeGameLP 78831b2263 feat(installer): add WPF installer/configurator project
Standalone WPF app (ClaudeDo.Installer) that handles full installation
and ongoing configuration of ClaudeDo. Two modes: wizard for first run,
tabbed settings panel for subsequent launches. Page-based extensibility
via IInstallerPage interface — adding new config sections requires only
one new class.

Install pipeline: dotnet publish, deploy binaries, write configs, init
DB (via SchemaInitializer from ClaudeDo.Data), register Windows Service,
create shortcuts. Dark theme matching the Avalonia app (forest teal accent).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:01:03 +02:00

75 lines
2.5 KiB
C#

using System.Windows.Controls;
using ClaudeDo.Installer.Core;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ClaudeDo.Installer.Pages.PathsPage;
public partial class PathsPageViewModel : ObservableObject, IInstallerPage
{
private readonly InstallContext _context;
private PathsPageView? _view;
public string Title => "Paths";
public string Icon => "\uE8B7";
public int Order => 1;
public bool ShowInWizard => true;
public bool ShowInSettings => true;
public UserControl View => _view ??= new PathsPageView { DataContext = this };
[ObservableProperty] private string _dbPath = "~/.todo-app/todo.db";
[ObservableProperty] private string _logRoot = "~/.todo-app/logs";
[ObservableProperty] private string _sandboxRoot = "~/.todo-app/sandbox";
[ObservableProperty] private string _worktreeRootStrategy = "sibling";
[ObservableProperty] private string _centralWorktreeRoot = "~/.todo-app/worktrees";
[ObservableProperty] private string? _validationError;
public bool IsCentralVisible => WorktreeRootStrategy == "central";
public PathsPageViewModel(InstallContext context) => _context = context;
partial void OnWorktreeRootStrategyChanged(string value) =>
OnPropertyChanged(nameof(IsCentralVisible));
public Task LoadAsync()
{
var cfg = InstallerWorkerConfig.Load();
DbPath = cfg.DbPath;
LogRoot = cfg.LogRoot;
SandboxRoot = cfg.SandboxRoot;
WorktreeRootStrategy = cfg.WorktreeRootStrategy;
CentralWorktreeRoot = cfg.CentralWorktreeRoot;
return Task.CompletedTask;
}
public Task ApplyAsync()
{
_context.DbPath = DbPath;
_context.UiDbPath = DbPath;
_context.LogRoot = LogRoot;
_context.SandboxRoot = SandboxRoot;
_context.WorktreeRootStrategy = WorktreeRootStrategy;
_context.CentralWorktreeRoot = CentralWorktreeRoot;
return Task.CompletedTask;
}
public bool Validate()
{
if (string.IsNullOrWhiteSpace(DbPath) ||
string.IsNullOrWhiteSpace(LogRoot) ||
string.IsNullOrWhiteSpace(SandboxRoot))
{
ValidationError = "All path fields are required.";
return false;
}
if (WorktreeRootStrategy == "central" && string.IsNullOrWhiteSpace(CentralWorktreeRoot))
{
ValidationError = "Central worktree root is required when using central strategy.";
return false;
}
ValidationError = null;
return true;
}
}