Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
feat(execution): report what an apply actually did
fatDuck3b89bcb1d0b6
diff --git a/optimizerDuck.Test/Domain/UI/OptimizationStateTests.cs b/optimizerDuck.Test/Domain/UI/OptimizationStateTests.csnew file mode 100644index 0000000..2e02f43--- /dev/null+++ b/optimizerDuck.Test/Domain/UI/OptimizationStateTests.cs@@ -0,0 +1,26 @@+using optimizerDuck.Common.Helpers;+using optimizerDuck.Domain.UI;++namespace optimizerDuck.Test.Domain.UI;++public class OptimizationStateTests+{+ [Fact]+ public void IsAlreadyOptimal_DefaultsToFalseAndIsNeverWrittenToDisk()+ {+ var state = new OptimizationState();+ Assert.False(state.IsAlreadyOptimal);++ var before = Directory.Exists(Shared.RevertDirectory)+ ? Directory.GetFiles(Shared.RevertDirectory).Length+ : 0;++ state.IsAlreadyOptimal = true;++ Assert.True(state.IsAlreadyOptimal);+ var after = Directory.Exists(Shared.RevertDirectory)+ ? Directory.GetFiles(Shared.RevertDirectory).Length+ : 0;+ Assert.Equal(before, after);+ }+}diff --git a/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs b/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.csindex a0f272d..82b008e 100644--- a/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs+++ b/optimizerDuck.Test/Services/ApplyRevertComprehensiveTests.cs@@ -1,4 +1,4 @@-using Microsoft.Extensions.Logging.Abstractions;+using Microsoft.Extensions.Logging.Abstractions;using Newtonsoft.Json;using optimizerDuck.Common.Helpers;using optimizerDuck.Domain.Abstractions;@@ -1129,6 +1129,75 @@ public class ApplyRevertComprehensiveTestsreturn tcs.Task;}+ [Fact]+ public async Task ApplyAsync_OnlySkipsRecorded_ReportsNothingToDoWithoutRevertData()+ {+ await RunInStaThreadAsync(async () =>+ {+ var optimization = new TestOptimization+ {+ Id = Guid.NewGuid(),+ ApplyImpl = args =>+ args.context.Changes.AddSkip(+ "Service",+ "Service 'x' is already set to Manual (skipped)"+ ),+ };+ var revertPath = GetRevertFilePath(optimization.Id);+ var service = CreateService();+ var progress = new Progress<ProcessingProgress>(_ => { });++ var result = await service.ApplyAsync(optimization, progress);++ Assert.Equal(OptimizationSuccessResult.NothingToDo, result.Status);+ Assert.Empty(result.FailedSteps);+ Assert.False(File.Exists(revertPath));+ });+ }++ [Fact]+ public async Task ApplyAsync_NoStepsRecordedButProviderReportsSuccess_ReportsNothingToDo()+ {+ await RunInStaThreadAsync(async () =>+ {+ var optimization = new TestOptimization+ {+ Id = Guid.NewGuid(),+ ApplyImpl = _ => { },+ ResultOverride = ApplyResult.True(),+ };+ var revertPath = GetRevertFilePath(optimization.Id);+ var service = CreateService();+ var progress = new Progress<ProcessingProgress>(_ => { });++ var result = await service.ApplyAsync(optimization, progress);++ Assert.Equal(OptimizationSuccessResult.NothingToDo, result.Status);+ Assert.False(File.Exists(revertPath));+ });+ }++ [Fact]+ public async Task ApplyAsync_OnlySkipsFromToApplyResult_IsNotAFailure()+ {+ await RunInStaThreadAsync(async () =>+ {+ // A provider that records only skips and returns ToApplyResult() must not be+ // reported as a failure, which was the case before the classification changed.+ var optimization = new TestOptimization+ {+ Id = Guid.NewGuid(),+ ApplyImpl = args => args.context.Changes.AddSkip("Service", "nothing to do"),+ };+ var service = CreateService();+ var progress = new Progress<ProcessingProgress>(_ => { });++ var result = await service.ApplyAsync(optimization, progress);++ Assert.NotEqual(OptimizationSuccessResult.Failed, result.Status);+ });+ }+private sealed class TestOptimization : StubOptimization{public override string Name => "Test Optimization";@@ -1139,13 +1208,15 @@ public class ApplyRevertComprehensiveTestsOptimizationContext context)> ApplyImpl { get; init; } = _ => { };+ public ApplyResult? ResultOverride { get; init; }+public override Task<ApplyResult> ApplyAsync(IProgress<ProcessingProgress> progress,OptimizationContext context){ApplyImpl((progress, context));- return Task.FromResult(context.Changes.ToApplyResult());+ return Task.FromResult(ResultOverride ?? context.Changes.ToApplyResult());}}diff --git a/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs b/optimizerDuck.Test/Services/Managers/RevertManagerTests.csindex a7cc74b..e86fb29 100644--- a/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs+++ b/optimizerDuck.Test/Services/Managers/RevertManagerTests.cs@@ -1,4 +1,4 @@-using Microsoft.Extensions.Logging;+using Microsoft.Extensions.Logging;using Microsoft.Extensions.Logging.Abstractions;using Newtonsoft.Json;using Newtonsoft.Json.Linq;@@ -566,6 +566,70 @@ public class MockOptimization(Guid id) : StubOptimization}}+/// <summary>+/// Pins the guard that a step recorded as a change carries the data needed to undo it.+/// The writer filters entries without compensation, so the warning is the only signal+/// that a provider forgot one.+/// </summary>+public class RevertManagerChangeGuardTests+{+ private sealed class CapturingLogger : ILogger<RevertManager>+ {+ public List<string> Warnings { get; } = [];++ public IDisposable? BeginScope<TState>(TState state)+ where TState : notnull => null;++ public bool IsEnabled(LogLevel logLevel) => true;++ public void Log<TState>(+ LogLevel logLevel,+ EventId eventId,+ TState state,+ Exception? exception,+ Func<TState, Exception?, string> formatter+ )+ {+ if (logLevel == LogLevel.Warning)+ Warnings.Add(formatter(state, exception));+ }+ }++ [Fact]+ public async Task SaveRevertDataAsync_ChangeWithoutCompensation_WarnsAndWritesNoFile()+ {+ var logger = new CapturingLogger();+ var manager = new RevertManager(+ logger,+ TestShell.New(),+ new PowerPlanService(NullLogger<PowerPlanService>.Instance),+ TimeProvider.System+ );+ var id = Guid.NewGuid();+ var path = Path.Combine(Shared.RevertDirectory, id + ".json");+ var changes = new ChangeSet();+ changes.Add("Registry", "wrote a value", true, null);++ try+ {+ await manager.SaveRevertDataAsync(+ changes,+ id,+ "GuardTestOptimization",+ TestContext.Current.CancellationToken+ );++ Assert.Contains(logger.Warnings, w => w.Contains("carries no revert data"));+ Assert.False(File.Exists(path));+ }+ finally+ {+ if (File.Exists(path))+ File.Delete(path);+ }+ }+}+public class RetryableTestRevertStep : IRevertStep{public const string StepType = "RetryableTest";diff --git a/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs b/optimizerDuck.Test/Services/OptimizationExecutionContextTests.csindex b6e8a04..b880ec3 100644--- a/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs+++ b/optimizerDuck.Test/Services/OptimizationExecutionContextTests.cs@@ -1,4 +1,4 @@-using Microsoft.Extensions.Logging;+using Microsoft.Extensions.Logging;using Newtonsoft.Json.Linq;using optimizerDuck.Domain.Abstractions;using optimizerDuck.Domain.Execution;@@ -128,6 +128,55 @@ public class ChangeSetTestsAssert.Equal(100, changes.Changes.Count);Assert.Equal(100, changes.Changes.Select(c => c.Index).Distinct().Count());}+ [Fact]+ public void AddSkip_RecordsSuccessfulSkipWithoutCompensation()+ {+ var changes = new ChangeSet();++ changes.AddSkip("Service", "Service 'x' is already set to Manual (skipped)");++ var change = Assert.Single(changes.Changes);+ Assert.True(change.Ok);+ Assert.Equal(ChangeKind.Skip, change.Kind);+ Assert.Null(change.Revert);+ }++ [Fact]+ public void AddIrreversible_RecordsOneWayStep()+ {+ var changes = new ChangeSet();++ changes.AddIrreversible("Scheduled Task", "Deleted task '\\x'");++ var change = Assert.Single(changes.Changes);+ Assert.True(change.Ok);+ Assert.Equal(ChangeKind.Irreversible, change.Kind);+ Assert.Null(change.Revert);+ }++ [Fact]+ public void DidApplyAnything_IgnoresSkipsAndIrreversibleSteps()+ {+ var changes = new ChangeSet();+ changes.AddSkip("Service", "skipped");+ changes.AddIrreversible("Scheduled Task", "deleted");++ Assert.False(changes.DidApplyAnything);++ changes.Add("Registry", "wrote a value", true, new MockRevertStep());++ Assert.True(changes.DidApplyAnything);+ }++ [Fact]+ public void DidApplyAnything_FailedChangeDoesNotCount()+ {+ var changes = new ChangeSet();++ changes.Add("Registry", "write failed", false, null, "denied");++ Assert.False(changes.DidApplyAnything);+ }}public class MockRevertStep : IRevertStepdiff --git a/optimizerDuck.Test/Services/OptimizationServices/ScheduledTaskServiceTests.cs b/optimizerDuck.Test/Services/OptimizationServices/ScheduledTaskServiceTests.csindex e6b857f..e45d67d 100644--- a/optimizerDuck.Test/Services/OptimizationServices/ScheduledTaskServiceTests.cs+++ b/optimizerDuck.Test/Services/OptimizationServices/ScheduledTaskServiceTests.cs@@ -1,6 +1,9 @@-using Microsoft.Extensions.Logging.Abstractions;+using Microsoft.Extensions.Logging.Abstractions;+using optimizerDuck.Domain.Execution;using optimizerDuck.Domain.Optimizations.Models.ScheduledTask;+using optimizerDuck.Domain.Revert.Steps;using optimizerDuck.Services.System.Primitives;+using optimizerDuck.Test.TestDoubles;namespace optimizerDuck.Test.Services.OptimizationServices;@@ -17,4 +20,83 @@ public class ScheduledTaskServiceTestsAssert.Equal(TaskEnabledState.NotFound, state);}++ [Fact]+ public async Task DisableAndEnable_RoundTripThroughTheRecordedRevertSteps()+ {+ // The enable and disable pair is the part optimizations use, so the recorded step has to+ // carry the previous state and put it back. This test creates and deletes its own task.+ var name = $"optimizerDuck_Test_{Guid.NewGuid():N}";+ var fullPath = "\\" + name;+ var model = new ScheduledTaskModel+ {+ Name = name,+ Path = "\\",+ FullPath = fullPath,+ ExecutablePath = "cmd.exe",+ Arguments = "/c exit 0",+ IsEnabled = true,+ };++ try+ {+ var registered = ScheduledTaskService.RegisterTask(+ NewCall(),+ "\\",+ model+ );+ Assert.True(registered.Ok, registered.Error);++ // Disable: the recorded step must carry "was enabled" and restore it.+ var disableCall = NewCall();+ var disabled = ScheduledTaskService.DisableTask(disableCall, fullPath);+ Assert.True(disabled.Ok, disabled.Error);+ var disableStep = Assert.IsType<ScheduledTaskRevertStep>(+ Assert.Single(disableCall.Changes.Changes).Revert+ );+ Assert.True(disableStep.OriginalEnabled);+ Assert.Equal(+ TaskEnabledState.Disabled,+ ScheduledTaskService.GetTaskEnabledState(fullPath, NullLogger.Instance)+ );++ Assert.True(+ await disableStep.ExecuteAsync(TestShell.Context(), NullLogger.Instance)+ );+ Assert.Equal(+ TaskEnabledState.Enabled,+ ScheduledTaskService.GetTaskEnabledState(fullPath, NullLogger.Instance)+ );++ // Disable again first, so enabling really changes the state.+ Assert.True(ScheduledTaskService.DisableTask(NewCall(), fullPath).Ok);++ // Enable: the recorded step must carry "was disabled" and restore that.+ var enableCall = NewCall();+ var enabled = ScheduledTaskService.EnableTask(enableCall, fullPath);+ Assert.True(enabled.Ok, enabled.Error);+ var enableStep = Assert.IsType<ScheduledTaskRevertStep>(+ Assert.Single(enableCall.Changes.Changes).Revert+ );+ Assert.False(enableStep.OriginalEnabled);++ Assert.True(await enableStep.ExecuteAsync(TestShell.Context(), NullLogger.Instance));+ Assert.Equal(+ TaskEnabledState.Disabled,+ ScheduledTaskService.GetTaskEnabledState(fullPath, NullLogger.Instance)+ );+ }+ finally+ {+ ScheduledTaskService.DeleteTask(NewCall(), fullPath);+ }++ Assert.Equal(+ TaskEnabledState.NotFound,+ ScheduledTaskService.GetTaskEnabledState(fullPath, NullLogger.Instance)+ );+ }++ private static OpCall NewCall() =>+ new() { Changes = new ChangeSet(), Logger = NullLogger.Instance };}diff --git a/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs b/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.csindex a7b9933..6875286 100644--- a/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs+++ b/optimizerDuck.Test/Services/OptimizationServices/ServiceProcessServiceTests.cs@@ -376,13 +376,18 @@ public class ServiceProcessServiceTests{await StripChangeConfigFromAdminsAsync(TestServiceName);+ var call = NewCall();var result = await ServiceProcessService.ChangeServiceStartupTypeAsync(- NewCall(),+ call,new ServiceItem(TestServiceName, ServiceStartupType.Disabled));- Assert.False(result.Ok);- Assert.NotNull(result.Error);+ // Windows protects this service. That is a skip, not a failure: the call reports+ // success for the batch and records no revert step for the protected item.+ Assert.True(result.Ok, result.Error);+ var change = Assert.Single(call.Changes.Changes);+ Assert.Equal(ChangeKind.Skip, change.Kind);+ Assert.Null(change.Revert);}finally{diff --git a/optimizerDuck/Domain/Execution/ChangeSet.cs b/optimizerDuck/Domain/Execution/ChangeSet.csindex 764f0b2..dc0eb4d 100644--- a/optimizerDuck/Domain/Execution/ChangeSet.cs+++ b/optimizerDuck/Domain/Execution/ChangeSet.cs@@ -1,4 +1,4 @@-using optimizerDuck.Domain.Abstractions;+using optimizerDuck.Domain.Abstractions;using optimizerDuck.Domain.Optimizations.Models;using optimizerDuck.Services.Configuration;@@ -65,6 +65,30 @@ public sealed class ChangeSet}}+ /// <summary>+ /// Whether any step actually modified the system. Skips and irreversible actions+ /// did not leave something to undo, so they do not count as applied changes.+ /// </summary>+ public bool DidApplyAnything+ {+ get+ {+ lock (_gate)+ return _changes.Any(c => c.Ok && c.Kind == ChangeKind.Change);+ }+ }++ /// <summary>Records a step that found nothing to do, so it needs no compensation.</summary>+ public Change AddSkip(string name, string description) =>+ Add(name, description, true, kind: ChangeKind.Skip);++ /// <summary>+ /// Records a step that modified the system on purpose with no way back, so no+ /// compensation is expected for it.+ /// </summary>+ public Change AddIrreversible(string name, string description) =>+ Add(name, description, true, kind: ChangeKind.Irreversible);+/// <summary>Adds a change with an auto-incremented execution index.</summary>public Change Add(string name,@@ -73,7 +97,8 @@ public sealed class ChangeSetIRevertStep? revert = null,string? error = null,string? errorDetail = null,- Func<OpCall, Task<OpResult>>? retry = null+ Func<OpCall, Task<OpResult>>? retry = null,+ ChangeKind kind = ChangeKind.Change){var change = new Change@@ -81,6 +106,7 @@ public sealed class ChangeSetName = name,Description = description,Ok = ok,+ Kind = kind,Revert = revert,Error = error,ErrorDetail = errorDetail,@@ -133,6 +159,9 @@ public sealed record Changepublic bool Ok { get; init; }+ /// <summary>What the step did, which decides whether compensation data is expected.</summary>+ public ChangeKind Kind { get; init; } = ChangeKind.Change;+public IRevertStep? Revert { get; init; }public string? Error { get; init; }@@ -141,3 +170,19 @@ public sealed record Changepublic Func<OpCall, Task<OpResult>>? Retry { get; init; }}++/// <summary>+/// What a recorded step did to the system, which decides whether the step is expected+/// to carry the data needed to undo it. Only <see cref="Change" /> modified something.+/// </summary>+public enum ChangeKind+{+ /// <summary>The step modified the system and carries the data needed to undo it.</summary>+ Change,++ /// <summary>The step found nothing to do, so there is nothing to undo.</summary>+ Skip,++ /// <summary>The step modified the system on purpose with no way back.</summary>+ Irreversible,+}diff --git a/optimizerDuck/Domain/UI/OptimizationState.cs b/optimizerDuck/Domain/UI/OptimizationState.csindex 3e84dd7..f37b4d0 100644--- a/optimizerDuck/Domain/UI/OptimizationState.cs+++ b/optimizerDuck/Domain/UI/OptimizationState.cs@@ -53,6 +53,13 @@ public partial class OptimizationState : ObservableObject[ObservableProperty]private bool isApplied;+ /// <summary>+ /// Indicates that the last apply reported nothing to do because the machine already+ /// matched the optimization.+ /// </summary>+ [ObservableProperty]+ private bool isAlreadyOptimal;+/// <summary>/// A human-readable relative time string (e.g., "5 minutes ago")./// </summary>diff --git a/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs b/optimizerDuck/Domain/UI/OptimizationSuccessResult.csindex 2cbe170..a2a33f1 100644--- a/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs+++ b/optimizerDuck/Domain/UI/OptimizationSuccessResult.cs@@ -13,4 +13,10 @@ public enum OptimizationSuccessResult/// <summary>The operation failed entirely.</summary>Failed,++ /// <summary>+ /// Nothing needed to change because the machine already matched the optimization.+ /// No revert data exists for it.+ /// </summary>+ NothingToDo,}diff --git a/optimizerDuck/Resources/Languages/Translations.ar-SA.resx b/optimizerDuck/Resources/Languages/Translations.ar-SA.resxindex 61ce9bf..0cf5436 100644--- a/optimizerDuck/Resources/Languages/Translations.ar-SA.resx+++ b/optimizerDuck/Resources/Languages/Translations.ar-SA.resx@@ -1117,7 +1117,7 @@</data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>إخفاء المُطبَّق</value>+ <value>إخفاء العناصر المنتهية</value></data><data name="Optimizer.Menu.ViewSource" xml:space="preserve"><value>عرض الكود المصدري</value>@@ -2252,5 +2252,17 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (التكرار كل {0} لمدة {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>مُحسَّن مسبقاً</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>هذا الجهاز مطابق لهذا التحسين بالفعل، لذا لا يوجد ما يجب تغييره.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>لا شيء لتغييره: {0} مطابق لهذا الجهاز بالفعل.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>لا شيء لتغييره</value>+ </data></root>diff --git a/optimizerDuck/Resources/Languages/Translations.de-DE.resx b/optimizerDuck/Resources/Languages/Translations.de-DE.resxindex 6f44a4d..97c4739 100644--- a/optimizerDuck/Resources/Languages/Translations.de-DE.resx+++ b/optimizerDuck/Resources/Languages/Translations.de-DE.resx@@ -1088,7 +1088,7 @@ Aktualisiere jetzt, um die neuesten Funktionen, Verbesserungen und Fehlerbehebun<value>Alle sicheren abwählen</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Angewendete ausblenden</value>+ <value>Erledigte Einträge ausblenden</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Keine Ergebnisse gefunden. Versuche einen anderen Suchbegriff oder Filter.</value>@@ -2262,4 +2262,16 @@ Aktualisiere jetzt, um die neuesten Funktionen, Verbesserungen und Fehlerbehebun<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (Wiederholung alle {0} für {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Bereits optimal</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Dieser PC entspricht dieser Optimierung bereits, es gibt also nichts zu ändern.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nichts zu ändern: {0} entspricht diesem PC bereits.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nichts zu ändern</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.es-ES.resx b/optimizerDuck/Resources/Languages/Translations.es-ES.resxindex 3b6a4af..07319b0 100644--- a/optimizerDuck/Resources/Languages/Translations.es-ES.resx+++ b/optimizerDuck/Resources/Languages/Translations.es-ES.resx@@ -2078,7 +2078,7 @@ Actualiza ahora para disfrutar de las nuevas funciones y mejoras.</value><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Ocultar Aplicados</value>+ <value>Ocultar elementos finalizados</value></data>@@ -4015,4 +4015,16 @@ Actualiza ahora para disfrutar de las nuevas funciones y mejoras.</value><data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (repetir cada {0} durante {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Ya está optimizado</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Este equipo ya cumple con esta optimización, así que no hay nada que cambiar.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nada que cambiar: {0} ya cumple con este equipo.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nada que cambiar</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.fr-FR.resx b/optimizerDuck/Resources/Languages/Translations.fr-FR.resxindex 4e74c74..ec8270b 100644--- a/optimizerDuck/Resources/Languages/Translations.fr-FR.resx+++ b/optimizerDuck/Resources/Languages/Translations.fr-FR.resx@@ -1022,7 +1022,7 @@ Mettez à jour maintenant pour profiter des dernières fonctionnalités, amélio<value>Désélectionner tout ce qui est sûr</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Masquer les appliquées</value>+ <value>Masquer les éléments terminés</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Aucun résultat trouvé. Essayez un autre terme de recherche ou filtre.</value>@@ -2210,4 +2210,16 @@ Mettez à jour maintenant pour profiter des dernières fonctionnalités, amélio<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (répétition toutes les {0} pendant {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Déjà optimal</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Ce PC correspond déjà à cette optimisation, il n'y a donc rien à modifier.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Rien à modifier : {0} correspond déjà à ce PC.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Rien à modifier</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.he-IL.resx b/optimizerDuck/Resources/Languages/Translations.he-IL.resxindex 0b68cf1..e874120 100644--- a/optimizerDuck/Resources/Languages/Translations.he-IL.resx+++ b/optimizerDuck/Resources/Languages/Translations.he-IL.resx@@ -1088,7 +1088,7 @@<value>בטל בחירת כל הבטוחים</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>הסתר שהוחלו</value>+ <value>הסתר פריטים שהסתיימו</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>לא נמצאו תוצאות. יש לנסות מונח חיפוש או מסנן אחר.</value>@@ -2267,4 +2267,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (חזרה כל {0} במשך {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>כבר מיטבי</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>המחשב הזה כבר תואם את האופטימיזציה הזו, ולכן אין מה לשנות.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>אין מה לשנות: {0} כבר תואם למחשב הזה.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>אין מה לשנות</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.id-ID.resx b/optimizerDuck/Resources/Languages/Translations.id-ID.resxindex d7e5104..28605c3 100644--- a/optimizerDuck/Resources/Languages/Translations.id-ID.resx+++ b/optimizerDuck/Resources/Languages/Translations.id-ID.resx@@ -1082,7 +1082,7 @@ Perbarui sekarang untuk menikmati fitur terbaru, peningkatan, dan perbaikan bug.<value>Batal Pilih Semua (Aman)</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Sembunyikan yang Diterapkan</value>+ <value>Sembunyikan item yang selesai</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Tidak ada hasil yang ditemukan. Coba kata kunci pencarian atau filter yang berbeda.</value>@@ -2267,4 +2267,16 @@ Perbarui sekarang untuk menikmati fitur terbaru, peningkatan, dan perbaikan bug.<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (ulangi setiap {0} selama {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Sudah optimal</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>PC ini sudah sesuai dengan optimasi ini, jadi tidak ada yang perlu diubah.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Tidak ada yang perlu diubah: {0} sudah sesuai dengan PC ini.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Tidak ada yang perlu diubah</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.it-IT.resx b/optimizerDuck/Resources/Languages/Translations.it-IT.resxindex 7159118..a80f1b5 100644--- a/optimizerDuck/Resources/Languages/Translations.it-IT.resx+++ b/optimizerDuck/Resources/Languages/Translations.it-IT.resx@@ -1033,7 +1033,7 @@ Aggiorna ora per godere delle ultime funzionalità, miglioramenti e correzioni.<<value>Deseleziona tutti i sicuri</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Nascondi applicati</value>+ <value>Nascondi elementi completati</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Nessun risultato trovato. Prova un termine di ricerca o filtro diverso.</value>@@ -2218,4 +2218,16 @@ Aggiorna ora per godere delle ultime funzionalità, miglioramenti e correzioni.<<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (ripeti ogni {0} per {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Già ottimale</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Questo PC corrisponde già a questa ottimizzazione, quindi non c'è nulla da modificare.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nulla da modificare: {0} corrisponde già a questo PC.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nulla da modificare</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.ja-JP.resx b/optimizerDuck/Resources/Languages/Translations.ja-JP.resxindex 77a8c6f..9904b53 100644--- a/optimizerDuck/Resources/Languages/Translations.ja-JP.resx+++ b/optimizerDuck/Resources/Languages/Translations.ja-JP.resx@@ -1026,7 +1026,7 @@<value>安全な項目の選択をすべて解除</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>適用済みを非表示</value>+ <value>完了した項目を非表示</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>結果が見つかりません。別の検索語またはフィルターをお試しください</value>@@ -2202,4 +2202,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> ({0} ごとに {1} まで繰り返し)</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>既に最適化済み</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>この PC は既にこの最適化に一致しているため、変更する必要はありません。</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>変更はありません。{0} は既にこの PC に一致しています。</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>変更はありません</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.ko-KR.resx b/optimizerDuck/Resources/Languages/Translations.ko-KR.resxindex eda4083..4f99286 100644--- a/optimizerDuck/Resources/Languages/Translations.ko-KR.resx+++ b/optimizerDuck/Resources/Languages/Translations.ko-KR.resx@@ -1026,7 +1026,7 @@<value>안전 모두 선택 해제</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>적용 숨기기</value>+ <value>완료된 항목 숨기기</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>검색된 결과가 없습니다 다른 검색어나 필터를 사용해 보세요</value>@@ -2201,4 +2201,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> ({0}마다 {1} 동안 반복)</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>이미 최적 상태</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>이 PC는 이미 이 최적화와 일치하므로 변경할 필요가 없습니다.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>변경할 내용이 없습니다. {0}은(는) 이미 이 PC와 일치합니다.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>변경할 내용 없음</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.pl-PL.resx b/optimizerDuck/Resources/Languages/Translations.pl-PL.resxindex 3611cb8..ba28a38 100644--- a/optimizerDuck/Resources/Languages/Translations.pl-PL.resx+++ b/optimizerDuck/Resources/Languages/Translations.pl-PL.resx@@ -1027,7 +1027,7 @@ Zaktualizuj teraz, aby korzystać z najnowszych funkcji, ulepszeń i poprawek b<value>Odznacz wszystkie bezpieczne</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Ukryj zastosowane</value>+ <value>Ukryj ukończone elementy</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Nie znaleziono wyników. Spróbuj innego hasła lub filtra.</value>@@ -2210,4 +2210,16 @@ Zaktualizuj teraz, aby korzystać z najnowszych funkcji, ulepszeń i poprawek b<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (powtarzaj co {0} przez {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Już zoptymalizowane</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Ten komputer już spełnia tę optymalizację, więc nie ma nic do zmiany.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nie ma nic do zmiany: {0} już pasuje do tego komputera.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nie ma nic do zmiany</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.pt-BR.resx b/optimizerDuck/Resources/Languages/Translations.pt-BR.resxindex 3f9fa01..9e4030c 100644--- a/optimizerDuck/Resources/Languages/Translations.pt-BR.resx+++ b/optimizerDuck/Resources/Languages/Translations.pt-BR.resx@@ -1027,7 +1027,7 @@ Atualize agora para desfrutar das últimas funcionalidades, melhorias e correç<value>Desselecionar Todos Seguros</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Ocultar Aplicados</value>+ <value>Ocultar itens concluídos</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Nenhum resultado encontrado. Tente um termo de busca diferente ou filtro.</value>@@ -2210,4 +2210,16 @@ Atualize agora para desfrutar das últimas funcionalidades, melhorias e correç<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (repetir a cada {0} por {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Já está otimizado</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Este PC já corresponde a esta otimização, então não há nada para alterar.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nada para alterar: {0} já corresponde a este PC.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nada para alterar</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.resx b/optimizerDuck/Resources/Languages/Translations.resxindex 4b7fdf0..9765efc 100644--- a/optimizerDuck/Resources/Languages/Translations.resx+++ b/optimizerDuck/Resources/Languages/Translations.resx@@ -1,4 +1,4 @@-<?xml version="1.0" encoding="utf-8"?>+<?xml version="1.0" encoding="utf-8"?><root><!--Microsoft ResX Schema@@ -1182,7 +1182,7 @@ Update now to enjoy the latest features, improvements, and bug fixes.</value><value>Deselect all Safe</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Hide Applied</value>+ <value>Hide finished items</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>No results found. Try a different search term or filter.</value>@@ -2268,4 +2268,16 @@ Update now to enjoy the latest features, improvements, and bug fixes.</value><data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (repeat every {0} for {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Already optimal</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>This machine already matches this optimization, so there is nothing to change.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Nothing to change: {0} already matches this machine.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Nothing to change</value>+ </data></root>diff --git a/optimizerDuck/Resources/Languages/Translations.ru-RU.resx b/optimizerDuck/Resources/Languages/Translations.ru-RU.resxindex e64485e..352e2d4 100644--- a/optimizerDuck/Resources/Languages/Translations.ru-RU.resx+++ b/optimizerDuck/Resources/Languages/Translations.ru-RU.resx@@ -1021,7 +1021,7 @@<value>Снять все безопасные</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Скрыть примененные</value>+ <value>Скрыть завершённые элементы</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Ничего не найдено. Попробуйте другой запрос или фильтр.</value>@@ -2210,4 +2210,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (повторять каждые {0} в течение {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Уже оптимально</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Этот компьютер уже соответствует данной оптимизации, поэтому менять нечего.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Нечего менять: {0} уже соответствует этому компьютеру.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Нечего менять</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.tr-TR.resx b/optimizerDuck/Resources/Languages/Translations.tr-TR.resxindex 9fa362b..7ac118f 100644--- a/optimizerDuck/Resources/Languages/Translations.tr-TR.resx+++ b/optimizerDuck/Resources/Languages/Translations.tr-TR.resx@@ -1026,7 +1026,7 @@ En son özelliklerden, iyileştirmelerden ve hata düzeltmelerinden yararlanmak<value>Tüm Güvenli Olanların Seçimini Kaldır</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Uygulanmışları Gizle</value>+ <value>Tamamlanan öğeleri gizle</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Sonuç bulunamadı. Farklı bir arama terimi veya filtre deneyin.</value>@@ -2201,4 +2201,16 @@ En son özelliklerden, iyileştirmelerden ve hata düzeltmelerinden yararlanmak<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (her {0}, {1} boyunca tekrarla)</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Zaten en iyi durumda</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Bu bilgisayar bu iyileştirmeyle zaten uyumlu, değiştirilecek bir şey yok.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Değiştirilecek bir şey yok: {0} bu bilgisayarla zaten uyumlu.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Değiştirilecek bir şey yok</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx b/optimizerDuck/Resources/Languages/Translations.vi-VN.resxindex 595aa3d..32d9538 100644--- a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx+++ b/optimizerDuck/Resources/Languages/Translations.vi-VN.resx@@ -937,7 +937,7 @@ Cập nhật ngay để trải nghiệm các tính năng mới, cải tiến và<value>Bỏ chọn tất cả an toàn</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>Ẩn đã áp dụng</value>+ <value>Ẩn mục đã xong</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>Không tìm thấy kết quả. Hãy thử từ khóa hoặc bộ lọc khác.</value>@@ -2202,4 +2202,16 @@ Cập nhật ngay để trải nghiệm các tính năng mới, cải tiến và<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (lặp lại mỗi {0} trong {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>Đã đúng sẵn</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>Máy bạn đã ở đúng cấu hình này, nên không có gì cần thay đổi.</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>Không cần thay đổi: {0} đã đúng với máy này.</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>Không cần thay đổi</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.zh-CN.resx b/optimizerDuck/Resources/Languages/Translations.zh-CN.resxindex 64377b7..d37199c 100644--- a/optimizerDuck/Resources/Languages/Translations.zh-CN.resx+++ b/optimizerDuck/Resources/Languages/Translations.zh-CN.resx@@ -1069,7 +1069,7 @@<value>取消全选安全项</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>隐藏已应用项</value>+ <value>隐藏已完成的项目</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>未找到结果,请更换搜索词或筛选条件。</value>@@ -2218,4 +2218,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (每 {0} 重复, 持续 {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>已是最佳状态</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>此电脑已符合此项优化,无需更改。</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>无需更改:{0} 已与此电脑匹配。</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>无需更改</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Resources/Languages/Translations.zh-TW.resx b/optimizerDuck/Resources/Languages/Translations.zh-TW.resxindex 6acc9c0..9ce73fe 100644--- a/optimizerDuck/Resources/Languages/Translations.zh-TW.resx+++ b/optimizerDuck/Resources/Languages/Translations.zh-TW.resx@@ -741,7 +741,7 @@<value>取消選取所有安全項目</value></data><data name="Optimizer.Menu.HideApplied" xml:space="preserve">- <value>隱藏已套用</value>+ <value>隱藏已完成的項目</value></data><data name="Bloatware.Search.NoResults" xml:space="preserve"><value>找不到結果。請嘗試其他搜尋詞或過濾器。</value>@@ -2205,4 +2205,16 @@<data name="ScheduledTasks.TriggerDetail.RepeatFor" xml:space="preserve"><value> (每 {0} 重複, 持續 {1})</value></data>+ <data name="Optimizer.UI.State.AlreadyOptimal" xml:space="preserve">+ <value>已是最佳狀態</value>+ </data>+ <data name="Optimizer.UI.State.AlreadyOptimal.Tooltip" xml:space="preserve">+ <value>此電腦已符合此項最佳化,無需變更。</value>+ </data>+ <data name="Optimization.Apply.NothingToDo" xml:space="preserve">+ <value>無需變更:{0} 已與此電腦相符。</value>+ </data>+ <data name="Optimization.Apply.Snackbar.NothingToDo.Title" xml:space="preserve">+ <value>無需變更</value>+ </data></root>\ No newline at end of filediff --git a/optimizerDuck/Services/Optimization/OptimizationService.cs b/optimizerDuck/Services/Optimization/OptimizationService.csindex 65182e5..74d90a7 100644--- a/optimizerDuck/Services/Optimization/OptimizationService.cs+++ b/optimizerDuck/Services/Optimization/OptimizationService.cs@@ -294,7 +294,9 @@ public class OptimizationService(};}- if (!changes.HasSuccessfulSteps)+ // Every recorded step failed: nothing changed and nothing succeeded, so it stays a+ // failure with the failure dialog as before.+ if (changes.Changes.Count > 0 && !changes.HasSuccessfulSteps){return new OptimizationResult{@@ -304,6 +306,23 @@ public class OptimizationService(};}+ // Nothing to do: the provider reported success but no step changed the system, either+ // because there was nothing to change or because every recorded step was a skip. No+ // revert data exists for it, and the card is marked for this session only.+ if (!changes.DidApplyAnything)+ {+ _logger.LogInformation(+ "Apply of {OptimizationKey} changed nothing, reporting nothing to do",+ optimization.OptimizationKey+ );+ return new OptimizationResult+ {+ Status = OptimizationSuccessResult.NothingToDo,+ Message = Loc.Instance["Optimization.Apply.NothingToDo", optimization.Name],+ FailedSteps = failedSteps,+ };+ }+var failedCount = failedSteps.Count;return new OptimizationResult{@@ -578,7 +597,7 @@ public class OptimizationService(CancellationToken cancellationToken = default){- if (!changes.HasSuccessfulSteps)+ if (!changes.DidApplyAnything)return;trydiff --git a/optimizerDuck/Services/Revert/RevertManager.cs b/optimizerDuck/Services/Revert/RevertManager.csindex 9584c63..57a215d 100644--- a/optimizerDuck/Services/Revert/RevertManager.cs+++ b/optimizerDuck/Services/Revert/RevertManager.cs@@ -1,4 +1,4 @@-using System.Collections.Concurrent;+using System.Collections.Concurrent;using System.IO;using System.Reflection;using System.Text;@@ -50,6 +50,20 @@ public class RevertManager(.OrderBy(c => c.Index).ToList();+ // A step that modified the system must carry the data needed to undo it. The filter+ // above drops entries without compensation, so a Change arriving here without one is a+ // provider defect rather than a legitimate skip.+ foreach (+ var defect in changes.Changes.Where(c =>+ c.Ok && c.Kind == ChangeKind.Change && c.Revert == null+ )+ )+ _logger.LogWarning(+ "Recorded change {Step} for {Name} carries no revert data, so undo does not cover it",+ defect.Name,+ name+ );+if (incoming.Count == 0)return;diff --git a/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs b/optimizerDuck/Services/System/Primitives/PowerPlanChanges.csindex 0fa1ee3..b083a67 100644--- a/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs+++ b/optimizerDuck/Services/System/Primitives/PowerPlanChanges.cs@@ -43,10 +43,9 @@ public static class PowerPlanChangesif (previousId is null || previousId.Value == schemeId){- call.Changes.Add(+ call.Changes.AddSkip(ServiceStrings.PowerPlanName,- ServiceStrings.Format("Power plan {0} already active (skipped)", name),- true+ ServiceStrings.Format("Power plan {0} already active (skipped)", name));return OpResult.Success();}diff --git a/optimizerDuck/Services/System/Primitives/RegistryService.cs b/optimizerDuck/Services/System/Primitives/RegistryService.csindex e1dfa6f..ef98775 100644--- a/optimizerDuck/Services/System/Primitives/RegistryService.cs+++ b/optimizerDuck/Services/System/Primitives/RegistryService.cs@@ -1,4 +1,4 @@-using System.Diagnostics.CodeAnalysis;+using System.Diagnostics.CodeAnalysis;using System.Globalization;using System.IO;using System.Security;@@ -394,7 +394,7 @@ public static class RegistryServiceitem.Path,item.Name!);- call.Changes.Add(name, description, true);+ call.Changes.AddSkip(name, description);return OpResult.Success();}@@ -531,7 +531,7 @@ public static class RegistryServiceitem.Path,item.Name!);- call.Changes.Add(name, description, true);+ call.Changes.AddSkip(name, description);return OpResult.Success();}@@ -644,7 +644,7 @@ public static class RegistryServiceif (regKey != null){logger.LogInformation("Skip create registry {Path} (already exists)", item.Path);- call.Changes.Add(name, description, true);+ call.Changes.AddSkip(name, description);return OpResult.Success();}@@ -722,7 +722,7 @@ public static class RegistryServiceif (regKey == null){logger.LogInformation("Skip delete registry key {Path} (not found)", item.Path);- call.Changes.Add(name, description, true);+ call.Changes.AddSkip(name, description);return OpResult.Success();}diff --git a/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs b/optimizerDuck/Services/System/Primitives/ScheduledTaskService.csindex 1828f5e..c08d05d 100644--- a/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs+++ b/optimizerDuck/Services/System/Primitives/ScheduledTaskService.cs@@ -1,4 +1,4 @@-using System.Collections.ObjectModel;+using System.Collections.ObjectModel;using System.Globalization;using Microsoft.Extensions.Logging;using Microsoft.Win32.TaskScheduler;@@ -63,17 +63,27 @@ public static class ScheduledTaskServiceLoc.Instance["ScheduledTasks.Error.TaskNotFound", fullPath]);- var wasEnabled = task.Enabled;- task.Enabled = false;+ if (!task.Enabled)+ {+ // Already disabled: nothing to write, so there is nothing to undo either.+ call.Logger.LogInformation("Task {Path} is already disabled, skipping", fullPath);+ call.Changes.AddSkip(+ ServiceStrings.ScheduledTaskName,+ ServiceStrings.Format(+ ServiceStrings.ScheduledTaskInfoAlreadyConfigured,+ fullPath,+ "disabled"+ )+ );+ return OpResult.Success();+ }- // Record revert step: restore to previous enabled state- ScheduledTaskRevertStep? revertStep = null;- if (wasEnabled)- revertStep = new ScheduledTaskRevertStep- {- FullPath = fullPath,- OriginalEnabled = true,- };+ task.Enabled = false;+ var revertStep = new ScheduledTaskRevertStep+ {+ FullPath = fullPath,+ OriginalEnabled = true,+ };call.Logger.LogInformation("Disabled task {Path}", fullPath);call.Changes.Add(ServiceStrings.ScheduledTaskName, description, true, revertStep);@@ -139,17 +149,27 @@ public static class ScheduledTaskServiceLoc.Instance["ScheduledTasks.Error.TaskNotFound", fullPath]);- var wasEnabled = task.Enabled;- task.Enabled = true;+ if (task.Enabled)+ {+ // Already enabled: nothing to write, so there is nothing to undo either.+ call.Logger.LogInformation("Task {Path} is already enabled, skipping", fullPath);+ call.Changes.AddSkip(+ ServiceStrings.ScheduledTaskName,+ ServiceStrings.Format(+ ServiceStrings.ScheduledTaskInfoAlreadyConfigured,+ fullPath,+ "enabled"+ )+ );+ return OpResult.Success();+ }- // Record revert step: restore to previous enabled state- ScheduledTaskRevertStep? revertStep = null;- if (!wasEnabled)- revertStep = new ScheduledTaskRevertStep- {- FullPath = fullPath,- OriginalEnabled = false,- };+ task.Enabled = true;+ var revertStep = new ScheduledTaskRevertStep+ {+ FullPath = fullPath,+ OriginalEnabled = false,+ };call.Logger.LogInformation("Enabled task {Path}", fullPath);call.Changes.Add(ServiceStrings.ScheduledTaskName, description, true, revertStep);@@ -251,7 +271,7 @@ public static class ScheduledTaskService);task.Run();call?.Logger.LogInformation("Started task {Path}", fullPath);- call?.Changes.Add(ServiceStrings.ScheduledTaskName, description, true);+ call?.Changes.AddIrreversible(ServiceStrings.ScheduledTaskName, description);return OpResult.Success();}catch (Exception ex)@@ -291,7 +311,7 @@ public static class ScheduledTaskService);task.Stop();call?.Logger.LogInformation("Stopped task {Path}", fullPath);- call?.Changes.Add(ServiceStrings.ScheduledTaskName, description, true);+ call?.Changes.AddIrreversible(ServiceStrings.ScheduledTaskName, description);return OpResult.Success();}catch (Exception ex)@@ -354,7 +374,7 @@ public static class ScheduledTaskServicevar folderPath = task.Folder.Path;ts.GetFolder(folderPath).DeleteTask(task.Name);call?.Logger.LogInformation("Deleted task {Path}", fullPath);- call?.Changes.Add(ServiceStrings.ScheduledTaskName, description, true);+ call?.Changes.AddIrreversible(ServiceStrings.ScheduledTaskName, description);return OpResult.Success();}catch (Exception ex)@@ -454,7 +474,7 @@ public static class ScheduledTaskServicemodel.Name,folderPath);- call?.Changes.Add(ServiceStrings.ScheduledTaskName, description, true);+ call?.Changes.AddIrreversible(ServiceStrings.ScheduledTaskName, description);return OpResult.Success();}catch (Exception ex)diff --git a/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs b/optimizerDuck/Services/System/Primitives/ServiceProcessService.csindex 1a2ea53..33b2cdd 100644--- a/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs+++ b/optimizerDuck/Services/System/Primitives/ServiceProcessService.cs@@ -1,4 +1,4 @@-using System.Diagnostics;+using System.Diagnostics;using System.Runtime.InteropServices;using Microsoft.Extensions.Logging;using optimizerDuck.Common.Extensions;@@ -73,7 +73,7 @@ public static class ServiceProcessServiceitem.Name);call.Logger.LogInformation("[SERVICE][{Name}] not found, skipping", item.Name);- call.Changes.Add(ServiceStrings.ServiceName, skipDescription, true);+ call.Changes.AddSkip(ServiceStrings.ServiceName, skipDescription);return MapToOpResult(ServiceChangeResult.NotFound, null, null, null);}@@ -111,7 +111,7 @@ public static class ServiceProcessServiceitem.Name,item.StartupType);- call.Changes.Add(ServiceStrings.ServiceName, alreadyDescription, true);+ call.Changes.AddSkip(ServiceStrings.ServiceName, alreadyDescription);return MapToOpResult(ServiceChangeResult.AlreadyConfigured, null, null, null);}@@ -156,14 +156,7 @@ public static class ServiceProcessServiceitem.Name,sw.Elapsed.FormatTime());- call.Changes.Add(- ServiceStrings.ServiceName,- description,- false,- null,- accessDeniedError,- errorDetail- );+ call.Changes.AddSkip(ServiceStrings.ServiceName, accessDeniedError);return MapToOpResult(ServiceChangeResult.AccessDenied,null,@@ -234,8 +227,9 @@ public static class ServiceProcessService/// <summary>/// Maps the compat <see cref="ServiceChangeResult"/> outcome to an <see cref="OpResult"/>.- /// NotFound and AlreadyConfigured are informational successes; AccessDenied and- /// Failed carry an error naming the service.+ /// Success, NotFound, AlreadyConfigured and AccessDenied are informational outcomes,+ /// because a refusal by Windows is a skip rather than a failure; only Failed carries an+ /// error naming the service./// </summary>private static OpResult MapToOpResult(ServiceChangeResult outcome,@@ -248,7 +242,8 @@ public static class ServiceProcessService{ServiceChangeResult.Successor ServiceChangeResult.NotFound- or ServiceChangeResult.AlreadyConfigured => OpResult.Success(revert),+ or ServiceChangeResult.AlreadyConfigured+ or ServiceChangeResult.AccessDenied => OpResult.Success(revert),_ => OpResult.Fail(error ?? ServiceStrings.ServiceErrorChangeStartupTypeFailed,errorDetaildiff --git a/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml b/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xamlindex ef62ad0..2dfe91a 100644--- a/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml+++ b/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml@@ -346,7 +346,30 @@VerticalAlignment="Bottom"ColumnDefinitions="*,Auto"><Grid RowDefinitions="Auto,Auto">- <controls:RiskBadge HorizontalAlignment="Left" Risk="{Binding Risk}" RiskVisual="{Binding RiskVisual}" />+ <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">+ <controls:RiskBadge Risk="{Binding Risk}" RiskVisual="{Binding RiskVisual}" />+ <Border+ Margin="6,0,0,0"+ Padding="6,2"+ Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}"+ CornerRadius="{StaticResource CornerRadiusSmall}"+ ToolTip="{ext:Loc Optimizer.UI.State.AlreadyOptimal.Tooltip}"+ ToolTipService.InitialShowDelay="150"+ ToolTipService.Placement="Top"+ Visibility="{Binding State.IsAlreadyOptimal, Converter={StaticResource BooleanToVisibilityConverter}}">+ <StackPanel Orientation="Horizontal">+ <ui:SymbolIcon+ Margin="0,0,6,0"+ FontSize="14"+ Foreground="{DynamicResource SystemFillColorSuccessBrush}"+ Symbol="CheckmarkCircle24" />+ <ui:TextBlock+ VerticalAlignment="Center"+ FontTypography="Caption"+ Text="{ext:Loc Optimizer.UI.State.AlreadyOptimal}" />+ </StackPanel>+ </Border>+ </StackPanel><BorderGrid.Row="1"diff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.csindex 9e69490..0ebcd3c 100644--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.Dialogs.cs@@ -1,4 +1,4 @@-namespace optimizerDuck.UI.ViewModels.Optimizer;+namespace optimizerDuck.UI.ViewModels.Optimizer;using System.Collections.ObjectModel;using System.ComponentModel;@@ -172,6 +172,9 @@ public partial class OptimizationCategoryViewModel)return OperationNotificationState.Success;+ if (applyResult.Status == OptimizationSuccessResult.NothingToDo)+ return OperationNotificationState.NothingToDo;+return retryOutcome == FailureResolutionOutcome.Deferred? OperationNotificationState.Partial: OperationNotificationState.Failed;@@ -208,7 +211,20 @@ public partial class OptimizationCategoryViewModel"\n"+ Loc.Instance["RestorePoint.Snackbar.Success.Message", Shared.RestorePointName];- if (notificationState == OperationNotificationState.Success)+ if (notificationState == OperationNotificationState.NothingToDo)+ {+ // Respects the completion notification setting like the success path, because the+ // card already carries the mark when the toast is turned off.+ if (showSuccess)+ _snackbarService.Show(+ Loc.Instance["Optimization.Apply.Snackbar.NothingToDo.Title"],+ finalMessage,+ ControlAppearance.Info,+ new SymbolIcon { Symbol = SymbolRegular.Info24, Filled = true },+ TimeSpan.FromSeconds(5)+ );+ }+ else if (notificationState == OperationNotificationState.Success){if (showSuccess)_snackbarService.Show(@@ -406,6 +422,7 @@ public partial class OptimizationCategoryViewModelSuccess,Partial,Failed,+ NothingToDo,}private enum OptimizationOperationdiff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.csindex f1ef47a..7a036f2 100644--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs@@ -1,4 +1,4 @@-using System.Collections.ObjectModel;+using System.Collections.ObjectModel;using System.ComponentModel;using System.Windows;using System.Windows.Controls;@@ -101,7 +101,8 @@ public partial class OptimizationCategoryViewModel : ViewModel#region Filter & Search- public bool HasAppliedOptimizations => _allOptimizations.Any(o => o.State.IsApplied);+ public bool HasAppliedOptimizations =>+ _allOptimizations.Any(o => o.State.IsApplied || o.State.IsAlreadyOptimal);partial void OnSearchTextChanged(string value) => ScheduleApplyFilter();@@ -253,6 +254,30 @@ public partial class OptimizationCategoryViewModel : ViewModelreturn;}+ // Nothing to do changed nothing, so the card is marked for this session and the+ // pending changes prompt stays untouched.+ optimization.State.IsAlreadyOptimal =+ applyResult.Status == OptimizationSuccessResult.NothingToDo;++ if (applyResult.Status == OptimizationSuccessResult.NothingToDo)+ {+ await FinalizeOperationAsync(optimization);+ OnPropertyChanged(nameof(HasAppliedOptimizations));+ ShowOperationOutcomeSnackbar(+ OperationNotificationState.NothingToDo,+ OptimizationOperation.Apply,+ applyResult.Message,+ restorePointCreated+ );+ LogOperationOutcome(OperationNotificationState.NothingToDo, "apply", optimization);+ _logger.LogInformation(+ "===== END applying {Name} ({Id}) =====",+ optimization.OptimizationKey,+ optimization.Id+ );+ return;+ }+if (Application.Current is App app)app.HasPendingChanges = true;@@ -297,6 +322,9 @@ public partial class OptimizationCategoryViewModel : ViewModelp => _optimizationService.RevertAsync(optimization, p));+ // Reverting means the machine no longer matches, whatever an earlier apply reported.+ optimization.State.IsAlreadyOptimal = false;+if (Application.Current is App app)app.HasPendingChanges = true;@@ -339,6 +367,7 @@ public partial class OptimizationCategoryViewModel : ViewModel{var level =notificationState == OperationNotificationState.Success ? LogLevel.Information+ : notificationState == OperationNotificationState.NothingToDo ? LogLevel.Information: notificationState == OperationNotificationState.Partial ? LogLevel.Warning: LogLevel.Warning;@@ -351,6 +380,8 @@ public partial class OptimizationCategoryViewModel : ViewModelvar message =notificationState == OperationNotificationState.Success ? $"Successfully {pastTense}"+ : notificationState == OperationNotificationState.NothingToDo+ ? $"Nothing to {operationName} for": notificationState == OperationNotificationState.Partial ? $"Partially {pastTense}": $"Failed to {operationName}";@@ -523,9 +554,9 @@ public partial class OptimizationCategoryViewModel : ViewModel_ => query,};- // Hide applied+ // Hide applied and already optimal itemsif (HideApplied)- query = query.Where(o => !o.State.IsApplied);+ query = query.Where(o => !o.State.IsApplied && !o.State.IsAlreadyOptimal);// Sortquery = SelectedSortByIndex switch