feat(ui): PowerUse-Einstellungen nach Settings -> Ausfuehrung verschieben

Schalter, Zeitfenster und Handoff-Prozent lagen im Usage-Monitor und mussten
in SettingsModalViewModel nur load->save durchgeschleift werden, damit ein
Settings-Speichern sie nicht zurueckwirft. Jetzt gehoeren sie dem General-Tab,
der Monitor ist wieder nur Anzeige + Threshold-Drag, und "Jetzt aktualisieren"
sitzt als Icon in der Titelleiste (neuer ModalShell.HeaderActions-Slot).
This commit is contained in:
mika kuns
2026-09-07 08:17:37 +02:00
parent c7392e085f
commit 7c7c33d677
21 changed files with 179 additions and 213 deletions
@@ -131,6 +131,38 @@ public class SettingsModalViewModelTests : IDisposable
Assert.Equal(77, worker.Saved.UsageGateSevenDayPct);
}
[Fact]
public async Task PowerUse_survives_a_load_edit_save_round_trip()
{
// PowerUse moved off the usage monitor onto this tab, so Settings is now its only writer.
// A binding that doesn't reach General silently resets the switch to the record default.
var worker = new FakeWorker
{
AppToReturn = DtoWith(80, 90) with
{
PowerUseEnabled = true,
PowerUseWindowStart = "18:00",
PowerUseWindowEnd = "06:00",
PowerUseHandoffPct = 88,
},
};
var vm = MakeVm(worker);
await vm.LoadAsync();
Assert.True(vm.General.PowerUseEnabled);
Assert.Equal("18:00", vm.General.PowerUseWindowStart);
Assert.Equal(88, vm.General.PowerUseHandoffPct);
// A typo in the window is normalized to null on save, not stored as a fake window.
vm.General.PowerUseWindowEnd = "not a time";
await vm.SaveCommand.ExecuteAsync(null);
Assert.True(worker.Saved!.PowerUseEnabled);
Assert.Equal("18:00", worker.Saved.PowerUseWindowStart);
Assert.Null(worker.Saved.PowerUseWindowEnd);
Assert.Equal(88, worker.Saved.PowerUseHandoffPct);
}
[Fact]
public async Task HasLinkedRepo_false_when_no_list_has_a_working_dir()
{
@@ -4,9 +4,8 @@ using Xunit;
namespace ClaudeDo.Worker.Tests.Hub;
/// The PowerUse window and handoff threshold are edited on the usage monitor, but Settings→General
/// rebuilds the whole DTO positionally on save. So the contract that matters is: whatever
/// GetAppSettings hands out, feeding it straight back must change nothing.
/// Settings rebuilds the whole AppSettings DTO positionally on save, so the contract that matters
/// is: whatever GetAppSettings hands out, feeding it straight back must change nothing.
public sealed class PowerUseSettingsHubTests : IDisposable
{
private readonly DbFixture _db = new();
@@ -72,8 +72,8 @@ public sealed class HandlerRestartCoordinatorTests : IDisposable
});
await ctx.SaveChangesAsync();
// Written straight to the row: AppSettingsRepository.UpdateAsync deliberately doesn't
// copy PowerUseEnabled (the usage monitor owns that toggle, not the settings modal).
// Written straight to the row so the fixture doesn't depend on the repository's
// clamping/normalizing copy block.
await new AppSettingsRepository(ctx).GetAsync(); // materializes the singleton row
var settings = await ctx.AppSettings.FirstAsync(s => s.Id == AppSettingsEntity.SingletonId);
settings.PowerUseEnabled = powerUseEnabled;
@@ -68,8 +68,8 @@ public sealed class HandlerUsageGuardTests : IDisposable
});
await ctx.SaveChangesAsync();
// Written straight to the row: AppSettingsRepository.UpdateAsync deliberately doesn't
// copy PowerUseEnabled (the usage monitor owns that toggle, not the settings modal).
// Written straight to the row so the fixture doesn't depend on the repository's
// clamping/normalizing copy block.
await new AppSettingsRepository(ctx).GetAsync();
var settings = await ctx.AppSettings.FirstAsync(s => s.Id == AppSettingsEntity.SingletonId);
settings.PowerUseEnabled = powerUseEnabled;