7559b4af5a
v1.7.1 changed the shipped default CPU assignment mode to AffinityMask because Automatic applies only Windows CPU Sets, a soft scheduling preference that leaves the affinity mask in Task Manager unchanged. A new default only reaches a profile that has no stored value, so every upgrading user kept Automatic and still saw an affinity feature that appeared to do nothing. Confirmed against the published 1.7.1 build: a fresh profile started on AffinityMask, an existing one stayed on Automatic. CpuAssignmentModeMigrationPolicy moves a stored Automatic to AffinityMask once per profile and records that it ran. Two flags are needed, not one: without the "seen" flag a user who closes the app before acknowledging the change would never learn of it, and without the "migrated" flag a later deliberate return to Automatic would be undone on the next launch. Both cases are covered by tests. The change is announced through an overlay modelled on the existing startup suggestion, so it is the app's own dialog rather than a system message box, and it is translated into all seven supported languages. It is queued rather than stacked when the startup suggestion is already up, and takes keyboard focus. Persistence is deliberately non-fatal: a failed write is retried on the next launch, where previously it would have fallen into the load handler's catch and replaced the profile just loaded with defaults, silently swallowing the notice. An out-of-range stored mode now repairs to the shipped default instead of Automatic, so corrupt data is not reported back to the user as a choice they made. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AhS1xyuMPFvxrojERQ4NuY
58 lines
2.5 KiB
C#
58 lines
2.5 KiB
C#
namespace ThreadPilot.Helpers
|
|
{
|
|
using System;
|
|
using ThreadPilot.Models;
|
|
|
|
/// <summary>
|
|
/// v1.7.1 changed the shipped default CPU assignment mode from <see cref="CpuAssignmentMode.Automatic"/>
|
|
/// to <see cref="CpuAssignmentMode.AffinityMask"/>, because Automatic applies only Windows CPU Sets:
|
|
/// a soft scheduling preference that leaves the affinity mask shown in Task Manager unchanged.
|
|
/// A persisted setting always wins over a new default, so everyone upgrading kept the mode that
|
|
/// made the affinity feature look like it did nothing. Move them once, and tell them it happened.
|
|
/// </summary>
|
|
public static class CpuAssignmentModeMigrationPolicy
|
|
{
|
|
/// <summary>
|
|
/// Runs the one-time migration. Returns true when the profile was modified and must be
|
|
/// persisted - including the case where only the completion flags changed. Persisting those
|
|
/// matters: without them a profile is migrated again on the next launch, which would undo a
|
|
/// deliberate return to <see cref="CpuAssignmentMode.Automatic"/>.
|
|
/// </summary>
|
|
public static bool Apply(ApplicationSettingsModel settings)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
|
|
if (settings.HasMigratedCpuAssignmentModeDefault)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
settings.HasMigratedCpuAssignmentModeDefault = true;
|
|
|
|
if (settings.DefaultCpuAssignmentMode != CpuAssignmentMode.Automatic)
|
|
{
|
|
// Nothing changed for this user, so there is nothing to tell them about - but the
|
|
// completion flags still have to reach disk.
|
|
settings.HasSeenCpuAssignmentModeChangeNotice = true;
|
|
return true;
|
|
}
|
|
|
|
settings.DefaultCpuAssignmentMode = CpuAssignmentMode.AffinityMask;
|
|
settings.HasSeenCpuAssignmentModeChangeNotice = false;
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// True while the migration has moved this profile but the user has not acknowledged it yet.
|
|
/// Surviving a restart matters here: the notice is the only thing telling them their mode changed.
|
|
/// </summary>
|
|
public static bool ShouldShowNotice(ApplicationSettingsModel settings)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
|
|
return settings.HasMigratedCpuAssignmentModeDefault
|
|
&& !settings.HasSeenCpuAssignmentModeChangeNotice;
|
|
}
|
|
}
|
|
}
|