feat(installer): add Diagnose section to SettingsWindow

Re-runs the environment checks against the installed configuration
(worker.config.json + detected install dir) without blocking navigation
and without auto-running on window open, only on a "Recheck" click.

Extracted the check-row rendering and check-run logic (busy state,
summary, Recheck command) out of SystemCheckPage into a shared
Checks/CheckListViewModel + Checks/CheckListView, composed by both
SystemCheckPage (wizard) and the new DiagnosePage (settings) instead
of duplicating it.
This commit is contained in:
mika kuns
2026-08-06 08:22:45 +02:00
parent b3a8373c70
commit 7e1b1177de
15 changed files with 529 additions and 205 deletions
+5
View File
@@ -11,6 +11,7 @@ using ClaudeDo.Installer.Core.Interfaces;
using ClaudeDo.Installer.Localization;
using ClaudeDo.Localization;
using ClaudeDo.Releases;
using ClaudeDo.Installer.Pages.DiagnosePage;
using ClaudeDo.Installer.Pages.InstallPage;
using ClaudeDo.Installer.Pages.PathsPage;
using ClaudeDo.Installer.Pages.ServicePage;
@@ -153,6 +154,10 @@ public partial class App : Application
sc.AddSingleton<IInstallerPage, ServicePageViewModel>();
sc.AddSingleton<IInstallerPage, UiSettingsPageViewModel>();
sc.AddSingleton<IInstallerPage, InstallPageViewModel>();
sc.AddSingleton<IInstallerPage>(sp => new DiagnosePageViewModel(
sp.GetRequiredService<InstallContext>(),
sp.GetRequiredService<Func<EnvironmentCheckService>>(),
InstallerWorkerConfig.Load));
// Steps — execution order matters for the FreshInstall pipeline (IEnumerable<IInstallStep>).
// Double-registered as both IInstallStep and concrete type so the Update pipeline
+15 -4
View File
@@ -161,6 +161,10 @@ regardless of severity (an indeterminate result — e.g. the CLI not found, so v
can't be checked — must not strand the user; the underlying `Error`-severity check for the CLI
itself, `ClaudeCliCheck`, is what blocks in that case).
The check-row rendering and the check-run logic (busy state, summary text, Recheck command) live
in one place — `Checks/CheckListViewModel.cs` + `Checks/CheckListView.xaml` — composed by every
page that hosts a check list, not duplicated per page.
`SystemCheckPage` (`Pages/SystemCheckPage/`) hosts the check list in the **FreshInstall** wizard
only, registered via `PageResolver` at `Order = 1` (directly after `WelcomePage`); `WizardViewModel`
filters it back out in `Update` mode along with Paths/Service/UiSettings. Checks run automatically
@@ -169,8 +173,15 @@ on page entry (`LoadAsync`, guarded against double-entry). "Next" is disabled vi
subscribes to `PropertyChanged` on the current page so a live recheck can flip it back. A "Recheck"
button re-runs `EnvironmentCheckService.RunAllAsync` (disabled while already running).
`DiagnosePage` (`Pages/DiagnosePage/`) hosts the same `CheckListView` in `SettingsWindow` (Config
mode only, `ShowInSettings = true` / `ShowInWizard = false`, `Order = 5` — after UiSettings).
Nothing here blocks navigation and checks do **not** auto-run on load — only on a "Recheck" click.
Unlike the wizard, its `InstallContext` is built from the **installed** configuration
(`InstallerWorkerConfig.Load()` for `ClaudeBin`/`SignalRPort`, the shared `InstallContext` for
`InstallDirectory`/`ExternalMcpPort`), refreshed on every `LoadAsync()` — not the wizard-default
`InstallContext` the DI container hands out, which is only populated once a page's `ApplyAsync`
(i.e. Save) runs.
**Not implemented (see merge-status note above):** a "Claude Help Me" button that launches an
external terminal with a live `claude` session for setup troubleshooting, and a Diagnose section
in `SettingsWindow` (Config mode) that re-runs the same checks against the installed configuration.
Both were speced as follow-up tasks; both blocked before writing any code because their prerequisite
(this section) wasn't on `main` yet.
external terminal with a live `claude` session for setup troubleshooting. Its footer slot is
reserved in `CheckListView.xaml`; still blocked on the same follow-up as before.
@@ -0,0 +1,91 @@
<UserControl x:Class="ClaudeDo.Installer.Checks.CheckListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClaudeDo.Installer.Checks"
xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization"
d:DataContext="{d:DesignInstance local:CheckListViewModel}"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Check list -->
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Rows}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:CheckRowViewModel}">
<Border Margin="0,0,0,6" Padding="10,8"
Background="{StaticResource IslandBgBrush}"
BorderBrush="{StaticResource BorderSubtleBrush}"
BorderThickness="1" CornerRadius="4">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="0" Width="10" Height="10" Margin="0,0,10,0"
VerticalAlignment="Top"
Fill="{Binding StatusBrush}"/>
<StackPanel Grid.Column="1">
<TextBlock Text="{Binding Title}" FontSize="13" FontWeight="SemiBold"/>
<TextBlock Text="{Binding Message}" FontSize="12"
Foreground="{StaticResource TextSecondaryBrush}"
TextWrapping="Wrap" Margin="0,2,0,0"/>
<TextBlock Text="{Binding Hint}" FontSize="11"
Foreground="{StaticResource TextMutedBrush}"
TextWrapping="Wrap" Margin="0,4,0,0"
Visibility="{Binding Hint, Converter={StaticResource NullToCollapsedConverter}}"/>
<Button Content="{Binding HelpUrl}"
HorizontalAlignment="Left" Margin="-16,4,0,0"
Background="Transparent" BorderThickness="0"
Foreground="{StaticResource AccentLightBrush}"
Cursor="Hand"
Command="{Binding DataContext.OpenHelpUrlCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding HelpUrl}"
Visibility="{Binding HelpUrl, Converter={StaticResource NullToCollapsedConverter}}"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!-- Progress + summary -->
<StackPanel Grid.Row="1" Margin="0,8,0,0">
<ProgressBar IsIndeterminate="True" Margin="0,0,0,8"
Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Text="{Binding Summary}" FontSize="12" TextWrapping="Wrap"
Foreground="{StaticResource TextSecondaryBrush}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding HasBlockingError}" Value="True">
<Setter Property="Foreground" Value="{StaticResource ErrorBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<!-- Footer -->
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
<!-- Reserved space: a "Claude Help Me" button lands here in a follow-up task. -->
<Button Content="{loc:Tr installer.systemCheck.recheck}"
Command="{Binding RunChecksCommand}"/>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,8 @@
using System.Windows.Controls;
namespace ClaudeDo.Installer.Checks;
public partial class CheckListView : UserControl
{
public CheckListView() => InitializeComponent();
}
@@ -0,0 +1,133 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Localization;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace ClaudeDo.Installer.Checks;
public sealed class CheckRowViewModel
{
public CheckRowViewModel(CheckResult result)
{
var loc = TrExtension.Localizer;
Status = result.Status;
Severity = result.Severity;
Title = loc?[result.TitleKey] ?? result.TitleKey;
Message = result.Message;
Hint = result.HintKey is not null ? loc?[result.HintKey] ?? result.HintKey : null;
HelpUrl = result.HelpUrl;
StatusBrush = ResolveBrush(Status, Severity);
}
public CheckStatus Status { get; }
public CheckSeverity Severity { get; }
public string Title { get; }
public string Message { get; }
public string? Hint { get; }
public string? HelpUrl { get; }
public Brush StatusBrush { get; }
private static Brush ResolveBrush(CheckStatus status, CheckSeverity severity)
{
var key = status switch
{
CheckStatus.Ok => "StatusGreenBrush",
CheckStatus.Unknown => "StatusGrayBrush",
CheckStatus.Failed when severity == CheckSeverity.Error => "StatusRedBrush",
CheckStatus.Failed => "StatusOrangeBrush",
_ => "StatusGrayBrush",
};
return Application.Current?.Resources[key] as Brush ?? Brushes.Gray;
}
}
/// <summary>
/// Shared presentation logic for the environment check list: running the check pass, tracking
/// busy/summary state, and the row collection. Composed (not subclassed) by every page that
/// hosts a check list — <see cref="Pages.SystemCheckPage.SystemCheckPageViewModel"/> and
/// <see cref="Pages.DiagnosePage.DiagnosePageViewModel"/> — so the run logic exists exactly once.
/// </summary>
public partial class CheckListViewModel : ObservableObject
{
private readonly InstallContext _context;
private readonly Func<EnvironmentCheckService> _checkServiceFactory;
public ObservableCollection<CheckRowViewModel> Rows { get; } = [];
[ObservableProperty] private bool _isRunning;
[ObservableProperty] private bool _hasRun;
[ObservableProperty] private bool _hasBlockingError;
[ObservableProperty] private string _summary = string.Empty;
public CheckListViewModel(InstallContext context, Func<EnvironmentCheckService> checkServiceFactory)
{
_context = context;
_checkServiceFactory = checkServiceFactory;
}
partial void OnIsRunningChanged(bool value) => RunChecksCommand.NotifyCanExecuteChanged();
[RelayCommand(CanExecute = nameof(CanRunChecks))]
private async Task RunChecksAsync()
{
if (IsRunning) return;
IsRunning = true;
Summary = TrExtension.Localizer?["installer.systemCheck.summary.running"] ?? "Checking your system…";
try
{
var service = _checkServiceFactory();
var report = await service.RunAllAsync(_context, CancellationToken.None);
Rows.Clear();
foreach (var result in report.Results)
Rows.Add(new CheckRowViewModel(result));
HasBlockingError = report.HasBlockingError;
Summary = BuildSummary(report);
HasRun = true;
}
finally
{
IsRunning = false;
}
}
private bool CanRunChecks() => !IsRunning;
private static string BuildSummary(EnvironmentCheckReport report)
{
var loc = TrExtension.Localizer;
var blocking = report.Results
.Where(r => r.Severity == CheckSeverity.Error && r.Status == CheckStatus.Failed)
.ToList();
if (blocking.Count > 0)
{
var names = string.Join(", ", blocking.Select(r => loc?[r.TitleKey] ?? r.TitleKey));
return loc?.Get("installer.systemCheck.summary.blocking", blocking.Count, names)
?? $"{blocking.Count} problem(s) must be fixed: {names}";
}
var warnings = report.Results.Count(r => r.Severity == CheckSeverity.Warning && r.Status == CheckStatus.Failed);
if (warnings > 0)
{
return loc?.Get("installer.systemCheck.summary.warnings", warnings)
?? $"{warnings} warning(s) found.";
}
return loc?["installer.systemCheck.summary.ok"] ?? "Everything looks good.";
}
[RelayCommand]
private static void OpenHelpUrl(string? url)
{
if (string.IsNullOrEmpty(url)) return;
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
}
@@ -0,0 +1,27 @@
<UserControl x:Class="ClaudeDo.Installer.Pages.DiagnosePage.DiagnosePageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClaudeDo.Installer.Pages.DiagnosePage"
xmlns:checks="clr-namespace:ClaudeDo.Installer.Checks"
xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization"
d:DataContext="{d:DesignInstance local:DiagnosePageViewModel}"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Header -->
<StackPanel Grid.Row="0" Margin="0,0,0,16">
<TextBlock Text="{loc:Tr installer.diagnose.title}" FontSize="18" FontWeight="SemiBold" Margin="0,0,0,4"/>
<TextBlock Text="{loc:Tr installer.diagnose.subtitle}"
Foreground="{StaticResource TextSecondaryBrush}" TextWrapping="Wrap"/>
</StackPanel>
<checks:CheckListView Grid.Row="1" DataContext="{Binding Checks}"/>
</Grid>
</UserControl>
@@ -0,0 +1,8 @@
using System.Windows.Controls;
namespace ClaudeDo.Installer.Pages.DiagnosePage;
public partial class DiagnosePageView : UserControl
{
public DiagnosePageView() => InitializeComponent();
}
@@ -0,0 +1,50 @@
using System.Windows.Controls;
using ClaudeDo.Installer.Checks;
using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Localization;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ClaudeDo.Installer.Pages.DiagnosePage;
/// <summary>
/// Re-runs the same environment checks as the wizard's SystemCheckPage, but against the
/// installed configuration (worker.config.json + the detected install directory) instead of
/// wizard defaults, and nothing here blocks navigation or auto-runs on load.
/// </summary>
public partial class DiagnosePageViewModel : ObservableObject, IInstallerPage
{
private readonly InstallContext _sharedContext;
private readonly Func<InstallerWorkerConfig> _loadWorkerConfig;
private readonly InstallContext _installedContext = new();
private DiagnosePageView? _view;
public string Title => TrExtension.Localizer?["installer.diagnose.title"] ?? "Diagnose";
public string Icon => "";
public int Order => 5;
public bool ShowInWizard => false;
public bool ShowInSettings => true;
public UserControl View => _view ??= new DiagnosePageView { DataContext = this };
public CheckListViewModel Checks { get; }
public DiagnosePageViewModel(InstallContext sharedContext, Func<EnvironmentCheckService> checkServiceFactory, Func<InstallerWorkerConfig> loadWorkerConfig)
{
_sharedContext = sharedContext;
_loadWorkerConfig = loadWorkerConfig;
Checks = new CheckListViewModel(_installedContext, checkServiceFactory);
}
public Task LoadAsync()
{
var cfg = _loadWorkerConfig();
_installedContext.InstallDirectory = _sharedContext.InstallDirectory;
_installedContext.ClaudeBin = cfg.ClaudeBin;
_installedContext.SignalRPort = cfg.SignalRPort;
_installedContext.ExternalMcpPort = _sharedContext.ExternalMcpPort;
return Task.CompletedTask;
}
public Task ApplyAsync() => Task.CompletedTask;
public bool Validate() => true;
}
@@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClaudeDo.Installer.Pages.SystemCheckPage"
xmlns:checks="clr-namespace:ClaudeDo.Installer.Checks"
xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization"
d:DataContext="{d:DesignInstance local:SystemCheckPageViewModel}"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -12,8 +13,6 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
@@ -23,77 +22,6 @@
Foreground="{StaticResource TextSecondaryBrush}" TextWrapping="Wrap"/>
</StackPanel>
<!-- Check list -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Rows}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:CheckRowViewModel}">
<Border Margin="0,0,0,6" Padding="10,8"
Background="{StaticResource IslandBgBrush}"
BorderBrush="{StaticResource BorderSubtleBrush}"
BorderThickness="1" CornerRadius="4">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="0" Width="10" Height="10" Margin="0,0,10,0"
VerticalAlignment="Top"
Fill="{Binding StatusBrush}"/>
<StackPanel Grid.Column="1">
<TextBlock Text="{Binding Title}" FontSize="13" FontWeight="SemiBold"/>
<TextBlock Text="{Binding Message}" FontSize="12"
Foreground="{StaticResource TextSecondaryBrush}"
TextWrapping="Wrap" Margin="0,2,0,0"/>
<TextBlock Text="{Binding Hint}" FontSize="11"
Foreground="{StaticResource TextMutedBrush}"
TextWrapping="Wrap" Margin="0,4,0,0"
Visibility="{Binding Hint, Converter={StaticResource NullToCollapsedConverter}}"/>
<Button Content="{Binding HelpUrl}"
HorizontalAlignment="Left" Margin="-16,4,0,0"
Background="Transparent" BorderThickness="0"
Foreground="{StaticResource AccentLightBrush}"
Cursor="Hand"
Command="{Binding DataContext.OpenHelpUrlCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding HelpUrl}"
Visibility="{Binding HelpUrl, Converter={StaticResource NullToCollapsedConverter}}"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!-- Progress + summary -->
<StackPanel Grid.Row="2" Margin="0,8,0,0">
<ProgressBar IsIndeterminate="True" Margin="0,0,0,8"
Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisConverter}}"/>
<TextBlock Text="{Binding Summary}" FontSize="12" TextWrapping="Wrap"
Foreground="{StaticResource TextSecondaryBrush}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding HasBlockingError}" Value="True">
<Setter Property="Foreground" Value="{StaticResource ErrorBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<!-- Footer -->
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
<!-- Reserved space: a "Claude Help Me" button lands here in a follow-up task. -->
<Button Content="{loc:Tr installer.systemCheck.recheck}"
Command="{Binding RunChecksCommand}"/>
</StackPanel>
<checks:CheckListView Grid.Row="1" DataContext="{Binding Checks}"/>
</Grid>
</UserControl>
@@ -1,8 +1,5 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ClaudeDo.Installer.Checks;
using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Localization;
@@ -11,85 +8,45 @@ using CommunityToolkit.Mvvm.Input;
namespace ClaudeDo.Installer.Pages.SystemCheckPage;
public sealed class CheckRowViewModel
{
public CheckRowViewModel(CheckResult result)
{
var loc = TrExtension.Localizer;
Status = result.Status;
Severity = result.Severity;
Title = loc?[result.TitleKey] ?? result.TitleKey;
Message = result.Message;
Hint = result.HintKey is not null ? loc?[result.HintKey] ?? result.HintKey : null;
HelpUrl = result.HelpUrl;
StatusBrush = ResolveBrush(Status, Severity);
}
public CheckStatus Status { get; }
public CheckSeverity Severity { get; }
public string Title { get; }
public string Message { get; }
public string? Hint { get; }
public string? HelpUrl { get; }
public Brush StatusBrush { get; }
private static Brush ResolveBrush(CheckStatus status, CheckSeverity severity)
{
var key = status switch
{
CheckStatus.Ok => "StatusGreenBrush",
CheckStatus.Unknown => "StatusGrayBrush",
CheckStatus.Failed when severity == CheckSeverity.Error => "StatusRedBrush",
CheckStatus.Failed => "StatusOrangeBrush",
_ => "StatusGrayBrush",
};
return Application.Current?.Resources[key] as Brush ?? Brushes.Gray;
}
}
public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
{
private readonly InstallContext _context;
private readonly Func<EnvironmentCheckService> _checkServiceFactory;
private SystemCheckPageView? _view;
private bool _hasStarted;
public string Title => TrExtension.Localizer?["installer.systemCheck.title"] ?? "System Check";
public string Icon => "";
public string Icon => "";
public int Order => 1;
public bool ShowInWizard => true;
public bool ShowInSettings => false;
public UserControl View => _view ??= new SystemCheckPageView { DataContext = this };
public ObservableCollection<CheckRowViewModel> Rows { get; } = [];
public CheckListViewModel Checks { get; }
[ObservableProperty] private bool _isRunning;
[ObservableProperty] private bool _hasRun;
[ObservableProperty] private bool _hasBlockingError;
[ObservableProperty] private string _summary = string.Empty;
// Pass-through to the shared check-run logic — kept so this page's UI/tests can bind
// directly on it, matching the pre-extraction API.
public ObservableCollection<CheckRowViewModel> Rows => Checks.Rows;
public bool IsRunning => Checks.IsRunning;
public bool HasRun => Checks.HasRun;
public bool HasBlockingError => Checks.HasBlockingError;
public string Summary => Checks.Summary;
public IAsyncRelayCommand RunChecksCommand => Checks.RunChecksCommand;
public bool BlocksNavigation => IsRunning || HasBlockingError;
public bool BlocksNavigation => Checks.IsRunning || Checks.HasBlockingError;
public SystemCheckPageViewModel(InstallContext context, Func<EnvironmentCheckService> checkServiceFactory)
{
_context = context;
_checkServiceFactory = checkServiceFactory;
Checks = new CheckListViewModel(context, checkServiceFactory);
// The wizard listens for PropertyChanged on this page to re-evaluate "Next" — bubble
// any change from the composed check list up so a live recheck can flip it back.
Checks.PropertyChanged += (_, _) => OnPropertyChanged(nameof(BlocksNavigation));
}
partial void OnIsRunningChanged(bool value)
{
OnPropertyChanged(nameof(BlocksNavigation));
RunChecksCommand.NotifyCanExecuteChanged();
}
partial void OnHasBlockingErrorChanged(bool value) => OnPropertyChanged(nameof(BlocksNavigation));
public Task LoadAsync()
{
if (!_hasStarted)
{
_hasStarted = true;
_ = RunChecksAsync();
_ = Checks.RunChecksCommand.ExecuteAsync(null);
}
return Task.CompletedTask;
}
@@ -97,64 +54,4 @@ public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
public Task ApplyAsync() => Task.CompletedTask;
public bool Validate() => !HasBlockingError;
[RelayCommand(CanExecute = nameof(CanRunChecks))]
private async Task RunChecksAsync()
{
if (IsRunning) return;
IsRunning = true;
Summary = TrExtension.Localizer?["installer.systemCheck.summary.running"] ?? "Checking your system…";
try
{
var service = _checkServiceFactory();
var report = await service.RunAllAsync(_context, CancellationToken.None);
Rows.Clear();
foreach (var result in report.Results)
Rows.Add(new CheckRowViewModel(result));
HasBlockingError = report.HasBlockingError;
Summary = BuildSummary(report);
HasRun = true;
}
finally
{
IsRunning = false;
}
}
private bool CanRunChecks() => !IsRunning;
private static string BuildSummary(EnvironmentCheckReport report)
{
var loc = TrExtension.Localizer;
var blocking = report.Results
.Where(r => r.Severity == CheckSeverity.Error && r.Status == CheckStatus.Failed)
.ToList();
if (blocking.Count > 0)
{
var names = string.Join(", ", blocking.Select(r => loc?[r.TitleKey] ?? r.TitleKey));
return loc?.Get("installer.systemCheck.summary.blocking", blocking.Count, names)
?? $"{blocking.Count} problem(s) must be fixed: {names}";
}
var warnings = report.Results.Count(r => r.Severity == CheckSeverity.Warning && r.Status == CheckStatus.Failed);
if (warnings > 0)
{
return loc?.Get("installer.systemCheck.summary.warnings", warnings)
?? $"{warnings} warning(s) found.";
}
return loc?["installer.systemCheck.summary.ok"] ?? "Everything looks good.";
}
[RelayCommand]
private static void OpenHelpUrl(string? url)
{
if (string.IsNullOrEmpty(url)) return;
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
}