feat(settings): make every Settings row real; archive settings, index backups and restore
Settings (UI-01, UI-02, UI-03, UI-09, RF-4): - New Import, Analysis and Formats pages, in the order of Settings.html. Import holds the defaults of new cards (session rules, subfolders, verification, duplicates, after-import actions); Analysis the deep-analysis width cap, night and star-field thresholds and deep analysis after import or scan; Formats the decode tier of every format on this PC with a notice and Store install link per missing codec extension. - Archive gains thumbnail size and rescan interval; its templates, proxy size and thumbnail size are the open archive's own (archive.json) and new archives' defaults. - Rendering quality, parallelism and background priority now drive the jobs: quality maps to preparation size, read-ahead and default flow quality; parallelism sets the engine's workers live and caps per-job threads; background priority raises the UI thread while Titano is in front. - Advanced gains Restore (daily backups, dry-run summary, destructive confirmation, staged for the next start) and Reset all. - The naming preview's sample title is a catalog string. Engine (ENG-03, ENG-04, ENG-06): - ArchiveService.GetSettingsAsync/UpdateSettingsAsync rewrite archive.json atomically under a lease, then the index row; the server endpoint and the desktop use them, and the desktop creates archives with Settings › Archive. ThumbnailPolicy in archive.json sizes the thumbnails. - DatabaseBackups: daily VACUUM INTO copies kept x3 on the desktop and on a server on SQLite (DatabaseBackupService), staged restore checked and preceded by a fresh copy. - Maintenance vacuums the SQLite index when 10 % or more is free (dry run reports it). - JobEngine.SetWorkers; ProcessingOptions.Tune applies host tuning per job. Archive setup toasts say why in a localized sentence (RF-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
91 files changed
+2864
-357
No files matched your search
@@ -164,6 +164,125 @@ public sealed class SettingsLogicTests
|
||||
Assert.Null(EncoderUse.Codecs([]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThePreviewTitleSpeaksTheInterfaceLanguage()
|
||||
{
|
||||
// The sample's title is a catalog string read on every preview (so a language switch shows at once), not English text.
|
||||
Assert.Equal("Harbour sunset", NamingPreview.FirstNames("{title}", "{n:0000}")[0].Split('/')[0]);
|
||||
Assert.Equal("Harbour sunset", NamingPreview.SampleFrames[0].Title);
|
||||
Assert.False(ReferenceEquals(NamingPreview.SampleFrames, NamingPreview.SampleFrames), "built on each call");
|
||||
var italian = Loc.Get("Settings.Naming.SampleTitle", CultureInfo.GetCultureInfo("it"));
|
||||
Assert.True(italian is { Length: > 0 } && italian != "Harbour sunset", italian);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheQualityProfileTunesTheJobs()
|
||||
{
|
||||
var settings = new Titano.App.Infrastructure.AppSettings { Quality = Titano.App.Infrastructure.QualityProfile.Best, Parallelism = 3, MemoryBudgetGb = 6 };
|
||||
var basis = new Titano.Data.Processing.ProcessingOptions();
|
||||
|
||||
var best = ProcessingTuning.Apply(basis, settings, 64L << 30, 16, @"C:\cache");
|
||||
Assert.Equal((6L << 30, @"C:\cache", 8, 2), (best.FrameWindow.MemoryBudget, best.FrameWindow.SpillDirectory, best.FrameWindow.Ahead, best.FrameWindow.MaxConcurrentLoads));
|
||||
Assert.Equal((1024, Titano.Core.Project.FlowQualitySetting.Best), (best.Render.AnalysisLongEdge, best.Render.DefaultFlowQuality));
|
||||
Assert.Equal(int.Min(3, Titano.Core.Analysis.Deep.DeepAnalysisOptions.Default.MaxDegreeOfParallelism), best.DeepAnalysis.MaxDegreeOfParallelism);
|
||||
|
||||
settings.Quality = Titano.App.Infrastructure.QualityProfile.Fast;
|
||||
settings.MemoryBudgetGb = null;
|
||||
settings.Parallelism = null;
|
||||
var fast = ProcessingTuning.Apply(basis, settings, 32L << 30, 16, @"C:\cache");
|
||||
Assert.Equal((8L << 30, 4), (fast.FrameWindow.MemoryBudget, fast.FrameWindow.Ahead));
|
||||
Assert.Equal((256, Titano.Core.Project.FlowQualitySetting.Draft), (fast.Render.AnalysisLongEdge, fast.Render.DefaultFlowQuality));
|
||||
Assert.Equal(512, ProcessingTuning.PreparationLongEdge(Titano.App.Infrastructure.QualityProfile.Balanced));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParallelismAutoLeavesFourCoresToTheInterface()
|
||||
{
|
||||
Assert.Equal(12, ProcessingTuning.ParallelismAuto(16));
|
||||
Assert.Equal(1, ProcessingTuning.ParallelismAuto(4));
|
||||
Assert.Equal(1, ProcessingTuning.ParallelismAuto(2));
|
||||
Assert.Equal(12, ProcessingTuning.Parallelism(new Titano.App.Infrastructure.AppSettings(), 16));
|
||||
Assert.Equal(5, ProcessingTuning.Parallelism(new Titano.App.Infrastructure.AppSettings { Parallelism = 5 }, 16));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheAnalysisSettingsBecomeTheDeepAnalysisParameters()
|
||||
{
|
||||
var defaults = new Titano.App.Infrastructure.AppSettings().DeepAnalysis(Titano.Core.Analysis.Deep.DeepAnalysisOptions.Default);
|
||||
// The defaults of Settings › Analysis are the engine's own: nothing changes until the user does.
|
||||
Assert.Equal(Titano.Core.Analysis.Deep.DeepAnalysisOptions.Default.Fingerprint(), defaults.Fingerprint());
|
||||
Assert.Equal(Titano.Core.Analysis.Deep.DeepAnalysisOptions.Default.StarFieldDensity, defaults.StarFieldDensity);
|
||||
|
||||
var tuned = new Titano.App.Infrastructure.AppSettings { AnalysisLongEdge = 1024, NightBrightnessPercent = 12.5, StarFieldDensity = 60 }
|
||||
.DeepAnalysis(Titano.Core.Analysis.Deep.DeepAnalysisOptions.Default);
|
||||
Assert.Equal((1024, -3.0, 60.0), (tuned.MaxAnalysisLongEdge, tuned.DarkLogLuminance, tuned.StarFieldDensity));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewCardsStartFromSettingsImport()
|
||||
{
|
||||
var settings = new Titano.App.Infrastructure.AppSettings
|
||||
{
|
||||
ImportSessionGapMinutes = 90,
|
||||
ImportMinimumFrames = 20,
|
||||
ImportSubfolders = false,
|
||||
ImportVerify = false,
|
||||
ImportDuplicates = Titano.Core.Import.DuplicatePolicy.ImportAgain,
|
||||
ImportAfter = Titano.Data.Archiving.AfterImport.DeleteImported,
|
||||
ImportEject = false,
|
||||
DeepAnalysisAfterImport = false,
|
||||
};
|
||||
var profile = settings.ImportProfile("{year}", "{name}");
|
||||
Assert.Equal(("{year}", "{name}", 90, 20), (profile.FolderTemplate, profile.FileTemplate, profile.SessionGapMinutes, profile.MinimumSessionFrames));
|
||||
Assert.Equal((false, false, false, false), (profile.IncludeSubfolders, profile.VerifyCopies, profile.Eject, profile.DeepAnalysis));
|
||||
Assert.Equal((Titano.Core.Import.DuplicatePolicy.ImportAgain, Titano.Data.Archiving.AfterImport.DeleteImported), (profile.Duplicates, profile.AfterImport));
|
||||
// Untouched settings give the brief's card defaults.
|
||||
Assert.Equal(new Titano.Data.Archiving.CardProfile(), new Titano.App.Infrastructure.AppSettings().ImportProfile(TemplateDefaults.Folder, TemplateDefaults.File));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewArchivesTakeSettingsArchive()
|
||||
{
|
||||
var settings = new Titano.App.Infrastructure.AppSettings { FolderTemplate = "{year}", FileTemplate = "{name}", ProxyLongEdge = 2560, ThumbnailLongEdge = 480 };
|
||||
var archive = settings.ArchiveDefaults();
|
||||
Assert.Equal(("{year}", "{name}", 2560, 480), (archive.Templates.Folder, archive.Templates.File, archive.Proxies.LongEdge, archive.Thumbnails.LongEdge));
|
||||
Assert.Null((new Titano.App.Infrastructure.AppSettings().ArchiveDefaults() with { Name = "Archive" }).Problem());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SettingsSurviveARoundTripWithTheNewSections()
|
||||
{
|
||||
var settings = new Titano.App.Infrastructure.AppSettings { ThumbnailLongEdge = 640, ScanIntervalMinutes = 30, NightBrightnessPercent = 3.5, DeepAnalysisAfterScan = true };
|
||||
var copy = Titano.App.Infrastructure.AppSettings.Parse(settings.ToJson())!;
|
||||
Assert.Equal((640, 30, 3.5, true), (copy.ThumbnailLongEdge, copy.ScanIntervalMinutes, copy.NightBrightnessPercent, copy.DeepAnalysisAfterScan));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BackgroundPriorityRaisesTheInterfaceOnlyInFront()
|
||||
{
|
||||
Assert.Equal(ThreadPriority.AboveNormal, InterfacePriority.For(enabled: true, active: true));
|
||||
Assert.Equal(ThreadPriority.Normal, InterfacePriority.For(enabled: true, active: false));
|
||||
Assert.Equal(ThreadPriority.Normal, InterfacePriority.For(enabled: false, active: true));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FormatsShowTheirTierAndWhatToInstall()
|
||||
{
|
||||
Assert.Equal(("JPEG XL", "CR3", "3FR"), (FormatNames.Of(Titano.Core.Imaging.ImageFileFormat.JpegXl), FormatNames.Of(Titano.Core.Imaging.ImageFileFormat.Cr3),
|
||||
FormatNames.Of(Titano.Core.Imaging.ImageFileFormat.ThreeFr)));
|
||||
var heif = Titano.Core.Windows.Codecs.StoreExtension.Get(Titano.Core.Windows.Codecs.StoreExtensionKind.HeifImage);
|
||||
var format = Titano.Core.Imaging.Decoders.DecoderFactory.DescribeFormats(Titano.Core.Imaging.Decoders.DecoderFactory.CreateClient(null))
|
||||
.First(f => f.Format.Format == Titano.Core.Imaging.ImageFileFormat.Heif).Format;
|
||||
var row = new FormatRowViewModel(new FormatRow(format, Titano.Core.Imaging.DecodeTier.EmbeddedPreview, "managed", [heif]));
|
||||
Assert.Equal(("Preview only", "Titano", heif.ProductName), (row.TierText, row.DecoderText, row.NeedsText));
|
||||
Assert.Equal(Titano.Ui.Controls.StatusKind.Warning, row.TierKind);
|
||||
Assert.Equal("HEIF: Preview only", row.Announcement);
|
||||
var missing = new MissingExtensionViewModel(heif, new Titano.Ui.Mvvm.RelayCommand(() => { }));
|
||||
Assert.Equal(heif.ProductName + " missing", missing.Text);
|
||||
var none = new FormatRowViewModel(new FormatRow(format, Titano.Core.Imaging.DecodeTier.Unavailable, null, []));
|
||||
Assert.Equal(("Not supported", "—", "—", false), (none.TierText, none.DecoderText, none.NeedsText, none.HasNeeds));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnumDrivenKeysExistInEveryRequiredLanguage()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user