merge: integration branch claude/keen-knuth-uhxv8w (Archive manager and UI kit review) into the Library workstream

The Archive manager's reviewed dialogs (live status lines, one-sentence
errors, growing label columns, left-to-right paths) move into the shared
ArchiveDialogs.xaml with their styles, so the Library's Delete and the
Trash dialog use them too. Delete, Restore and Rate failures read as one
sentence through ArchiveFailures, which now knows a stale delete plan, a
newer sidecar and a sequence already back in the library
(SequenceInLibraryException). The confirmation's plan lines in the UI font
follow the reading direction; fingerprints stay left to right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-06 20:36:02 +00:00
commit 9f7907d903
77 files changed
+1966 -468

No files matched your search

+59 -18
View File
@@ -47,6 +47,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private Core.Model.Archive? _archive;
private ArchiveAvailability _availability = ArchiveAvailability.Offline;
private ArchiveStats? _stats;
private int _withoutProxies;
private ArchiveTree? _tree;
private int _viewIndex;
private bool _loaded;
@@ -129,7 +130,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public bool HasArchive => _archive is not null;
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", _archive.RootPath);
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", Formatting.LeftToRight(_archive.RootPath));
/// <summary>0 = overview (tree and figures), 1 = maintenance.</summary>
public int ViewIndex
@@ -171,7 +172,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand VerifyCommand { get; }
public ICommand AdoptCommand { get; }
/// <summary>"Adopt folder ▾ › Copy into the layout": the Import screen copies the folder into the archive with its templates.</summary>
/// <summary>"Adopt folder ▾ › Copy into archive": the Import screen copies the folder into the archive with its templates.</summary>
public ICommand CopyFolderCommand { get; }
public ICommand BackupCommand { get; }
@@ -195,6 +196,20 @@ public sealed class ArchiveViewModel : SectionViewModel
public IReadOnlyList<ChartItem> CameraBars { get => _cameras; private set => Set(ref _cameras, value); }
public IReadOnlyList<ChartItem> FormatBars { get => _formats; private set => Set(ref _formats, value); }
/// <summary>The heatmap's scale in the card header (Archive.html: "0 ▭ 21,000"); hidden without photos.</summary>
public bool HasMonthScale => MonthScaleMax > 0;
public string MonthScaleLow => Formatting.Count(0);
public string MonthScaleHigh => Formatting.Count((long)MonthScaleMax);
private double MonthScaleMax => _months.SelectMany(r => r.Values).Where(double.IsFinite).DefaultIfEmpty(0).Max();
/// <summary>What each chart shows, value by value, for screen readers (the charts themselves are images).</summary>
public string MonthsDescription => Describe(_months.SelectMany(r => r.Values.Select((photos, month) => photos > 0 ? r.ToolTips?[month] : null)));
public string StorageDescription => Describe(_storage.Select(b => b.ToolTip));
public string CamerasDescription => Describe(_cameras.Select(b => b.ToolTip));
public string FormatsDescription => Describe(_formats.Select(b => b.ToolTip));
/// <summary>Photos per month in the culture's digits.</summary>
public Func<double, string> CountFormatter { get; } = v => Formatting.Count((long)v);
@@ -212,6 +227,9 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>The set button's accessible name: what it is and the set it shows.</summary>
public string SetFilterName => Loc.L("Archive.Set.Filter") + " · " + SetText;
/// <summary>Camera, status and tag on top of the tree selection.</summary>
public ArchiveSetFilter Filter
{
@@ -286,7 +304,9 @@ public sealed class ArchiveViewModel : SectionViewModel
get => _duplicates;
private set
{
if (Set(ref _duplicates, value)) OnPropertyChanged(nameof(DuplicatesText));
if (!Set(ref _duplicates, value)) return;
OnPropertyChanged(nameof(DuplicatesText));
ShowHealth();
}
}
@@ -299,8 +319,11 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>A duplicates or orphans search runs; it can be cancelled.</summary>
public bool IsSearching => _search is not null;
/// <summary>The duplicates search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingDuplicates => _findingDuplicates;
/// <summary>The orphans search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingOrphans => _findingOrphans;
/// <summary>"3 groups", "None found", or empty before the first search.</summary>
public string DuplicatesText => _findingDuplicates ? Loc.L("Archive.Find.Searching")
@@ -428,19 +451,28 @@ public sealed class ArchiveViewModel : SectionViewModel
private void ShowFigures(ArchiveStats stats, int withoutProxies)
{
_withoutProxies = withoutProxies;
Tiles = ArchiveFigures.Tiles(stats);
MonthRows = [.. ArchiveFigures.PhotosPerMonth(stats, DateTime.Today).Select(r => new ChartRow(r.Label, r.Values, r.ToolTips))];
StorageBars = Bars(ArchiveFigures.StorageByYear(stats));
CameraBars = Bars(ArchiveFigures.ByCamera(stats));
FormatBars = Bars(ArchiveFigures.ByFormat(stats));
ShowHealth();
}
/// <summary>The health lines of the last figures; the duplicates line follows the last duplicates search.</summary>
private void ShowHealth()
{
if (_stats is not { } stats) return;
Health =
[
.. ArchiveFigures.Health(stats, withoutProxies).Select(line => new HealthLineViewModel(line, line.Action switch
.. ArchiveFigures.Health(stats, _withoutProxies, _duplicates?.Count).Select(line => new HealthLineViewModel(line, line.Action switch
{
HealthAction.Verify => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.Verified, ids => ArchiveJobs.Verify(_archive!, ids))),
HealthAction.Proxies => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.ProxiesBuilt, ids => ArchiveJobs.Proxies(ids, CountLabel(ids)))),
HealthAction.Analyse => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.AnalyzedLight, ids => ProcessingJobs.LightAnalysis(ids, CountLabel(ids)))),
HealthAction.Duplicates => FindDuplicatesCommand,
HealthAction.MarkDuplicates => MarkDuplicatesCommand,
HealthAction.Orphans => FindOrphansCommand,
_ => null,
})),
@@ -450,6 +482,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private static IReadOnlyList<ChartItem> Bars(IReadOnlyList<BarValue> values) =>
[.. values.Select(v => new ChartItem(v.Label, v.Value, v.ValueText, v.ToolTip))];
private static string Describe(IEnumerable<string?> values) => string.Join(Environment.NewLine, values.Where(v => !string.IsNullOrEmpty(v)));
/// <summary>A reloaded tree keeps the open years and the selection (nodes that still exist).</summary>
private void ShowTree(ArchiveTree tree)
{
@@ -498,6 +532,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSetChanged()
{
OnPropertyChanged(nameof(SetText));
OnPropertyChanged(nameof(SetFilterName));
OnPropertyChanged(nameof(CameraChoices));
OnPropertyChanged(nameof(StatusChoices));
OnPropertyChanged(nameof(TagChoices));
@@ -714,13 +749,13 @@ public sealed class ArchiveViewModel : SectionViewModel
try
{
var path = await db.BackupAsync(Services.Environment.BackupDirectory);
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"),
() => ShellActions.Reveal(path));
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Formatting.LeftToRight(Path.GetFileName(path)), Loc.L("Library.Export.Show"),
Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or NotSupportedException)
{
Log.Warning("archive", "Database backup failed", ex);
Shell.Notify(Loc.L("Archive.Backup.Failed"), ex.Message);
NotifyFailure("Archive.Backup.Failed", ex, BackupCommand);
}
}
@@ -737,13 +772,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Services.SaveSettings();
_archive = archive;
await Services.QueueScanAsync(archive, full: false);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), archive.RootPath);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), Formatting.LeftToRight(archive.RootPath));
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", $"Relinking {folder} failed", ex);
Shell.Notify(Loc.L("Archive.Relink.Failed"), ex.Message);
// Retry asks for the folder again: the same one once its drive is back, or the right one.
NotifyFailure("Archive.Relink.Failed", ex, RelinkCommand);
}
}
@@ -777,7 +813,8 @@ public sealed class ArchiveViewModel : SectionViewModel
}
catch (DatabaseException ex)
{
Shell.ReportError(ex);
Log.Warning("archive", "Duplicates search failed", ex);
NotifyFailure("Archive.Duplicates.Failed", ex, FindDuplicatesCommand);
}
finally
{
@@ -803,10 +840,10 @@ public sealed class ArchiveViewModel : SectionViewModel
catch (OperationCanceledException) when (search.IsCancellationRequested)
{
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", "Orphan search failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.Failed"), ex.Message);
NotifyFailure("Archive.Orphans.Failed", ex, FindOrphansCommand);
}
finally
{
@@ -831,7 +868,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSearchChanged()
{
OnPropertyChanged(nameof(IsSearching));
OnPropertyChanged(nameof(IsFindingDuplicates));
OnPropertyChanged(nameof(IsFindingOrphans));
OnPropertyChanged(nameof(DuplicatesText));
OnPropertyChanged(nameof(OrphansText));
OnPropertyChanged(nameof(DuplicatesToolTip));
@@ -888,11 +926,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Orphans = Orphans?.Where(o => o.Row != row).ToList();
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Fixing {row.Title} failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.FixFailed"), ex.Message);
NotifyFailure("Archive.Orphans.FixFailed", ex, new AsyncRelayCommand(() => FixAsync(row)));
}
}
/// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary>
private void NotifyFailure(string titleKey, Exception ex, ICommand retry) =>
Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null));
}