Files
Chronos/src/Chronos.App/Server/Copies/CopyScenes.cs
T
Alby96andClaude Opus 5.5 9657c1711d fix(copies): close the owner review 6 second verification findings
Upload again now deletes the gone pair row once the new sequence is linked, so
the pair stops reading "deleted on server" or "kept here". A linked upload the
server refuses into its sequence (403 for an account without Edit that does not
own it) falls back to ordinary uploads instead of failing; an Integrate that
would add photos to such a sequence is blocked in its plan (NoAddRight).
Automatic photo transfers pause on a metered connection whatever the option
says. Integrate trashes server photos only against the manifest version that
checked the winner, and a merge is blocked while the other sequence holds a
damaged photo nothing else holds (DamagedPhotos), so nothing unverified reaches
the trash.

The plan and the confirmations now say what really happens: replaced versions
are no longer counted as kept, a merge lists the kept sequence's replaced
photos, plan lines use the text colour, an integrated pair that left photos out
says new photos move by hand, and a merging pair reads "merging" with its
progress. The Compare dialog gets per-side tooltips, class sizes for both
sides, policy-aware class tooltips, column headings and readable file names;
the sync table shows "deleted there" with Review and warns on skipped rows; the
Edit picker names the server, the Library card shows the match status second,
a deleted server sequence is named instead of "0 photos", and the match
tooltips stop calling a sequence a copy. The capture scenes use the server
name, the link names and consistent sample sizes.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 16:08:49 +01:00

117 lines
5.5 KiB
C#

using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Data.Copies;
using Chronos.Data.Sync;
namespace Chronos.App.Server.Copies;
/// <summary>
/// The Matches states that <c>--capture</c> renders (<c>server-copies-&lt;scene&gt;-&lt;theme&gt;.png</c>, design §8.7) and the
/// screen smoke tests check, on the sample pairs: the list, the dialog at each part and with each list, the plan with and
/// without a block, the merge of a local pair, the toast of Find matches, and the sync rows a pair marks.
/// </summary>
public static class CopyScenes
{
/// <summary>Scenes shown in the window (dialogs in-window included); the confirmations are separate windows.</summary>
public static readonly IReadOnlyList<string> Views =
[
"server-copies", "server-copies-toast", "server-copies-photos", "server-copies-choose", "server-copies-versions",
"server-copies-review", "server-copies-details", "server-copies-projects", "server-copies-plan", "server-copies-blocked",
"server-copies-merge", "server-sync-copyfound", "server-copies-gone",
];
/// <summary>The Lighthouse pair (a match found on the server).</summary>
public const string Lighthouse = "Lighthouse 2026-08-13";
/// <summary>The Alps pair (twice on this PC).</summary>
public const string Alps = "Alps 2025";
/// <summary>Shows <paramref name="view"/>; returns the dialog it opened, if any.</summary>
public static async Task<CopyDialogViewModel?> ShowAsync(ShellViewModel shell, string view)
{
var server = shell.Server;
var sync = server.Sync;
var list = sync.Copies;
shell.Navigate(SectionKey.Server);
if (server.Dialog is { } open) server.CloseDialog(open);
sync.SearchText = string.Empty;
await sync.ReloadAsync();
await list.ReloadAsync();
switch (view)
{
case "server-sync-copyfound":
sync.ShowFilter(SyncFilter.All);
return null;
case "server-copies-gone":
sync.ShowFilter(SyncFilter.All, "Garden");
return null;
case "server-copies-toast":
sync.ShowFilter(SyncFilter.FoundCopies);
if (list.Engine is { } engine) list.Announce(await engine.FindAsync(shell.Services.Sync.Remote, CancellationToken.None));
return null;
}
sync.ShowFilter(SyncFilter.FoundCopies);
if (view == "server-copies") return null;
var title = view is "server-copies-versions" or "server-copies-merge" ? Alps : view == "server-copies-review" ? "Bridge works wk 41" : Lighthouse;
if (list.Pairs.FirstOrDefault(p => p.Here.Title == title) is not { } pair) return null;
var (part, photos) = view switch
{
"server-copies-photos" => (CopyDialogPart.Photos, PhotoClass.OnlyHere),
"server-copies-choose" => (CopyDialogPart.Photos, PhotoClass.Differs),
"server-copies-versions" => (CopyDialogPart.Photos, PhotoClass.Versions),
"server-copies-review" => (CopyDialogPart.Photos, PhotoClass.DeletedThere),
"server-copies-details" => (CopyDialogPart.Details, (PhotoClass?)null),
"server-copies-projects" => (CopyDialogPart.Projects, null),
_ => (CopyDialogPart.Plan, null),
};
if (list.Open(pair, part, photos) is not { } dialog) return null;
await dialog.LoadAsync();
switch (view)
{
case "server-copies-choose":
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ChoosePerPhoto);
dialog.SelectedClass = dialog.Classes.FirstOrDefault(c => c.Class == PhotoClass.Differs);
break;
case "server-copies-details":
if (dialog.Details.Count > 0) dialog.Details[0].ChoiceIndex = 0;
break;
case "server-copies-plan":
dialog.AllHereCommand.Execute(null);
dialog.Part = CopyDialogPart.Plan;
break;
}
if (dialog.IsPlan) await dialog.PlanNowAsync();
return dialog;
}
/// <summary>"Replace photos?": the Lighthouse plan where this PC's version of the different photos wins.</summary>
public static async Task<ConfirmRequest?> ReplaceRequestAsync(ShellViewModel shell)
{
if (await ShowAsync(shell, "server-copies-plan") is not { } dialog) return null;
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ThisPcWins);
await dialog.PlanNowAsync();
// Worded as the dialog words it: the plan's server name, else the signed-in one's.
var request = dialog.Plan is { } plan ? dialog.ReplaceRequest(plan) : null;
shell.Server.CloseDialog(dialog);
return request;
}
/// <summary>"Merge sequences?": the Alps merge, with the typed photo count.</summary>
public static async Task<ConfirmRequest?> MergeRequestAsync(ShellViewModel shell)
{
if (await ShowAsync(shell, "server-copies-merge") is not { } dialog) return null;
dialog.AllHereCommand.Execute(null);
await dialog.PlanNowAsync();
var request = dialog.MergePlan is { } plan ? dialog.MergeRequest(plan) : null;
shell.Server.CloseDialog(dialog);
return request;
}
/// <summary>Back to the sync table with no dialog and no search.</summary>
public static void Reset(ShellViewModel shell)
{
if (shell.Server.Dialog is { } open) shell.Server.CloseDialog(open);
shell.Server.Sync.ShowFilter(SyncFilter.All, string.Empty);
}
}