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()
|
||||
{
|
||||
|
||||
@@ -96,6 +96,61 @@ public sealed class SettingsScreenSmokeTests
|
||||
Assert.True(ServerSession.ForgetRequest(certificate.FullFingerprint).IsDestructive);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task ImportAnalysisAndFormatsAreRealSettings() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
var settings = shell.Settings;
|
||||
// The open archive's own thumbnail size (archive.json) is what Settings › Archive shows.
|
||||
var archive = Assert.NotNull(await Titano.App.Archiving.CurrentArchive.FindAsync(shell.Services.Database!, shell.Services.Settings.LastArchivePath));
|
||||
var manifestPath = new Titano.Core.Archiving.ArchivePaths(archive.RootPath).ManifestPath;
|
||||
var manifest = Titano.Core.Archiving.ManifestStore.ReadArchive(manifestPath);
|
||||
Titano.Core.Archiving.ManifestStore.WriteArchive(manifestPath, manifest with { ThumbnailPolicy = new Titano.Core.Archiving.ThumbnailPolicy { LongEdge = 240 } });
|
||||
|
||||
shell.Navigate(SectionKey.Settings);
|
||||
settings.Page = SettingsPage.Archive;
|
||||
await WaitAsync(() => settings.SelectedThumbnailSize.Value == 240, "the archive's thumbnail size is shown");
|
||||
await app.ExpectAsync<SettingsView>("settings-archive");
|
||||
settings.SelectedThumbnailSize = settings.ThumbnailSizes.Single(s => s.Value == 480);
|
||||
await WaitAsync(() => Titano.Core.Archiving.ManifestStore.ReadArchive(manifestPath).ThumbnailPolicy.LongEdge == 480, "written into archive.json");
|
||||
Assert.Equal(480, shell.Services.Settings.ThumbnailLongEdge);
|
||||
|
||||
// Import: the defaults of new cards.
|
||||
settings.Page = SettingsPage.Import;
|
||||
await app.ExpectAsync<SettingsView>("settings-import");
|
||||
settings.SessionGap.Text = "90";
|
||||
Assert.True(settings.SessionGap.Commit());
|
||||
settings.IsFormatCard = true;
|
||||
Assert.Equal((90, Titano.Data.Archiving.AfterImport.FormatCard), (shell.Services.Settings.ImportSessionGapMinutes, shell.Services.Settings.ImportAfter));
|
||||
Assert.True(settings.CanResetSection);
|
||||
settings.ResetSectionCommand.Execute(null);
|
||||
Assert.Equal(("45", true), (settings.SessionGap.Text, settings.IsKeepCard));
|
||||
|
||||
// Analysis: thresholds in the language's own decimals, checked against their range.
|
||||
settings.Page = SettingsPage.Analysis;
|
||||
await app.ExpectAsync<SettingsView>("settings-analysis");
|
||||
Assert.Equal(6.25.ToString("0.##", System.Globalization.CultureInfo.CurrentCulture), settings.NightBrightness.Text);
|
||||
settings.NightBrightness.Text = "80";
|
||||
Assert.True(settings.NightBrightness.HasErrors, "beyond 50 %");
|
||||
settings.NightBrightness.Revert();
|
||||
settings.DeepAnalysisAfterScan = true;
|
||||
Assert.True(shell.Services.Settings.DeepAnalysisAfterScan);
|
||||
|
||||
// Formats: the tier of every format and a notice with Install per missing extension.
|
||||
settings.Page = SettingsPage.Formats;
|
||||
await WaitAsync(() => settings.Formats.Count > 0 && !settings.IsDetectingFormats, "formats listed");
|
||||
await app.ExpectAsync<SettingsView>("settings-formats");
|
||||
Assert.Count(3, settings.MissingExtensions);
|
||||
var installs = app.FindAll<Button>().Where(b => b.IsVisible && b.Content as string == Loc.L("Settings.Formats.Install")).ToList();
|
||||
Assert.Count(3, installs);
|
||||
Assert.True(installs.All(b => AutomationProperties.GetName(b).StartsWith(Loc.L("Settings.Formats.InstallName", string.Empty), StringComparison.Ordinal)), "named after the extension");
|
||||
Assert.Contains(settings.Formats, f => f.Row.Tier == Titano.Core.Imaging.DecodeTier.Native);
|
||||
Assert.False(settings.CanResetSection, "Formats only shows this PC");
|
||||
installs[0].Command.Execute(null);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task TheFirstRunDialogKeepsTheKeyboardInside() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
@@ -166,6 +221,17 @@ public sealed class SettingsScreenSmokeTests
|
||||
Assert.Equal(FlowDirection.LeftToRight, main.FlowDirection);
|
||||
});
|
||||
|
||||
/// <summary>Waits (on the UI thread, letting it run) until <paramref name="condition"/> holds.</summary>
|
||||
private static async Task WaitAsync(Func<bool> condition, string what)
|
||||
{
|
||||
var until = DateTime.UtcNow.AddSeconds(20);
|
||||
while (!condition())
|
||||
{
|
||||
Assert.True(DateTime.UtcNow < until, what);
|
||||
await Task.Delay(50);
|
||||
}
|
||||
}
|
||||
|
||||
private static TextBox Field(ScreenSmokeTests.SampleApp app, string name) =>
|
||||
app.FindAll<TextBox>().First(t => t.IsVisible && AutomationProperties.GetName(t) == name);
|
||||
|
||||
|
||||
Reference in new issue
Block a user