Files
ClaudeDo/src/ClaudeDo.Ui/ViewModels/Modals/Settings/SessionSkillsSettingsTabViewModel.cs
T
Mika Kuns ec4cbcbaf9 chore(claude-do): [A3] Settings + Update-Check: OperationStatus für Skill-Inst
Vorgaben: `docs/superpowers/plans/2026-08-11-operation-feedback.md`, Gruppe A, Entwurf A3. P0-1 ist gemergt: `src/ClaudeDo.Ui/Services/OperationStatus.cs` + `src/ClaudeDo.Ui/Views/Controls/OperationIndicator.axaml`.

SCOPE-ÄNDERUNG (Nutzer, 2026-08-12): OnlineInbox Sign-In/Sign-Out ist AUS DEM SCOPE GENOMMEN — vorerst unwichtig. `ViewModels/Modals/Settings/OnlineInboxSettingsViewModel.cs` und die

ClaudeDo-Task: 2356806f-f16e-4652-b615-4562e95c3a65
2026-08-12 09:55:04 +02:00

99 lines
3.3 KiB
C#

using System.Collections.ObjectModel;
using ClaudeDo.Ui.Localization;
using ClaudeDo.Ui.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace ClaudeDo.Ui.ViewModels.Modals.Settings;
public sealed partial class SessionSkillsSettingsTabViewModel : ViewModelBase
{
private readonly IWorkerClient _worker;
public OperationStatus InstallOp { get; } = new();
public OperationStatus UpdateOp { get; } = new();
[ObservableProperty] private string _installUrl = "";
[ObservableProperty] private string _statusMessage = "";
[ObservableProperty] private bool _isBusy;
[ObservableProperty] private bool _isEmpty = true;
public ObservableCollection<SessionSkillDto> Skills { get; } = new();
public SessionSkillsSettingsTabViewModel(IWorkerClient worker)
{
_worker = worker;
InstallOp.PropertyChanged += (_, e) =>
{
if (e.PropertyName == nameof(OperationStatus.IsRunning)) InstallCommand.NotifyCanExecuteChanged();
};
UpdateOp.PropertyChanged += (_, e) =>
{
if (e.PropertyName == nameof(OperationStatus.IsRunning)) UpdateCommand.NotifyCanExecuteChanged();
};
}
public async Task LoadAsync()
{
IsBusy = true;
try
{
var skills = await _worker.GetSessionSkillsAsync();
Skills.Clear();
foreach (var s in skills) Skills.Add(s);
IsEmpty = Skills.Count == 0;
}
finally { IsBusy = false; }
}
private bool CanInstall() => !InstallOp.IsRunning;
[RelayCommand(CanExecute = nameof(CanInstall))]
private async Task InstallAsync()
{
if (string.IsNullOrWhiteSpace(InstallUrl)) return;
StatusMessage = "";
using var op = InstallOp.Begin(Loc.T("ops.skills.installing"));
try
{
var installed = await _worker.InstallSessionSkillAsync(InstallUrl.Trim());
StatusMessage = Loc.T("vm.sessionSkillsTab.installed", string.Join(", ", installed));
InstallUrl = "";
await LoadAsync();
}
catch (Exception ex) { StatusMessage = Loc.T("vm.sessionSkillsTab.installFailed", ex.Message); }
}
private bool CanUpdate(string? sourceUrl) => !UpdateOp.IsRunning;
[RelayCommand(CanExecute = nameof(CanUpdate))]
private async Task UpdateAsync(string? sourceUrl)
{
if (string.IsNullOrWhiteSpace(sourceUrl)) return;
StatusMessage = "";
using var op = UpdateOp.Begin(Loc.T("ops.skills.updating"));
try
{
await _worker.UpdateSessionSkillAsync(sourceUrl);
StatusMessage = Loc.T("vm.sessionSkillsTab.updated");
await LoadAsync();
}
catch (Exception ex) { StatusMessage = Loc.T("vm.sessionSkillsTab.updateFailed", ex.Message); }
}
[RelayCommand]
private async Task RemoveAsync(string? sourceUrl)
{
if (string.IsNullOrWhiteSpace(sourceUrl)) return;
IsBusy = true; StatusMessage = "";
try
{
await _worker.RemoveSessionSkillAsync(sourceUrl);
StatusMessage = Loc.T("vm.sessionSkillsTab.removed");
await LoadAsync();
}
catch (Exception ex) { StatusMessage = Loc.T("vm.sessionSkillsTab.removeFailed", ex.Message); }
finally { IsBusy = false; }
}
}