v0.21.0 — System health banner with colored indicators + tooltips

New row between top bar and content showing pill-shaped status indicators
for the system dependencies that PROSERVE needs (SteamVR, Vive Business
Streaming process, VR headset reachable on the network, etc.). Each pill
is colored : 🟢 OK, 🟠 limitation détectée (e.g. ping élevé), 🔴 KO,
gris = non configuré. Hover → tooltip with full check kind, target,
last RTT/process count and timestamp.

Architecture
- LocalConfig.HealthChecksConfig : list of HealthCheckEntry (Kind=Ping
  or Process, Target=IP/host or process name, ping thresholds in ms,
  refresh interval in s).
- ISystemHealthService + SystemHealthService : ping via
  System.Net.NetworkInformation.Ping (no admin required), process
  lookup via System.Diagnostics.Process.GetProcessesByName. Returns
  HealthResult { Severity, Detail }.
- HealthIndicatorViewModel : observable wrapper per entry with
  Severity-driven Brushes (background pill, border, icon colour) and
  composed Tooltip text.
- MainViewModel.InitHealthIndicators + StartHealthLoop : populates
  ObservableCollection<HealthIndicatorViewModel> from config and runs
  parallel checks every RefreshIntervalSeconds (default 10s).
- MainWindow.xaml : new Row 1 (between top bar and body) hosting an
  ItemsControl bound to HealthIndicators. Row collapses cleanly if the
  list is empty (HasHealthIndicators=false).

Defaults shipped (all editable in %LocalAppData%\PSLauncher\config.json)
- 🎮 SteamVR (Process : vrserver)
- 📡 Vive Business Streaming (Process : HtcConnectionUtility)
- 🥽 Casque VR (Ping : empty, user fills in the headset IP)

The Settings UI editor for managing the list is intentionally deferred
to a future iteration — config.json edit is enough to start using it.

Versions bumped to 0.21.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 18:44:15 +02:00
parent 30eceaea2c
commit 60358a6cf5
10 changed files with 450 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ using PSLauncher.Core.Licensing;
using PSLauncher.Core.Localization;
using PSLauncher.Core.Manifests;
using PSLauncher.Core.DocTool;
using PSLauncher.Core.Health;
using PSLauncher.Core.Migrations;
using PSLauncher.Core.Process;
using PSLauncher.Core.ReportTool;
@@ -45,6 +46,7 @@ public sealed partial class MainViewModel : ObservableObject
private readonly IDatabaseMigrationService _migrationService;
private readonly IReportToolDeployer _reportDeployer;
private readonly IDocToolDeployer _docDeployer;
private readonly ISystemHealthService _healthService;
private readonly IServiceProvider _serviceProvider;
private readonly ILogger<MainViewModel> _logger;
@@ -63,6 +65,15 @@ public sealed partial class MainViewModel : ObservableObject
public ObservableCollection<VersionRowViewModel> OtherVersions { get; } = new();
/// <summary>
/// Indicateurs affichés dans le bandeau de santé sous la top bar : pings,
/// processus requis (SteamVR, Vive Streaming, etc.). Liste construite depuis
/// <see cref="HealthChecksConfig.Checks"/> au démarrage. Refresh périodique
/// piloté par <see cref="StartHealthLoop"/>.
/// </summary>
public ObservableCollection<HealthIndicatorViewModel> HealthIndicators { get; } = new();
public bool HasHealthIndicators => HealthIndicators.Count > 0;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasFeaturedVersion))]
[NotifyPropertyChangedFor(nameof(HasOtherVersions))]
@@ -236,6 +247,7 @@ public sealed partial class MainViewModel : ObservableObject
IDatabaseMigrationService migrationService,
IReportToolDeployer reportDeployer,
IDocToolDeployer docDeployer,
ISystemHealthService healthService,
IServiceProvider serviceProvider,
ILogger<MainViewModel> logger)
{
@@ -253,6 +265,7 @@ public sealed partial class MainViewModel : ObservableObject
_migrationService = migrationService;
_reportDeployer = reportDeployer;
_docDeployer = docDeployer;
_healthService = healthService;
_serviceProvider = serviceProvider;
_logger = logger;
@@ -261,6 +274,7 @@ public sealed partial class MainViewModel : ObservableObject
_license = _licenseService.GetCached();
RebuildList();
InitHealthIndicators();
// Vérification automatique des MAJ au démarrage (silencieuse et non bloquante)
_ = Task.Run(async () =>
@@ -275,6 +289,62 @@ public sealed partial class MainViewModel : ObservableObject
}
catch (Exception ex) { _logger.LogWarning(ex, "Auto check at startup failed"); }
});
// Boucle périodique des health checks. Ne tourne que si la config en
// contient au moins un. Premier passage immédiat puis re-check tous les
// RefreshIntervalSeconds.
StartHealthLoop();
}
/// <summary>
/// Construit la collection observable des indicateurs depuis la config et
/// notifie HasHealthIndicators pour que la UI cache le bandeau si la liste
/// est vide. Idempotent — appelée au startup uniquement, pas à chaque refresh.
/// </summary>
private void InitHealthIndicators()
{
HealthIndicators.Clear();
foreach (var entry in _config.HealthChecks.Checks)
HealthIndicators.Add(new HealthIndicatorViewModel(entry));
OnPropertyChanged(nameof(HasHealthIndicators));
}
/// <summary>
/// Lance une tâche en arrière-plan qui exécute tous les checks en parallèle,
/// applique les résultats sur les VM via le dispatcher UI, puis attend
/// RefreshIntervalSeconds avant de recommencer. La tâche tourne tant que
/// l'app vit ; pas de cancel explicite (l'arrêt suit la fermeture du process).
/// </summary>
private void StartHealthLoop()
{
if (HealthIndicators.Count == 0) return;
var interval = TimeSpan.FromSeconds(Math.Max(2, _config.HealthChecks.RefreshIntervalSeconds));
_ = Task.Run(async () =>
{
while (true)
{
try
{
var snapshot = HealthIndicators.ToList();
var tasks = snapshot.Select(async vm =>
{
try
{
var result = await _healthService.RunCheckAsync(vm.Entry, CancellationToken.None);
await Application.Current.Dispatcher.InvokeAsync(() => vm.Apply(result));
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Health check {Name} threw", vm.Entry.Name);
}
});
await Task.WhenAll(tasks).ConfigureAwait(false);
}
catch (Exception ex) { _logger.LogDebug(ex, "Health loop tick"); }
try { await Task.Delay(interval).ConfigureAwait(false); }
catch { break; }
}
});
}
/// <summary>