Merge branch 'main' into claudedo/4e19605838a3404f98624cb0e90195da
# Conflicts: # docs/open.md # src/ClaudeDo.Installer/CLAUDE.md # src/ClaudeDo.Installer/Pages/SystemCheckPage/SystemCheckPageView.xaml # src/ClaudeDo.Installer/Pages/SystemCheckPage/SystemCheckPageViewModel.cs
This commit is contained in:
@@ -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,73 +8,40 @@ 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 readonly ClaudeHelpLauncher _claudeHelpLauncher;
|
||||
private SystemCheckPageView? _view;
|
||||
private bool _hasStarted;
|
||||
private EnvironmentCheckReport? _lastReport;
|
||||
|
||||
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; }
|
||||
|
||||
// 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 => Checks.IsRunning || Checks.HasBlockingError;
|
||||
|
||||
[ObservableProperty] private bool _isRunning;
|
||||
[ObservableProperty] private bool _hasRun;
|
||||
[ObservableProperty] private bool _hasBlockingError;
|
||||
[ObservableProperty] private string _summary = string.Empty;
|
||||
[ObservableProperty] private string? _claudeHelpError;
|
||||
|
||||
public bool BlocksNavigation => IsRunning || HasBlockingError;
|
||||
|
||||
public bool ClaudeCliOk =>
|
||||
_lastReport?.Results.FirstOrDefault(r => r.Id == ClaudeCliCheck.CheckId)?.Status == CheckStatus.Ok;
|
||||
Checks.LastReport?.Results.FirstOrDefault(r => r.Id == ClaudeCliCheck.CheckId)?.Status == CheckStatus.Ok;
|
||||
|
||||
public bool ClaudeAuthFailed =>
|
||||
_lastReport?.Results.FirstOrDefault(r => r.Id == ClaudeAuthCheck.CheckId)?.Status == CheckStatus.Failed;
|
||||
Checks.LastReport?.Results.FirstOrDefault(r => r.Id == ClaudeAuthCheck.CheckId)?.Status == CheckStatus.Failed;
|
||||
|
||||
public bool CanStartClaudeHelp => ClaudeCliOk && !ClaudeAuthFailed;
|
||||
|
||||
@@ -101,24 +65,28 @@ public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
|
||||
ClaudeHelpLauncher claudeHelpLauncher)
|
||||
{
|
||||
_context = context;
|
||||
_checkServiceFactory = checkServiceFactory;
|
||||
_claudeHelpLauncher = claudeHelpLauncher;
|
||||
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, and so
|
||||
// the Claude-Help gating re-reads the fresh report.
|
||||
Checks.PropertyChanged += (_, _) =>
|
||||
{
|
||||
OnPropertyChanged(nameof(BlocksNavigation));
|
||||
OnPropertyChanged(nameof(ClaudeCliOk));
|
||||
OnPropertyChanged(nameof(ClaudeAuthFailed));
|
||||
OnPropertyChanged(nameof(CanStartClaudeHelp));
|
||||
OnPropertyChanged(nameof(ClaudeHelpTooltip));
|
||||
StartClaudeHelpCommand.NotifyCanExecuteChanged();
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -127,82 +95,17 @@ public partial class SystemCheckPageViewModel : ObservableObject, IInstallerPage
|
||||
|
||||
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));
|
||||
|
||||
_lastReport = report;
|
||||
HasBlockingError = report.HasBlockingError;
|
||||
Summary = BuildSummary(report);
|
||||
HasRun = true;
|
||||
|
||||
OnPropertyChanged(nameof(CanStartClaudeHelp));
|
||||
OnPropertyChanged(nameof(ClaudeHelpTooltip));
|
||||
StartClaudeHelpCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanRunChecks() => !IsRunning;
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanStartClaudeHelp))]
|
||||
private async Task StartClaudeHelpAsync()
|
||||
{
|
||||
if (_lastReport is null) return;
|
||||
if (Checks.LastReport is null) return;
|
||||
|
||||
ClaudeHelpError = null;
|
||||
var result = await _claudeHelpLauncher.LaunchAsync(_lastReport, _context, CancellationToken.None);
|
||||
var result = await _claudeHelpLauncher.LaunchAsync(Checks.LastReport, _context, CancellationToken.None);
|
||||
if (!result.Success)
|
||||
{
|
||||
ClaudeHelpError = TrExtension.Localizer?.Get("installer.systemCheck.claudeHelp.error", result.ErrorMessage ?? "")
|
||||
?? $"Could not start the Claude session: {result.ErrorMessage}";
|
||||
}
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user