fix(app): Library and Archive delete, quick actions and toolbar after review

Delete… runs in an in-window dialog shared by the Library and the Archive
manager: the dry run and the move into the trash report progress and stop
on Cancel, the toast counts only what really moved, and its Undo reports
failures. The confirmation names at most six moves and three refusals in
the UI font. Delete… stands apart at the far right of both bars and last
in the tab order.

The toolbar's filters wrap instead of pushing out the right-hand group at
1200 px. Card and row quick actions show while selected or focused, so Tab
reaches them; Analyse and Render are disabled with a reason when nothing
can run them, and say so in a toast if the session drops. Remote cards get
their own card, Analyse and Render tooltips; the details panel's Folder and
the saved-view menu say why they are disabled. Status offers Rendered, Not
rendered and Synced. Remote cards count in the Year and Camera choices and
the timeline. The trash dialog shows one sentence when empty.

--capture adds archive-trash and library-viewname.

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 08:06:14 +00:00
1 parent 992834988d
commit 04895c7b7b
29 files changed
+602 -170

No files matched your search

@@ -62,4 +62,19 @@ public sealed class DeletePlansTests
foreach (var reason in Enum.GetValues<DeleteBlock>())
Assert.NotEqual("Archive.Delete.Reason." + reason, Loc.L("Archive.Delete.Reason." + reason), "every reason has words");
}
[Test]
public void TheConfirmationStaysShortEnoughForASmallScreen()
{
var steps = Enumerable.Range(1, 20).Select(i => Step("Sequence " + i.ToString(CultureInfo.InvariantCulture), 10, 10, 1_000)).ToList();
var blocked = Enumerable.Range(1, 9).Select(i => new BlockedDelete(Sequence("Busy " + i.ToString(CultureInfo.InvariantCulture), 5), DeleteBlock.Busy)).ToList();
var request = Assert.NotNull(DeletePlans.Request(new DeletePlan(steps, blocked)));
var lines = request.Detail!.Split(Environment.NewLine);
Assert.Equal(DeletePlans.ListedLines + 1 + DeletePlans.BlockedLines + 1, lines.Length, "named lines plus one count for each part");
Assert.Equal(Loc.Plural("Archive.Delete.More", 14), lines[DeletePlans.ListedLines]);
Assert.Equal(Loc.Plural("Archive.Delete.More", 6), lines[^1]);
Assert.False(request.IsDetailMonospaced, "names read in the UI font, not the fingerprint font");
}
}
@@ -0,0 +1,74 @@
using Titano.App.Library;
using Titano.Core.Model;
using Titano.Data.Repositories;
using Titano.Testing;
namespace Titano.App.Tests.Library;
/// <summary>Mixed mode (BRIEF §4.4): the server's sequences without a copy here count in the Year and Camera choices and the timeline.</summary>
public sealed class LibraryFacetsTests
{
private static readonly ArchiveStats Local = new(3, 6_000, 60_000, [new YearBucket(2026, 3, 6_000, 60_000)],
[new MonthBucket(2026, 9, 2, 5_000), new MonthBucket(2026, 2, 1, 1_000)],
[new CameraBucket("Canon", "Canon EOS R5", 2, 5_000, 50_000), new CameraBucket("NIKON CORPORATION", "NIKON Z 8", 1, 1_000, 10_000)], [],
new ArchiveHealth(0, 0, 0, 0, 0, 0, 0));
private static Sequence Remote(DateTime? first, string? make, string? model, int frames) => new()
{
Id = Guid.CreateVersion7(),
ArchiveId = Guid.Empty,
Title = "Remote",
Folder = string.Empty,
Origin = SequenceOrigin.Server,
SyncState = SyncState.RemoteOnly,
FirstCapture = first,
CameraMake = make,
CameraModel = model,
FrameCount = frames,
TotalBytes = frames * 10L,
};
[Test]
public void RemoteCardsJoinTheYearsMonthsAndCameras()
{
Sequence[] remote =
[
Remote(new DateTime(2024, 5, 3), "SONY", "ILCE-7M4", 2_000),
Remote(new DateTime(2026, 9, 20), "Canon", "Canon EOS R5", 500),
Remote(null, null, null, 10),
];
var stats = LibraryFacets.Of(Local, remote, OriginFilter.Any);
Assert.SequenceEqual([2024, 2026], stats.ByYear.Select(y => y.Year));
Assert.Equal(new YearBucket(2024, 1, 2_000, 20_000), stats.ByYear[0]);
Assert.Equal(new YearBucket(2026, 4, 6_500, 65_000), stats.ByYear[1]);
Assert.SequenceEqual([(2024, 5), (2026, 2), (2026, 9)], stats.ByMonth.Select(m => (m.Year, m.Month)));
Assert.Equal(new MonthBucket(2026, 9, 3, 5_500), stats.ByMonth[2]);
Assert.Equal(3, stats.ByCamera.Single(c => c.Model == "Canon EOS R5").Sequences);
Assert.Equal(1, stats.ByCamera.Single(c => c.Model == "ILCE-7M4").Sequences);
Assert.Equal(1, stats.ByCamera.Single(c => c.Model is null).Sequences, "a card without camera counts under none");
Assert.Equal(Local.Sequences, stats.Sequences, "the totals stay the index's own");
var timeline = LibraryTimeline.From(stats, new DateTime(2026, 10, 6));
Assert.SequenceEqual([2026, 2025, 2024], timeline.Years, "a year only the server has gets its band");
Assert.Equal(2_000.0, timeline.Bands[2].Values[4]);
}
[Test]
public void TheOriginFilterDecidesWhoCounts()
{
Sequence[] remote = [Remote(new DateTime(2024, 5, 3), "SONY", "ILCE-7M4", 2_000)];
var local = LibraryFacets.Of(Local, remote, OriginFilter.Local);
Assert.SequenceEqual([2026], local.ByYear.Select(y => y.Year), "on this PC: the index alone");
Assert.False(local.ByCamera.Any(c => c.Model == "ILCE-7M4"));
var server = LibraryFacets.Of(Local, remote, OriginFilter.Server);
Assert.SequenceEqual([2024], server.ByYear.Select(y => y.Year), "only on server: the remote cards alone");
Assert.SequenceEqual(["ILCE-7M4"], server.ByCamera.Select(c => c.Model));
Assert.SequenceEqual([(2024, 5)], server.ByMonth.Select(m => (m.Year, m.Month)));
Assert.SequenceEqual(Local.ByYear, LibraryFacets.Of(Local, [], OriginFilter.Any).ByYear, "signed out, nothing changes");
}
}
@@ -0,0 +1,58 @@
using Titano.App.Library;
using Titano.Core.Model;
using Titano.Testing;
namespace Titano.App.Tests.Library;
/// <summary>The Status choices of Main.html (analysed, proxies, rendered, synced): the index's query and the same test in memory agree.</summary>
public sealed class LibraryFilterTests
{
private static Sequence Sequence(int rendered, SyncState sync, SequenceStatus status = SequenceStatus.None) => new()
{
Id = Guid.CreateVersion7(),
ArchiveId = Guid.CreateVersion7(),
Folder = "2026/x",
RenderedCount = rendered,
SyncState = sync,
Status = status,
};
[Test]
public void RenderedAndSyncedAskTheIndexForRendersAndSyncStates()
{
Assert.Equal(true, new LibraryFilter { Status = StatusFilter.Rendered }.ToQuery(50, null).Rendered);
Assert.Equal(false, new LibraryFilter { Status = StatusFilter.NotRendered }.ToQuery(50, null).Rendered);
Assert.Null(new LibraryFilter { Status = StatusFilter.Analysed }.ToQuery(50, null).Rendered);
Assert.SequenceEqual([SyncState.InSync, SyncState.LocalAhead], new LibraryFilter { Status = StatusFilter.Synced }.ToQuery(50, null).SyncStates!);
Assert.Null(new LibraryFilter { Status = StatusFilter.Rendered }.ToQuery(50, null).SyncStates);
var (with, without) = LibraryFilter.Flags(StatusFilter.NotRendered);
Assert.Equal(SequenceStatus.None, with | without, "renders are counted, not flagged");
}
[Test]
public void TheSameChoicesMatchInMemory()
{
var rendered = Sequence(2, SyncState.InSync, SequenceStatus.AnalyzedLight);
var bare = Sequence(0, SyncState.LocalOnly);
var ahead = Sequence(0, SyncState.ServerAhead);
Assert.True(LibraryFilter.MatchesStatus(rendered, StatusFilter.Rendered));
Assert.False(LibraryFilter.MatchesStatus(bare, StatusFilter.Rendered));
Assert.True(LibraryFilter.MatchesStatus(bare, StatusFilter.NotRendered));
Assert.True(LibraryFilter.MatchesStatus(rendered, StatusFilter.Synced));
Assert.False(LibraryFilter.MatchesStatus(ahead, StatusFilter.Synced), "the server is ahead: not synced");
Assert.True(LibraryFilter.MatchesStatus(rendered, StatusFilter.Analysed));
Assert.True(LibraryFilter.MatchesStatus(bare, StatusFilter.Any));
Assert.False(new LibraryFilter { Status = StatusFilter.NotRendered }.Matches(rendered));
}
[Test]
public void TheBriefsExampleViewCanBeSaved()
{
var filter = new LibraryFilter { Status = StatusFilter.NotRendered, Text = "night" };
var view = SavedView.Of(Guid.CreateVersion7(), "Night, 4K, not rendered", filter);
Assert.Equal(StatusFilter.NotRendered, view.Status);
Assert.True(view.Matches(filter));
Assert.Equal(filter.Status, view.ToFilter().Status);
}
}
@@ -15,7 +15,7 @@ namespace Titano.App.Tests.Library;
/// <summary>
/// The Library's new states of <c>--capture</c> (<see cref="LibraryScenes"/>) on the sample index while signed in to the
/// sample server, rendered in both themes in the real main window: the timeline, a selection with the whole mass actions
/// bar and its delete dry run, the server's sequences as remote cards, and saved views.
/// bar and its delete dry run, the server's sequences as remote cards, saved views and Save view, and the archive's trash.
/// </summary>
[WindowsOnly]
[Serial]
@@ -34,11 +34,12 @@ public sealed class LibraryScreenSmokeTests
await LibraryScenes.ShowAsync(app.Shell, "timeline");
Assert.True(library.IsTimeline, "the timeline shows its bands");
Assert.True(library.IsGrid, "the cards stay under the bands");
Assert.Equal(2, library.TimelineBands.Count, "one band per year, 2026 and 2025");
Assert.Equal(2, library.TimelineBands.Count, "one band per year, 2026 and 2025, the server's sequences included");
Assert.True(library.TimelineBand >= 0 && library.TimelineSlot >= 0, "the chosen month is outlined");
Assert.True(library.IsYearFiltered, "a month narrows the Library to its year");
await app.ExpectAsync<LibraryView>("library-timeline", waitForThumbnails: true);
Assert.True(app.FindAll<TimelineBands>().Any(t => t.IsVisible && t.ActualHeight > 0), "the bands are drawn");
var bands = Assert.NotNull(app.FindAll<TimelineBands>().FirstOrDefault(t => t.IsVisible && t.ActualHeight > 0), "the bands are drawn");
Assert.True(bands.Focusable, "the keyboard reaches the months");
await LibraryScenes.ShowAsync(app.Shell, "mass");
Assert.Equal(LibraryScenes.MassSelection, library.SelectionCount);
@@ -65,10 +66,13 @@ public sealed class LibraryScreenSmokeTests
{
dialog.Close();
}
// The sample dialogs cancel every confirmation: nothing moves.
// The sample dialogs cancel every confirmation: the delete dialog closes and nothing moves.
var selected = library.SelectedItems().Select(i => i.Id).ToList();
Assert.False(await SequenceDeletion.RunAsync(app.Shell, selected));
Assert.False(await library.DeleteAsync(selected));
Assert.Null(library.Dialog, "the delete dialog closes once it is answered");
foreach (var id in selected) Assert.NotNull(await app.Services.Database!.Sequences.GetAsync(id));
var first = library.Items.First(i => i.IsSelected);
Assert.True(library.AnalyseItemCommand.CanExecute(first) && library.RenderItemCommand.CanExecute(first), "the quick actions run on this PC's engine");
await LibraryScenes.ShowAsync(app.Shell, "remote");
Assert.True(library.ShowsOrigin, "signed in, the origin filter shows");
@@ -77,7 +81,10 @@ public sealed class LibraryScreenSmokeTests
Assert.True(library.IsSingleSelection);
Assert.False(library.DeleteCommand.CanExecute(null), "a remote card has nothing here to delete");
Assert.True(library.DownloadCommand.CanExecute(null), "its originals can come here");
Assert.False(library.RevealCommand.CanExecute(null), "a remote card has no folder here");
Assert.Equal(Core.Localization.Loc.L("Library.Blocked.ServerOnly"), library.RevealToolTip);
await app.ExpectAsync<LibraryView>("library-remote");
Assert.True(library.Years.Count > 1, "the server's years are choices too");
library.ClearFiltersCommand.Execute(null);
await library.RefreshAsync();
@@ -86,6 +93,21 @@ public sealed class LibraryScreenSmokeTests
await library.RefreshAsync();
Assert.True(library.IsViewActive);
Assert.True(library.Items.Count > 0 && library.Items.All(i => i.Sequence.CameraModel == "NIKON Z 8"));
await LibraryScenes.ShowAsync(app.Shell, "viewname");
var naming = Assert.NotNull(library.Dialog as ViewNameDialogViewModel, "Save view asks a name");
Assert.True(naming.SaveCommand.CanExecute(null), "the status filter's label is a free name");
Assert.False(library.IsContentEnabled, "the screen behind a dialog takes no input");
await app.ExpectAsync<LibraryView>("library-viewname");
naming.CloseCommand.Execute(null);
Assert.Null(library.Dialog);
await ArchiveScenes.ShowAsync(app.Shell, "trash");
var trash = Assert.NotNull(app.Shell.Archive.Dialog as TrashDialogViewModel, "Maintenance › Trash… opens the trash");
Assert.Equal(2, trash.Rows.Count, "the sample's deleted sequences");
Assert.True(trash.HasRows);
await app.ExpectAsync<ArchiveView>("archive-trash-sample");
trash.CloseCommand.Execute(null);
});
[Test]