diff --git a/src/ClaudeDo.Ui/ClaudeDo.Ui.csproj b/src/ClaudeDo.Ui/ClaudeDo.Ui.csproj index 7a19886..92c85bd 100644 --- a/src/ClaudeDo.Ui/ClaudeDo.Ui.csproj +++ b/src/ClaudeDo.Ui/ClaudeDo.Ui.csproj @@ -11,6 +11,7 @@ + diff --git a/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs b/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs index d6ec46a..b02a0a6 100644 --- a/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/IslandsShellViewModel.cs @@ -255,6 +255,51 @@ public sealed partial class IslandsShellViewModel : ViewModelBase await _updateCheck.CheckNowAsync(CancellationToken.None); } + [ObservableProperty] private string? _restartWorkerStatus; + + [RelayCommand] + private async Task RestartWorkerAsync() + { + if (!OperatingSystem.IsWindows()) + { + await FlashRestartStatusAsync("Service control is Windows-only."); + return; + } + + RestartWorkerStatus = "Restarting worker…"; + try + { + await Task.Run(() => + { + using var sc = new System.ServiceProcess.ServiceController("ClaudeDoWorker"); + if (sc.Status != System.ServiceProcess.ServiceControllerStatus.Stopped) + { + sc.Stop(); + sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(20)); + } + sc.Start(); + sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running, TimeSpan.FromSeconds(20)); + }); + await FlashRestartStatusAsync("Worker restarted."); + } + catch (InvalidOperationException) + { + // ServiceController throws this when the service is not installed. + await FlashRestartStatusAsync("ClaudeDoWorker service is not installed."); + } + catch (Exception ex) + { + await FlashRestartStatusAsync($"Restart failed: {ex.Message}"); + } + } + + private async Task FlashRestartStatusAsync(string text) + { + RestartWorkerStatus = text; + await Task.Delay(3000); + if (RestartWorkerStatus == text) RestartWorkerStatus = null; + } + [RelayCommand] private void DismissBanner() { diff --git a/src/ClaudeDo.Ui/Views/MainWindow.axaml b/src/ClaudeDo.Ui/Views/MainWindow.axaml index 1784682..5158462 100644 --- a/src/ClaudeDo.Ui/Views/MainWindow.axaml +++ b/src/ClaudeDo.Ui/Views/MainWindow.axaml @@ -67,6 +67,8 @@ Foreground="{DynamicResource TextDimBrush}"> +