With init-only properties, the source-generated reader set a property missing from settings.json to its default value, not its initializer, so the file failed validation and every setting fell back to defaults. Any release that adds a setting would have reset all user settings. Settings use settable properties now, and the snapshot's version field too; the other persisted types were checked and keep their defaults. Refs #1
This commit is contained in:
@@ -4,26 +4,28 @@ namespace FinalToken.Core;
|
||||
|
||||
public sealed record ProviderSettings
|
||||
{
|
||||
public bool Enabled { get; init; } = true;
|
||||
public bool PopupsEnabled { get; init; } = true;
|
||||
public bool PopupAhead { get; init; } = true;
|
||||
public bool PopupBehind { get; init; } = true;
|
||||
public string? CliPath { get; init; }
|
||||
// Setters let source-generated JSON construct defaults before assigning present properties.
|
||||
public bool Enabled { get; set; } = true;
|
||||
public bool PopupsEnabled { get; set; } = true;
|
||||
public bool PopupAhead { get; set; } = true;
|
||||
public bool PopupBehind { get; set; } = true;
|
||||
public string? CliPath { get; set; }
|
||||
}
|
||||
|
||||
public sealed record Settings
|
||||
{
|
||||
public TimeSpan RefreshInterval { get; init; } = TimeSpan.FromSeconds(60);
|
||||
public TimeSpan ProbeInterval { get; init; } = TimeSpan.FromMinutes(5);
|
||||
public double PaceThreshold { get; init; } = 10;
|
||||
public bool PopupAhead { get; init; } = true;
|
||||
public bool PopupBehind { get; init; } = true;
|
||||
public InstallMode StreamDeckInstallMode { get; init; } = InstallMode.Ask;
|
||||
public string? DismissedPluginVersion { get; init; }
|
||||
public bool StartWithOs { get; init; }
|
||||
public bool CloseToTray { get; init; } = true;
|
||||
public ProviderSettings Claude { get; init; } = new();
|
||||
public ProviderSettings Codex { get; init; } = new();
|
||||
// Preserve initializers when an older file lacks newly added properties (D5).
|
||||
public TimeSpan RefreshInterval { get; set; } = TimeSpan.FromSeconds(60);
|
||||
public TimeSpan ProbeInterval { get; set; } = TimeSpan.FromMinutes(5);
|
||||
public double PaceThreshold { get; set; } = 10;
|
||||
public bool PopupAhead { get; set; } = true;
|
||||
public bool PopupBehind { get; set; } = true;
|
||||
public InstallMode StreamDeckInstallMode { get; set; } = InstallMode.Ask;
|
||||
public string? DismissedPluginVersion { get; set; }
|
||||
public bool StartWithOs { get; set; }
|
||||
public bool CloseToTray { get; set; } = true;
|
||||
public ProviderSettings Claude { get; set; } = new();
|
||||
public ProviderSettings Codex { get; set; } = new();
|
||||
public ProviderSettings For(Provider provider) => provider == Provider.Claude ? Claude : Codex;
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsValid => RefreshInterval > TimeSpan.Zero && RefreshInterval <= TimeSpan.FromSeconds(60) &&
|
||||
|
||||
Reference in New Issue
Block a user