fix: keep a completion status until it fades, not until the finally

Success was invisible while failure stayed on screen. An apply set its result
with SetStatus(message, isBusyState: false), and the operation's own finally
called ClearStatus, which blanked it before it could be read; failures go
through SetCriticalStatus, which is preserved. The only surviving signal was
the toast, and success toasts are exactly what users switch off.

Fixed in ClearStatus rather than in the callers: the affinity path had already
lost its ClearStatus, but priority, memory priority, I/O priority and registry
enforcement all route through the same finally and were still silent. A
completion message is not busy state and already carries its own fade
lifetime, so clearing it there was never right for any caller.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
PrimeBuild-pc
2026-08-26 22:27:38 +02:00
committed by Prime Build
parent c8826547e2
commit b3cd418864
2 changed files with 39 additions and 0 deletions
@@ -17,6 +17,32 @@ namespace ThreadPilot.Core.Tests
Assert.False(viewModel.IsBusy);
}
[Fact]
public void ClearStatus_KeepsACompletionMessage()
{
// The regression this covers: an apply succeeded, set its status, and the operation's
// own finally wiped it before the user could read it - while failures stayed up.
var viewModel = new TestViewModel();
viewModel.SetCompletion("CPU assignment applied successfully to cs2 using AffinityMask.");
viewModel.Clear();
Assert.Equal("CPU assignment applied successfully to cs2 using AffinityMask.", viewModel.StatusMessage);
Assert.False(viewModel.IsBusy);
}
[Fact]
public void ClearStatus_StillClearsAProgressMessage()
{
var viewModel = new TestViewModel();
viewModel.SetProgress("Setting affinity for cs2...");
viewModel.Clear();
Assert.Equal(string.Empty, viewModel.StatusMessage);
Assert.False(viewModel.IsBusy);
}
private sealed class TestViewModel : BaseViewModel
{
public TestViewModel()
@@ -26,6 +52,10 @@ namespace ThreadPilot.Core.Tests
public void SetCritical(string message) => this.SetCriticalStatus(message);
public void SetCompletion(string message) => this.SetStatus(message, false);
public void SetProgress(string message) => this.SetStatus(message);
public void Clear() => this.ClearStatus();
}
}
+9
View File
@@ -77,6 +77,15 @@ namespace ThreadPilot.ViewModels
return;
}
// A completion message is not busy state: SetStatus(..., isBusyState: false) already
// gave it a fade lifetime of its own. Blanking it here is what made every successful
// apply vanish instantly, while failures - which take the preserved path above - stayed
// on screen. Clearing belongs to progress messages only.
if (!this.IsBusy && !string.IsNullOrEmpty(this.StatusMessage))
{
return;
}
this.CancelStatusLifetime();
this.StatusMessage = string.Empty;
this.StatusOpacity = 1.0;