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
+10 -8
View File
@@ -149,19 +149,21 @@ beider Branches, nicht aus `main` selbst. Details → `installer-preflight` in
`docs/explore-notes/README.md` und den neuen Abschnitt „Environment Checks" in `docs/explore-notes/README.md` und den neuen Abschnitt „Environment Checks" in
`src/ClaudeDo.Installer/CLAUDE.md`. `src/ClaudeDo.Installer/CLAUDE.md`.
**Zusätzliche Lücke, unabhängig vom Merge:** die zwei Folge-Tasks „Claude Help Me"-Button **Update (2026-08-06):** die Diagnose-Sektion (Config-Modus/`SettingsWindow`) ist implementiert
und Diagnose-Sektion (Config-Modus/`SettingsWindow`) sind **nicht implementiert** — beide `Pages/DiagnosePage/` + geteilte `Checks/CheckListViewModel.cs`/`Checks/CheckListView.xaml`
liefen ins selbe Merge-Problem und wurden ohne jede Code-Änderung als `Blocked` beendet. Die (auch von `SystemCheckPage` genutzt, keine zweite Implementierung). Unit-getestet
folgenden Punkte, die diese zwei Features beträfen, können also noch nicht geprüft werden und (`tests/ClaudeDo.Installer.Tests/Pages/DiagnosePage/DiagnosePageViewModelTests.cs`), **aber
brauchen zuerst eine neue Umsetzungsrunde: nicht visuell verifiziert** — siehe Punkt unten. Der „Claude Help Me"-Button bleibt offen (sein
Footer-Slot ist in `CheckListView.xaml` reserviert):
- [ ] „Claude Help Me" öffnet ein Terminal mit laufender Claude-Session, und die Session hat - [ ] „Claude Help Me" öffnet ein Terminal mit laufender Claude-Session, und die Session hat
den Diagnose-Report tatsächlich gelesen — **nicht umsetzbar, Feature existiert nicht.** den Diagnose-Report tatsächlich gelesen — **nicht umsetzbar, Feature existiert nicht.**
- [ ] Der Help-Me-Button ist korrekt deaktiviert, wenn `claude` nicht im PATH ist, mit - [ ] Der Help-Me-Button ist korrekt deaktiviert, wenn `claude` nicht im PATH ist, mit
verständlichem Tooltip — **nicht umsetzbar, Feature existiert nicht.** verständlichem Tooltip — **nicht umsetzbar, Feature existiert nicht.**
- [ ] Diagnose-Sektion im Config-Modus zeigt die echten installierten Pfade/Ports, und der - [ ] Diagnose-Sektion im Config-Modus: Öffnen von SettingsWindow löst keinen Prüflauf aus, Klick
laufende Worker auf 47821 gilt nicht als Konflikt — **nicht umsetzbar, Feature existiert auf „Erneut prüfen" schon; zeigt die echten installierten Pfade/Ports (nicht die
nicht.** InstallContext-Defaults), und der laufende Worker auf dem konfigurierten SignalR-Port gilt
nicht als Konflikt — **unit-verifiziert, visueller Durchlauf noch offen.**
Sobald die beiden Branches oben gemerged sind, sind folgende Punkte real prüfbar (gebaut + Sobald die beiden Branches oben gemerged sind, sind folgende Punkte real prüfbar (gebaut +
unit-getestet gegen die Scratch-Integration, aber **nicht visuell verifiziert**): unit-getestet gegen die Scratch-Integration, aber **nicht visuell verifiziert**):
+5
View File
@@ -11,6 +11,7 @@ using ClaudeDo.Installer.Core.Interfaces;
using ClaudeDo.Installer.Localization; using ClaudeDo.Installer.Localization;
using ClaudeDo.Localization; using ClaudeDo.Localization;
using ClaudeDo.Releases; using ClaudeDo.Releases;
using ClaudeDo.Installer.Pages.DiagnosePage;
using ClaudeDo.Installer.Pages.InstallPage; using ClaudeDo.Installer.Pages.InstallPage;
using ClaudeDo.Installer.Pages.PathsPage; using ClaudeDo.Installer.Pages.PathsPage;
using ClaudeDo.Installer.Pages.ServicePage; using ClaudeDo.Installer.Pages.ServicePage;
@@ -153,6 +154,10 @@ public partial class App : Application
sc.AddSingleton<IInstallerPage, ServicePageViewModel>(); sc.AddSingleton<IInstallerPage, ServicePageViewModel>();
sc.AddSingleton<IInstallerPage, UiSettingsPageViewModel>(); sc.AddSingleton<IInstallerPage, UiSettingsPageViewModel>();
sc.AddSingleton<IInstallerPage, InstallPageViewModel>(); 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>). // Steps — execution order matters for the FreshInstall pipeline (IEnumerable<IInstallStep>).
// Double-registered as both IInstallStep and concrete type so the Update pipeline // 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 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). 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 `SystemCheckPage` (`Pages/SystemCheckPage/`) hosts the check list in the **FreshInstall** wizard
only, registered via `PageResolver` at `Order = 1` (directly after `WelcomePage`); `WizardViewModel` 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 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" 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). 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 **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 external terminal with a live `claude` session for setup troubleshooting. Its footer slot is
in `SettingsWindow` (Config mode) that re-runs the same checks against the installed configuration. reserved in `CheckListView.xaml`; still blocked on the same follow-up as before.
Both were speced as follow-up tasks; both blocked before writing any code because their prerequisite
(this section) wasn't on `main` yet.
@@ -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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClaudeDo.Installer.Pages.SystemCheckPage" xmlns:local="clr-namespace:ClaudeDo.Installer.Pages.SystemCheckPage"
xmlns:checks="clr-namespace:ClaudeDo.Installer.Checks"
xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization" xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization"
d:DataContext="{d:DesignInstance local:SystemCheckPageViewModel}" d:DataContext="{d:DesignInstance local:SystemCheckPageViewModel}"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -12,8 +13,6 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Header --> <!-- Header -->
@@ -23,77 +22,6 @@
Foreground="{StaticResource TextSecondaryBrush}" TextWrapping="Wrap"/> Foreground="{StaticResource TextSecondaryBrush}" TextWrapping="Wrap"/>
</StackPanel> </StackPanel>
<!-- Check list --> <checks:CheckListView Grid.Row="1" DataContext="{Binding Checks}"/>
<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>
</Grid> </Grid>
</UserControl> </UserControl>
@@ -1,8 +1,5 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media;
using ClaudeDo.Installer.Checks; using ClaudeDo.Installer.Checks;
using ClaudeDo.Installer.Core; using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Localization; using ClaudeDo.Installer.Localization;
@@ -11,85 +8,45 @@ using CommunityToolkit.Mvvm.Input;
namespace ClaudeDo.Installer.Pages.SystemCheckPage; 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 public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
{ {
private readonly InstallContext _context;
private readonly Func<EnvironmentCheckService> _checkServiceFactory;
private SystemCheckPageView? _view; private SystemCheckPageView? _view;
private bool _hasStarted; private bool _hasStarted;
public string Title => TrExtension.Localizer?["installer.systemCheck.title"] ?? "System Check"; public string Title => TrExtension.Localizer?["installer.systemCheck.title"] ?? "System Check";
public string Icon => ""; public string Icon => "";
public int Order => 1; public int Order => 1;
public bool ShowInWizard => true; public bool ShowInWizard => true;
public bool ShowInSettings => false; public bool ShowInSettings => false;
public UserControl View => _view ??= new SystemCheckPageView { DataContext = this }; public UserControl View => _view ??= new SystemCheckPageView { DataContext = this };
public ObservableCollection<CheckRowViewModel> Rows { get; } = []; public CheckListViewModel Checks { get; }
[ObservableProperty] private bool _isRunning; // Pass-through to the shared check-run logic — kept so this page's UI/tests can bind
[ObservableProperty] private bool _hasRun; // directly on it, matching the pre-extraction API.
[ObservableProperty] private bool _hasBlockingError; public ObservableCollection<CheckRowViewModel> Rows => Checks.Rows;
[ObservableProperty] private string _summary = string.Empty; 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) public SystemCheckPageViewModel(InstallContext context, Func<EnvironmentCheckService> checkServiceFactory)
{ {
_context = context; Checks = new CheckListViewModel(context, checkServiceFactory);
_checkServiceFactory = 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() public Task LoadAsync()
{ {
if (!_hasStarted) if (!_hasStarted)
{ {
_hasStarted = true; _hasStarted = true;
_ = RunChecksAsync(); _ = Checks.RunChecksCommand.ExecuteAsync(null);
} }
return Task.CompletedTask; return Task.CompletedTask;
} }
@@ -97,64 +54,4 @@ public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
public Task ApplyAsync() => Task.CompletedTask; public Task ApplyAsync() => Task.CompletedTask;
public bool Validate() => !HasBlockingError; 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 });
}
} }
@@ -531,6 +531,10 @@
"subtitle": "Klicke auf Installieren, um ClaudeDo zu erstellen und bereitzustellen.", "subtitle": "Klicke auf Installieren, um ClaudeDo zu erstellen und bereitzustellen.",
"launch": "ClaudeDo starten" "launch": "ClaudeDo starten"
}, },
"diagnose": {
"title": "Diagnose",
"subtitle": "Führt die Systemprüfungen erneut aus, gegen deine installierte Konfiguration."
},
"settings": { "settings": {
"removeUserData": "Benutzerdaten entfernen (Aufgaben, Logs, Konfigurationen in ~/.todo-app)", "removeUserData": "Benutzerdaten entfernen (Aufgaben, Logs, Konfigurationen in ~/.todo-app)",
"uninstall": "Deinstallieren", "uninstall": "Deinstallieren",
@@ -531,6 +531,10 @@
"subtitle": "Click Install to build and deploy ClaudeDo.", "subtitle": "Click Install to build and deploy ClaudeDo.",
"launch": "Launch ClaudeDo" "launch": "Launch ClaudeDo"
}, },
"diagnose": {
"title": "Diagnose",
"subtitle": "Re-run the environment checks against your installed configuration."
},
"settings": { "settings": {
"removeUserData": "Remove user data (tasks, logs, configs in ~/.todo-app)", "removeUserData": "Remove user data (tasks, logs, configs in ~/.todo-app)",
"uninstall": "Uninstall", "uninstall": "Uninstall",
@@ -1,4 +1,6 @@
using ClaudeDo.Installer.Checks;
using ClaudeDo.Installer.Core; using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Pages.DiagnosePage;
using ClaudeDo.Installer.Pages.PathsPage; using ClaudeDo.Installer.Pages.PathsPage;
using ClaudeDo.Installer.Pages.ServicePage; using ClaudeDo.Installer.Pages.ServicePage;
using ClaudeDo.Installer.Pages.SystemCheckPage; using ClaudeDo.Installer.Pages.SystemCheckPage;
@@ -40,4 +42,33 @@ public class PageResolverTests
Assert.False(page.ShowInSettings); Assert.False(page.ShowInSettings);
} }
[Fact]
public void DiagnosePage_is_shown_in_settings_but_not_in_the_wizard()
{
var context = new InstallContext();
var page = new DiagnosePageViewModel(context, () => throw new InvalidOperationException(), () => new InstallerWorkerConfig());
Assert.True(page.ShowInSettings);
Assert.False(page.ShowInWizard);
}
[Fact]
public void DiagnosePage_appears_in_the_settings_sidebar_after_the_other_settings_pages()
{
var context = new InstallContext();
var pages = new IInstallerPage[]
{
new PathsPageViewModel(context),
new ServicePageViewModel(context),
new UiSettingsPageViewModel(context),
new DiagnosePageViewModel(context, () => throw new InvalidOperationException(), () => new InstallerWorkerConfig()),
};
var resolver = new PageResolver(pages);
var settingsPages = resolver.SettingsPages.ToList();
Assert.Equal(4, settingsPages.Count);
Assert.IsType<DiagnosePageViewModel>(settingsPages[^1]);
}
} }
@@ -0,0 +1,125 @@
using System.Net;
using System.Net.Sockets;
using ClaudeDo.Installer.Checks;
using ClaudeDo.Installer.Checks.Interfaces;
using ClaudeDo.Installer.Core;
using ClaudeDo.Installer.Tests.Pages.SystemCheckPage;
using Vm = ClaudeDo.Installer.Pages.DiagnosePage.DiagnosePageViewModel;
namespace ClaudeDo.Installer.Tests.Pages.DiagnosePage;
public sealed class DiagnosePageViewModelTests
{
private sealed class FakeOwnerResolver : IPortOwnerResolver
{
private readonly string? _owner;
public FakeOwnerResolver(string? owner) => _owner = owner;
public Task<string?> FindOwningProcessNameAsync(int port, CancellationToken ct) => Task.FromResult(_owner);
}
private static int GetFreePort()
{
var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
listener.Stop();
return port;
}
[Fact]
public async Task Loading_the_page_does_not_run_checks()
{
var check = FakeEnvironmentCheck.Ok("a");
var vm = new Vm(
new InstallContext(),
() => new EnvironmentCheckService(new IEnvironmentCheck[] { check }),
() => new InstallerWorkerConfig());
await vm.LoadAsync();
Assert.Equal(0, check.CallCount);
Assert.False(vm.Checks.HasRun);
Assert.Empty(vm.Checks.Rows);
}
[Fact]
public async Task Clicking_check_runs_once_and_a_second_click_during_the_run_starts_no_new_run()
{
var gate = new TaskCompletionSource();
var slow = new FakeEnvironmentCheck("slow", CheckSeverity.Error, async (_, _) =>
{
await gate.Task;
return CheckResult.Ok("slow", CheckSeverity.Error, "checks.slow.title", "ok");
});
var factoryCalls = 0;
var vm = new Vm(
new InstallContext(),
() =>
{
factoryCalls++;
return new EnvironmentCheckService(new IEnvironmentCheck[] { slow });
},
() => new InstallerWorkerConfig());
await vm.LoadAsync();
var firstRun = vm.Checks.RunChecksCommand.ExecuteAsync(null);
Assert.True(vm.Checks.IsRunning);
await vm.Checks.RunChecksCommand.ExecuteAsync(null); // second click while the first run is still in flight
Assert.Equal(1, factoryCalls);
Assert.Equal(1, slow.CallCount);
gate.SetResult();
await firstRun;
Assert.False(vm.Checks.IsRunning);
}
[Fact]
public async Task Checks_run_against_the_installed_configuration_not_context_defaults()
{
InstallContext? capturedCtx = null;
var probe = new FakeEnvironmentCheck("probe", CheckSeverity.Warning, (ctx, _) =>
{
capturedCtx = ctx;
return Task.FromResult(CheckResult.Ok("probe", CheckSeverity.Warning, "checks.probe.title", "ok"));
});
var sharedContext = new InstallContext { InstallDirectory = @"C:\Program Files\ClaudeDo" };
var vm = new Vm(
sharedContext,
() => new EnvironmentCheckService(new IEnvironmentCheck[] { probe }),
() => new InstallerWorkerConfig { ClaudeBin = @"C:\installed\claude.exe", SignalRPort = 55555 });
await vm.LoadAsync();
await vm.Checks.RunChecksCommand.ExecuteAsync(null);
Assert.NotNull(capturedCtx);
Assert.Equal(@"C:\installed\claude.exe", capturedCtx!.ClaudeBin);
Assert.Equal(55555, capturedCtx.SignalRPort);
Assert.Equal(@"C:\Program Files\ClaudeDo", capturedCtx.InstallDirectory);
}
[Fact]
public async Task Worker_already_running_on_the_installed_signalr_port_reports_ok()
{
var port = GetFreePort();
using var occupying = new TcpListener(IPAddress.Loopback, port);
occupying.Start();
var sharedContext = new InstallContext { ExternalMcpPort = GetFreePort() };
var vm = new Vm(
sharedContext,
() => new EnvironmentCheckService(new IEnvironmentCheck[] { new PortCheck(new FakeOwnerResolver("ClaudeDo.Worker")) }),
() => new InstallerWorkerConfig { SignalRPort = port });
await vm.LoadAsync();
await vm.Checks.RunChecksCommand.ExecuteAsync(null);
var row = Assert.Single(vm.Checks.Rows);
Assert.Equal(CheckStatus.Ok, row.Status);
}
}