From 3c99badcfed1d580844b61a72c5892902bae6baf Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 17 Nov 2026 18:01:37 +0100 Subject: [PATCH] fix(copies): close the third verification round and add the match baselines Integrate trashes a server photo only for the sequence's owner or an admin, a Details stage stops instead of overwriting a server change the user had kept this PC's value against, a merge retried after a stop plans again when work reached the other sequence, detection keeps pairs answered while it ran, and a sync row whose match the server deleted offers Keep here, Upload again and To trash. The Integrate and merge logs say in the UI language why a version was kept. The edit-picker-twins capture scene showed no Twin chip, since a capture has no workspace: it now lists sample workspace projects of the sample matches. The screenshot baselines gain the 38 Matches screens and take the Matches chip, the three Settings > Server rows, the longer priority list and 1.2.0. Refs #73 Co-Authored-By: Claude Opus 5.5 --- docs/CHANGELOG.md | 18 ++++ docs/DECISIONS.md | 11 +- i18n/en/Archive.resx | 10 ++ i18n/en/Errors.resx | 1 + i18n/en/Tooltips.resx | 9 +- i18n/it/Archive.it.resx | 10 ++ i18n/it/Errors.it.resx | 1 + i18n/it/Tooltips.it.resx | 9 +- src/Chronos.App/DesignTime/SampleCopies.cs | 27 +++-- src/Chronos.App/DesignTime/SampleData.cs | 11 ++ src/Chronos.App/Infrastructure/AppServices.cs | 8 +- .../Sections/SequencePickerView.xaml | 5 +- .../Sections/SequencePickerViewModel.cs | 23 ++++ src/Chronos.App/Sections/ServerView.xaml | 52 +++++---- .../Server/Copies/CopyDialogViewModel.cs | 59 +++++++++-- .../Server/Copies/CopyDialogs.xaml | 100 +++++++++++------- .../Server/Copies/CopyListViewModel.cs | 26 +++++ src/Chronos.App/Server/Copies/CopyPhotoRow.cs | 32 +++++- src/Chronos.App/Server/Copies/CopyScenes.cs | 45 +++++++- src/Chronos.App/Server/SyncRow.cs | 7 +- src/Chronos.App/Server/SyncTableViewModel.cs | 12 ++- src/Chronos.App/Server/SyncText.cs | 52 +++++++-- src/Chronos.App/Shell/ScreenCapture.cs | 3 +- .../Archiving/Jobs/MergeJobHandler.cs | 64 +++++++++-- src/Chronos.Data/Archiving/MergeJournal.cs | 13 +++ src/Chronos.Data/Archiving/SequenceMerger.cs | 49 +++++++-- src/Chronos.Data/Copies/CopyFinder.cs | 9 +- src/Chronos.Data/Copies/CopyLog.cs | 28 +++++ src/Chronos.Data/Copies/CopyPlans.cs | 12 ++- src/Chronos.Data/Copies/CopyReviewBuilder.cs | 10 +- src/Chronos.Data/Copies/FoundCopyStore.cs | 7 ++ .../Copies/IntegrateJobHandler.cs | 31 +++--- src/Chronos.Data/Copies/IntegrateJournal.cs | 6 ++ src/Chronos.Data/Copies/IntegratePlanner.cs | 18 +++- src/Chronos.Data/Sync/SyncService.cs | 10 ++ .../Server/CopyScreenSmokeTests.cs | 27 +++++ .../Chronos.App.Tests/Server/CopyTextTests.cs | 38 +++++++ .../Archiving/SequenceMergerTests.cs | 90 ++++++++++++++++ .../Copies/FoundCopyStoreTests.cs | 17 +++ .../Copies/IntegrateTests.cs | 97 +++++++++++++++++ .../baselines/edit-picker-twins-dark.png | Bin 0 -> 101111 bytes .../baselines/edit-picker-twins-light.png | Bin 0 -> 93755 bytes .../visual/baselines/library-copies-dark.png | Bin 0 -> 42005 bytes .../visual/baselines/library-copies-light.png | Bin 0 -> 40474 bytes .../visual/baselines/server-conflict-dark.png | Bin 60614 -> 61084 bytes .../baselines/server-conflict-light.png | Bin 56184 -> 56654 bytes .../baselines/server-copies-blocked-dark.png | Bin 0 -> 76854 bytes .../baselines/server-copies-blocked-light.png | Bin 0 -> 76584 bytes .../baselines/server-copies-choose-dark.png | Bin 0 -> 79387 bytes .../baselines/server-copies-choose-light.png | Bin 0 -> 79368 bytes .../baselines/server-copies-confirm-dark.png | Bin 0 -> 15429 bytes .../baselines/server-copies-confirm-light.png | Bin 0 -> 14448 bytes tests/visual/baselines/server-copies-dark.png | Bin 0 -> 79743 bytes .../baselines/server-copies-details-dark.png | Bin 0 -> 76289 bytes .../baselines/server-copies-details-light.png | Bin 0 -> 75600 bytes .../baselines/server-copies-empty-dark.png | Bin 0 -> 61609 bytes .../baselines/server-copies-empty-light.png | Bin 0 -> 57244 bytes .../baselines/server-copies-gone-dark.png | Bin 0 -> 61874 bytes .../baselines/server-copies-gone-light.png | Bin 0 -> 57382 bytes .../visual/baselines/server-copies-light.png | Bin 0 -> 75242 bytes .../baselines/server-copies-merge-dark.png | Bin 0 -> 80305 bytes .../baselines/server-copies-merge-light.png | Bin 0 -> 80393 bytes .../baselines/server-copies-photos-dark.png | Bin 0 -> 92705 bytes .../baselines/server-copies-photos-light.png | Bin 0 -> 91610 bytes .../baselines/server-copies-plan-dark.png | Bin 0 -> 76451 bytes .../baselines/server-copies-plan-light.png | Bin 0 -> 76088 bytes .../baselines/server-copies-projects-dark.png | Bin 0 -> 76004 bytes .../server-copies-projects-light.png | Bin 0 -> 75792 bytes .../server-copies-replace-confirm-dark.png | Bin 0 -> 9787 bytes .../server-copies-replace-confirm-light.png | Bin 0 -> 9341 bytes .../baselines/server-copies-review-dark.png | Bin 0 -> 79876 bytes .../baselines/server-copies-review-light.png | Bin 0 -> 79080 bytes .../server-copies-signedout-dark.png | Bin 0 -> 48133 bytes .../server-copies-signedout-light.png | Bin 0 -> 45476 bytes .../baselines/server-copies-toast-dark.png | Bin 0 -> 83949 bytes .../baselines/server-copies-toast-light.png | Bin 0 -> 80142 bytes .../baselines/server-copies-versions-dark.png | Bin 0 -> 78999 bytes .../server-copies-versions-light.png | Bin 0 -> 78610 bytes tests/visual/baselines/server-dark.png | Bin 84306 -> 84762 bytes tests/visual/baselines/server-jobs-dark.png | Bin 88530 -> 88988 bytes tests/visual/baselines/server-jobs-light.png | Bin 80492 -> 80920 bytes tests/visual/baselines/server-light.png | Bin 78073 -> 78484 bytes tests/visual/baselines/server-share-dark.png | Bin 85492 -> 85945 bytes .../baselines/server-share-failed-dark.png | Bin 85262 -> 85722 bytes .../baselines/server-share-failed-light.png | Bin 78848 -> 79247 bytes tests/visual/baselines/server-share-light.png | Bin 79226 -> 79639 bytes .../baselines/server-sync-copyfound-dark.png | Bin 0 -> 83691 bytes .../baselines/server-sync-copyfound-light.png | Bin 0 -> 77454 bytes tests/visual/baselines/server-sync-dark.png | Bin 84276 -> 84727 bytes tests/visual/baselines/server-sync-light.png | Bin 77441 -> 77846 bytes .../visual/baselines/settings-about-dark.png | Bin 46470 -> 46723 bytes .../visual/baselines/settings-about-light.png | Bin 43243 -> 43503 bytes .../baselines/settings-rendering-dark.png | Bin 77447 -> 77447 bytes .../baselines/settings-rendering-light.png | Bin 69761 -> 69759 bytes .../visual/baselines/settings-server-dark.png | Bin 70798 -> 68452 bytes .../baselines/settings-server-light.png | Bin 63944 -> 61814 bytes 96 files changed, 910 insertions(+), 147 deletions(-) create mode 100644 src/Chronos.Data/Copies/CopyLog.cs create mode 100644 tests/visual/baselines/edit-picker-twins-dark.png create mode 100644 tests/visual/baselines/edit-picker-twins-light.png create mode 100644 tests/visual/baselines/library-copies-dark.png create mode 100644 tests/visual/baselines/library-copies-light.png create mode 100644 tests/visual/baselines/server-copies-blocked-dark.png create mode 100644 tests/visual/baselines/server-copies-blocked-light.png create mode 100644 tests/visual/baselines/server-copies-choose-dark.png create mode 100644 tests/visual/baselines/server-copies-choose-light.png create mode 100644 tests/visual/baselines/server-copies-confirm-dark.png create mode 100644 tests/visual/baselines/server-copies-confirm-light.png create mode 100644 tests/visual/baselines/server-copies-dark.png create mode 100644 tests/visual/baselines/server-copies-details-dark.png create mode 100644 tests/visual/baselines/server-copies-details-light.png create mode 100644 tests/visual/baselines/server-copies-empty-dark.png create mode 100644 tests/visual/baselines/server-copies-empty-light.png create mode 100644 tests/visual/baselines/server-copies-gone-dark.png create mode 100644 tests/visual/baselines/server-copies-gone-light.png create mode 100644 tests/visual/baselines/server-copies-light.png create mode 100644 tests/visual/baselines/server-copies-merge-dark.png create mode 100644 tests/visual/baselines/server-copies-merge-light.png create mode 100644 tests/visual/baselines/server-copies-photos-dark.png create mode 100644 tests/visual/baselines/server-copies-photos-light.png create mode 100644 tests/visual/baselines/server-copies-plan-dark.png create mode 100644 tests/visual/baselines/server-copies-plan-light.png create mode 100644 tests/visual/baselines/server-copies-projects-dark.png create mode 100644 tests/visual/baselines/server-copies-projects-light.png create mode 100644 tests/visual/baselines/server-copies-replace-confirm-dark.png create mode 100644 tests/visual/baselines/server-copies-replace-confirm-light.png create mode 100644 tests/visual/baselines/server-copies-review-dark.png create mode 100644 tests/visual/baselines/server-copies-review-light.png create mode 100644 tests/visual/baselines/server-copies-signedout-dark.png create mode 100644 tests/visual/baselines/server-copies-signedout-light.png create mode 100644 tests/visual/baselines/server-copies-toast-dark.png create mode 100644 tests/visual/baselines/server-copies-toast-light.png create mode 100644 tests/visual/baselines/server-copies-versions-dark.png create mode 100644 tests/visual/baselines/server-copies-versions-light.png create mode 100644 tests/visual/baselines/server-sync-copyfound-dark.png create mode 100644 tests/visual/baselines/server-sync-copyfound-light.png diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5c2263d2..31700569 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -128,6 +128,24 @@ match. A 1.1 server works as before, without Integrate; a 1.2 server adds the ph - The Edit picker's twin tooltip names the server, not its key; the Library card shows the match status second; a match whose server sequence was deleted names the server instead of "0 photos"; the match tooltips no longer call a sequence a "copy". + - Integrate trashes a server photo only for the server sequence's owner or an admin; for anyone else the server's + losing version stays, out of the server's Main, and the plan says it needs the Delete right. Compare offers Delete on + server on the same terms. + - A server title, tags, rating or notes change made while an Integrate runs stops its Details stage where the user kept + this PC's value, instead of being overwritten. + - A merge retried after a stop plans again when work reached the other sequence since (settings, a project, a render) + or when a third sequence no longer holds a photo it was counted on for; a photo flagged missing whose file is back + blocks the merge plan. + - Detection no longer removes a pair answered while it ran. + - The Integrate and merge logs say in the UI language why a losing version was kept, and name the files and projects + they replaced or copied; an unreachable server's projects are named by the server's name. + - Upload all local names where a suspected match lies (another server, or another archive of this PC); a skipped + busy sequence says a job is integrating or merging it. + - A sync row whose match the server deleted offers Keep here, Upload again and To trash…. + - Compare dialog: the parts' tooltips say what each shows; the photo list has column headings; the Projects headings + name the lists they head; a merge reads Kept and Other from the start; the Projects part shows where each project + goes as soon as it opens. Matches: the This side and Other side columns take the room the actions leave. + - The Edit picker's Twin chip sits right after the project name. ## [1.1.1] — 2026-11-16 diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 81c74f96..70fe6b8f 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -965,5 +965,12 @@ One line per decision: date · decision · alternative · reason. | 2026-11-17 | The Compare photo list keeps each row's selection from the list's SelectionChanged (`ListSelection.SyncsRows`), not only from the realised rows' IsSelected binding (#73) | Turn virtualisation off | A long class list must stay virtualised; Ctrl+A must reach the hidden rows | | 2026-11-17 | Automatic photo transfers (an integrated pair's new photos) are held on a metered connection whatever the "pause on metered" option says; manual transfers follow the option (#73) | Follow the option for every transfer | Owner Q6: new photos move by themselves "with a metered pause"; the option still governs what the user starts | | 2026-11-17 | A linked upload whose IntoTarget the server refuses (403 forbidden) falls back for the rest of the job to ordinary uploads the server files by SHA-256; an Integrate that would send photos into a server sequence the account neither owns nor may edit is blocked in its plan (`CopyBlock.NoAddRight`) (#73) | Fail the upload; ask the server for a new right | A Read+Upload account keeps uploading as before 1.2; an Integrate cannot fall back without leaving its plan, so it stops before anything moves | -| 2026-11-17 | A merge is blocked (`CopyBlock.DamagedPhotos`) when the other sequence holds a Corrupt-flagged photo whose current file content nothing in the kept sequence or elsewhere in this PC's index holds; one held elsewhere goes to the trash as before (#73) | List the damaged photos in the plan and trash them | The simplest safe option: nothing unverified goes to the trash, and Verify/repair already exist | -| 2026-11-17 | The Plan's "Server uses ours" line still counts every version sent, replaced or kept beside (#73) | Count it as the Versions line does | The line says which side's file the server ends up with, true in both cases | +| 2026-11-17 | A merge is blocked (`CopyBlock.DamagedPhotos`) when the other sequence holds a Corrupt- or Missing-flagged photo (one whose file is back counts too: the merge would not copy it) whose current file content nothing in the kept sequence or elsewhere in this PC's index holds; one held elsewhere goes to the trash as before (#73) | List the damaged photos in the plan and trash them | The simplest safe option: nothing unverified goes to the trash, and Verify/repair already exist | +| 2026-11-17 | The Plan's "Server uses ours" line counts only the versions whose server version goes to its trash or out of its Main (`IntegratePlan.ServerUsesOurs`); a losing server version that stays for want of the right to delete it is listed as "stays: needs the Delete right" (`StaysForDelete`) and kept out of the server's Main by the payload (#73; replaces the earlier row that counted every version sent) | Count every version sent | A version sent but not used by the server's Main would be reported as used | +| 2026-11-17 | Who may trash photos of a server sequence is decided per sequence: the admin role (`CopyPlanContext.OwnsOrAdmin`, from the role or the ManageUsers permission only an admin holds) or the account that owns that sequence (its `OwnerUserId`), each with the Delete right; Integrate plans and Compare's Delete on server follow it (#73; replaces approximating ownership with the Delete right) | Approximate ownership with the Delete or Edit right | The server's DeleteFramesAsync allows the owner or an admin only: an Editor's plan would fail at the dry run with a 403 | +| 2026-11-17 | An Integrate's Details stage absorbs a server change made since the plan only on lines the plan did not have, or where the user took the server's value; a change to a title, tags, rating or notes line where the user kept this PC's value stops the stage (`Errors.Copies.DetailsChanged`) and overwrites neither side (#73) | Absorb every server change since the plan | Absorbing would silently overwrite the server's new value with this PC's on a line the user decided before that value existed | +| 2026-11-17 | A merge retried after a stop re-checks before the trash that nothing reached the other sequence since its plan: its settings version, a project not planned (or moved on to another head) whose head the kept sequence does not hold, a render not moved whose file the kept one does not hold, and the photos a third sequence held at the verify; any of these drops the journal and asks for a new plan (`Errors.Copies.Changed`); the plan skips the other's projects whose head the kept sequence already holds (#73) | Trust the journal written before the stop | Work sent home into the other after the stop would go to the trash with it, never copied | +| 2026-11-17 | Detection removes a stale pair only while it is still an unanswered Candidate (`FoundCopyStore.DeleteCandidateAsync`): an answer given while detection ran stays (#73) | Delete by id | A Keep apart or a Link given during a detection pass was erased | +| 2026-11-17 | The merge dialog plans once on opening to learn the sequence kept by default, so its photos read Kept and Other from the start; with no default (both equal) they read the two archives' names until one is kept (#73) | Read Kept for the pair's first until a plan runs | The wrong sequence was called "Kept" until the Plan part was opened | +| 2026-11-17 | A sync row whose match the server deleted offers the Matches row's Keep here, Upload again and To trash… (Upload again only once kept here), as new `SyncAction` values appended to the enum (#73) | Offer them on the Matches list only | Design §6.3 puts them on the local row; the row read "deleted on server" with no action | +| 2026-11-17 | The capture's edit-picker-twins scene lists two sample workspace projects (the integrated pair's Main, a Vertical of a pair still to answer) through `SequencePickerViewModel.ShowSampleWorkspaceAsync`, since a capture has no workspace (`WorkspaceHost.IsEnabled`); the Twin chip is marked by the picker's own twin lookup (#73) | Enable the workspace in a capture | The capture's sample library has no engine to copy media; without it the scene showed no Workspace group and no chip | diff --git a/i18n/en/Archive.resx b/i18n/en/Archive.resx index 3fdae8e6..ac2797a1 100644 --- a/i18n/en/Archive.resx +++ b/i18n/en/Archive.resx @@ -457,6 +457,16 @@ Videos {0}: sent into the linked sequencelong: job log line {0}: received into this PC's sequencelong: job log line + {0}: older version kept, {1}long: job log line; {1} is one of Archive.Log.KeptReason.* + Project {0} not copied: {1}long: job log line + a job is working on itlong: completes Archive.Log.CopyKept + the photos changed meanwhilelong: completes Archive.Log.CopyKept + the version that replaces it is not in placelong: completes Archive.Log.CopyKept + the version that replaces it is not in place on the serverlong: completes Archive.Log.CopyKept + the archive is offline or read-onlylong: completes Archive.Log.CopyKept + the server refused it ({0})long: completes Archive.Log.CopyKept; {0} is the server's reason + the photo cannot be read nowlong: completes Archive.Log.CopyKept + the sequence would be left emptylong: completes Archive.Log.CopyKept {0}: older version to the trashlong: job log line Project {0} copied as {1}long: job log line {0}: copied and verifiedlong: job log line diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index 175d266a..1b924978 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -146,6 +146,7 @@ {0} photos stayed as they were; the job log says why. {0} project was not copied; the job log says why. {0} projects were not copied; the job log says why. + The projects of {0} cannot be reached now. {0} needs {1} free; free some space and try again. A job is working on one of these sequences; try again when it ends. Send or discard the workspace changes of {0} first. diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 3d31b2bf..c8b1d455 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -1150,16 +1150,21 @@ This sequence may also be on {0}. Compare to decide. Upload all local left this out: {0}. Photos did not move by themselves: {0}. - it may be the same as a sequence on the server + it may be the same as a sequence on {0}{0} the server's name + it may be the same as a sequence in {0}{0} the other archive's name you kept it apart from a match it came from a server the server deleted its sequence - it is being integrated + a job is integrating or merging it Upload the sequences only here; {0} is left out (its row says why). Upload the sequences only here; {0} are left out (each row says why). Look for matches of these sequences on {0} and on this PC now. Look for matches among this PC's archives now. See which photos, details and projects differ between the two sequences. + The photos each sequence has, and which version each side keeps. + The title, tags, rating, notes and settings that differ, line by line. + The editing projects of each sequence, and where they go. + What each side receives and loses before anything runs. Complete both sequences, settle the differences once, then keep them in sync. Merge the two into the kept sequence; the other goes to the trash after verification. Keep both as separate sequences and stop asking. Upload all local leaves this one out. diff --git a/i18n/it/Archive.it.resx b/i18n/it/Archive.it.resx index 1a2da1ef..fadc3e65 100644 --- a/i18n/it/Archive.it.resx +++ b/i18n/it/Archive.it.resx @@ -449,6 +449,16 @@ Video {0}: inviata nella sequenza collegata {0}: ricevuta nella sequenza di questo PC + {0}: versione precedente mantenuta, {1} + Progetto {0} non copiato: {1} + un'attività ci sta lavorando + le foto sono cambiate nel frattempo + la versione che la sostituisce non è al suo posto + la versione che la sostituisce non è al suo posto sul server + l'archivio non è raggiungibile o è di sola lettura + il server l'ha rifiutato ({0}) + la foto non si può leggere ora + la sequenza resterebbe vuota {0}: versione precedente nel cestino Progetto {0} copiato come {1} {0}: copiata e verificata diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index 276b816f..5425cb6f 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -146,6 +146,7 @@ {0} foto sono rimaste com'erano; il registro del lavoro dice perché. {0} progetto non è stato copiato; il registro dice perché. {0} progetti non sono stati copiati; il registro dice perché. + I progetti di {0} non sono raggiungibili ora. {0} ha bisogno di {1} liberi; libera spazio e riprova. Un lavoro sta usando una di queste sequenze; riprova quando finisce. Prima invia o scarta le modifiche di lavoro di {0}. diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index c9eb90d1..387d9525 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -1148,16 +1148,21 @@ Questa sequenza potrebbe essere anche su {0}. Confronta per decidere. Carica le locali l'ha saltata: {0}. Le foto non sono passate da sole: {0}. - potrebbe essere la stessa di una sequenza sul server + potrebbe essere la stessa di una sequenza su {0} + potrebbe essere la stessa di una sequenza in {0} l'hai tenuta separata da una corrispondenza viene da un server il server ha eliminato la sua sequenza - è in integrazione + un'attività la sta integrando o unendo Carica le sequenze presenti solo qui; {0} viene saltata (la sua riga dice perché). Carica le sequenze presenti solo qui; {0} vengono saltate (ogni riga dice perché). Cerca ora corrispondenze di queste sequenze su {0} e su questo PC. Cerca ora corrispondenze tra gli archivi di questo PC. Mostra quali foto, dettagli e progetti differiscono tra le due sequenze. + Le foto di ciascuna sequenza e quale versione tiene ogni lato. + Titolo, tag, valutazione, note e impostazioni che differiscono, riga per riga. + I progetti di modifica di ciascuna sequenza e dove vanno. + Cosa riceve e cosa perde ogni lato prima che parta qualcosa. Completa entrambe le sequenze, risolvi una volta le differenze, poi tienile sincronizzate. Unisce le due nella sequenza tenuta; l'altra va nel cestino dopo la verifica. Tiene le due sequenze separate e non chiede più. Carica le locali la salta. diff --git a/src/Chronos.App/DesignTime/SampleCopies.cs b/src/Chronos.App/DesignTime/SampleCopies.cs index 409cebce..0f2e478b 100644 --- a/src/Chronos.App/DesignTime/SampleCopies.cs +++ b/src/Chronos.App/DesignTime/SampleCopies.cs @@ -32,6 +32,12 @@ internal sealed class SampleCopyEngine : ICopyEngine public IReadOnlyList Pairs => _pairs; + /// + /// More twins, read when asked (edit-picker-twins): the workspace's projects of this PC taken as a linked pair's, so the + /// picker shows its Twin chip whichever sample project the workspace holds then. + /// + public Func>>? MoreTwins { get; set; } + public void Add(SampleCopy pair) => _pairs.Add(pair); /// Raises as a detection run would (the matches-found toast). @@ -75,7 +81,11 @@ internal sealed class SampleCopyEngine : ICopyEngine steps, lasts, leftOut, null, null, null, choices.Details.Count, projects, steps.Where(s => s.Action is PhotoAction.Fetch or PhotoAction.FetchVersion).Sum(s => s.Bytes), steps.Where(s => s.Action is PhotoAction.Send or PhotoAction.SendVersion).Sum(s => s.Bytes), - 1_240_000_000_000, 2_900_000_000_000, blocks, 1, 1, 1, 1, "sample")); + 1_240_000_000_000, 2_900_000_000_000, blocks, 1, 1, 1, 1, "sample") + { + // The sample signs in with every right: each version this PC sends replaces the server's, which goes to its trash. + ServerUsesOurs = steps.Count(s => s.Action == PhotoAction.SendVersion), + }); } public async Task EnqueueIntegrateAsync(JobEngine engine, IntegratePlan plan, CancellationToken ct) @@ -99,11 +109,11 @@ internal sealed class SampleCopyEngine : ICopyEngine .Select(p => new ProjectStep(keepsHere ? CopySide.Other : CopySide.ThisPc, p.Id, p.Name, p.Name + " (2)", p.Versions, p.HeadId)).ToList(); return Task.FromResult(new MergePlan(copyId, keep ?? Guid.Empty, keepsHere ? pair.Copy.OtherId ?? Guid.Empty : pair.Copy.LocalId, choices, steps, [], [new RenderStep(Guid.CreateVersion7(), "Alps 2025 4K.mp4", 640_000_000, null)], null, choices.Details.Count, projects, - ["card:CANON-EOS-R5:2025-07-14"], [], [pair.Copy.Server ?? "nas"], new DeletePlan([], []), drop.Bytes / 20, 1_240_000_000_000, blocks, + ["card:CANON-EOS-R5:2025-07-14"], [], [.. drop.Servers], new DeletePlan([], []), drop.Bytes / 20, 1_240_000_000_000, blocks, 1, 1, 1, 1, "sample") { - // The link that moves is shown by the server's name, as SequenceMerger names it. - LinkNames = [drop.Servers.FirstOrDefault() ?? pair.Copy.Server ?? "nas"], + // Only the dropped sequence's own links move, shown by their servers' names as SequenceMerger names them. + LinkNames = [.. drop.Servers], }); } @@ -154,10 +164,13 @@ internal sealed class SampleCopyEngine : ICopyEngine public Task KeepHereAsync(Guid copyId, CancellationToken ct) => Change(copyId, c => c with { State = CopyState.KeptApart, PreviousState = c.State }); - public Task> TwinsAsync(CancellationToken ct) => Task.FromResult>( - [.. _pairs.Where(p => p.Copy is { Kind: CopyKind.LocalServer, State: CopyState.Integrated or CopyState.Linked }) + public async Task> TwinsAsync(CancellationToken ct) + { + IReadOnlyList more = MoreTwins is { } read ? await read() : []; + return [.. _pairs.Where(p => p.Copy is { Kind: CopyKind.LocalServer, State: CopyState.Integrated or CopyState.Linked }) .Select(p => new CopyTwin(p.Copy.Id, p.Copy.LocalId, p.Here.Where, "Main", p.Copy.Server ?? string.Empty, p.Copy.RemoteId ?? Guid.Empty, "Vertical", - p.There.Where))]); + p.There.Where)), .. more]; + } /// /// The photo steps of the choices: photos only on one side travel to the other (unless Choose each leaves them out); diff --git a/src/Chronos.App/DesignTime/SampleData.cs b/src/Chronos.App/DesignTime/SampleData.cs index f2483d12..f065a451 100644 --- a/src/Chronos.App/DesignTime/SampleData.cs +++ b/src/Chronos.App/DesignTime/SampleData.cs @@ -301,6 +301,10 @@ public sealed class SampleData const string ServerName = "Studio NAS"; var start = new DateTime(2026, 8, 13, 21, 0, 0); + // Each card draws a picture of its own: a few generated frames on disk, as FillAsync writes them (library-copies). + string[][] palettes = [["#1B2A4A", "#E07B39", "#F6C778"], ["#050914", "#1D2B53", "#C9D6FF"], ["#3A4F5C", "#9FB7C4", "#E9EEF1"], + ["#24476B", "#7FA7C9", "#F2F5F7"], ["#2F4A2A", "#7BA05B", "#D9E8C4"]]; + var painted = 0; async Task SequenceAsync(string title, Guid archive, int frames, DateTime first, string camera) { var sequence = new Sequence @@ -320,6 +324,8 @@ public sealed class SampleData UpdatedAt = Now, }; await db.Sequences.UpsertAsync(sequence); + var folderRoot = archive == originals.Id ? root : main.RootPath; + await db.Frames.BulkInsertAsync(WriteFrames(folderRoot, sequence, palettes[painted++ % palettes.Length], raw: false)); return sequence; } @@ -394,6 +400,11 @@ public sealed class SampleData SampleCopies.Facts(garden, main.Name, 480), SampleCopies.Facts(garden, ServerName, 0), photos, [], Projects(other: false))); engine.NextFind = new CopyFindResult([engine.Pairs[0].Copy, engine.Pairs[3].Copy], [], []); + // Edit's picker (edit-picker-twins): this PC's workspace projects read as a linked pair's, with a project on the server. + var workspace = _services.Workspace; + engine.MoreTwins = async () => !workspace.IsAvailable ? [] + : [.. (await workspace.ListAsync()).Where(e => !e.IsServerHome).Take(1) + .Select(e => new CopyTwin(Guid.Empty, e.SequenceId, main.Name, e.Name, server, Guid.Empty, "Main", ServerName))]; _services.Sync.Copies = engine; return engine; } diff --git a/src/Chronos.App/Infrastructure/AppServices.cs b/src/Chronos.App/Infrastructure/AppServices.cs index b305783a..f7ba5e8f 100644 --- a/src/Chronos.App/Infrastructure/AppServices.cs +++ b/src/Chronos.App/Infrastructure/AppServices.cs @@ -253,9 +253,9 @@ public sealed class AppServices : IAsyncDisposable } /// - /// What the planners know of this PC and the signed-in account. The account's rights stand for its rights over the - /// server's sequence: the server enforces ownership itself, so OwnsOrAdmin reads Delete or an admin right; the account's - /// id lets the Integrate planner see the sequences it owns (sending into one it neither owns nor may edit is refused). + /// What the planners know of this PC and the signed-in account. OwnsOrAdmin is the admin role only (Manage users, which + /// only Admin holds): the server deletes frames of a sequence for its owner or an admin only, so ownership is decided per + /// sequence from its owner and the account's id (sending into one it neither owns nor may edit is refused as well). /// private CopyPlanContext CopyContext(ISyncRemote? remote) { @@ -265,7 +265,7 @@ public sealed class AppServices : IAsyncDisposable bool Has(Permissions p) => (permissions & (long)p) != 0; var originals = Settings.KnownServers.Select(k => k.OriginalsArchiveId).OfType().ToHashSet(); return new CopyPlanContext(System.Environment.MachineName, remote is null ? null : Server.ServerName, rights.CanUpload, rights.CanFetchOriginals, - rights.CanEdit, Has(Permissions.Delete), Has(Permissions.Delete) || Has(Permissions.ManageArchive) || Has(Permissions.ManageUsers), + rights.CanEdit, Has(Permissions.Delete), string.Equals(user?.Role, "Admin", StringComparison.OrdinalIgnoreCase) || Has(Permissions.ManageUsers), remote is not null && Sync.HasProjects, user is { QuotaBytes: > 0 } ? Math.Max(0, user.QuotaBytes - user.UsedBytes) : null, new HashSet(), originals) { diff --git a/src/Chronos.App/Sections/SequencePickerView.xaml b/src/Chronos.App/Sections/SequencePickerView.xaml index 9f0063cc..16acbdab 100644 --- a/src/Chronos.App/Sections/SequencePickerView.xaml +++ b/src/Chronos.App/Sections/SequencePickerView.xaml @@ -103,8 +103,9 @@ lib:ThumbnailLoading.Width="64" DataContext="{Binding Sequence}"> - - + + diff --git a/src/Chronos.App/Sections/SequencePickerViewModel.cs b/src/Chronos.App/Sections/SequencePickerViewModel.cs index a3e74fd4..7a94ae3b 100644 --- a/src/Chronos.App/Sections/SequencePickerViewModel.cs +++ b/src/Chronos.App/Sections/SequencePickerViewModel.cs @@ -9,6 +9,7 @@ using Chronos.Core.Diagnostics; using Chronos.Core.Model; using Chronos.Data; using Chronos.Data.Repositories; +using Chronos.Data.Workspaces; using Chronos.Ui.Mvvm; namespace Chronos.App.Sections; @@ -326,6 +327,28 @@ public sealed class SequencePickerViewModel : LocalizedViewModel _workspaceStates = ReadStatesAsync(items, generation); } + /// + /// Lists as the Workspace group, each , then marks their twins. Design + /// time only: a capture has no workspace (), so its edit-picker-twins scene lists + /// sample projects of the sample matches. + /// + internal async Task ShowSampleWorkspaceAsync(IReadOnlyList entries, WorkspaceStatus status) + { + if (Shell.Services.Database is not { } db) return; + var items = new List(); + foreach (var entry in entries) + { + var row = await db.Sequences.GetAsync(entry.SequenceId); + items.Add(new WorkspaceProjectItem(entry, row is null ? null : new SequenceItem(row, Shell.Services.Thumbnails)) { Status = status }); + } + WorkspaceItems.Clear(); + foreach (var item in items) WorkspaceItems.Add(item); + SelectedProject = WorkspaceItems.FirstOrDefault(); + OnPropertyChanged(nameof(HasWorkspaceItems)); + RaiseStates(); + await MarkTwinsAsync(items); + } + /// /// Marks the projects whose time-lapse (a linked or integrated match) has a workspace project at the other home too /// (owner review 6, #73): a muted Twin chip, "Also at {home}: {project}". diff --git a/src/Chronos.App/Sections/ServerView.xaml b/src/Chronos.App/Sections/ServerView.xaml index 7f2cd0f1..a914444a 100644 --- a/src/Chronos.App/Sections/ServerView.xaml +++ b/src/Chronos.App/Sections/ServerView.xaml @@ -311,24 +311,34 @@ keeps its 10 px scroll-bar gutter and the header the same on its right, so the columns line up with or without scrolling. --> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -399,10 +409,10 @@ + + - - - + diff --git a/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs b/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs index cea7934e..6712417f 100644 --- a/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs +++ b/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs @@ -225,6 +225,19 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel /// A merge keeping the pair's other sequence: the review compares the pair's first with it, so its two columns swap. private bool Swapped => IsMerge && _keepId is { } keep && keep == Copy.OtherId; + /// A merge with no kept sequence yet: the photo sides read as the two archives' names, not as Kept and Other. + private (string Here, string There)? Places => IsMerge && _keepId is null ? (Here.Where, There.Where) : null; + + /// The class rows follow the kept sequence (or the places while none is kept). + private void OrientClasses() + { + foreach (var row in _classes) + { + row.Swapped = Swapped; + row.Places = Places; + } + } + // ---- Projects ---- /// 0 Copy across, 1 Leave them (a merge always copies: its other home goes to the trash). @@ -267,6 +280,15 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel public string ThereHeading => IsMerge ? DroppedFacts?.Where ?? There.Where : Loc.L("Server.Copies.Plan.OnServer", ServerName); + /// + /// The Projects part's first list: this PC's, or the pair's first sequence's. The lists stay where the review put them + /// whichever sequence is kept, so their headings name the place, not the role. + /// + public string ProjectsHereHeading => IsMerge ? Here.Where : Loc.L("Server.Copies.Plan.OnThisPc"); + + /// The Projects part's second list: the server's, or the pair's other sequence's. + public string ProjectsThereHeading => IsMerge ? There.Where : Loc.L("Server.Copies.Plan.OnServer", ServerName); + public bool IsPlanning { get => _isPlanning; @@ -312,12 +334,24 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel { _review = await _engine.CompareAsync(Copy.Id, Copy.Kind == CopyKind.LocalServer ? _shell.Services.Sync.Remote : null, CancellationToken.None); if (IsClosed) return; + if (IsMerge && _keepId is null) + { + // The sequence the merge keeps by default is known before the first plan: the photos read Kept and Other + // from the start (both sides equal in every way: they name the archives until the user keeps one). + var merge = await _engine.PlanMergeAsync(Copy.Id, null, MergeChoices(), CancellationToken.None); + if (IsClosed) return; + if (!merge.Blocks.Contains(CopyBlock.KeptUnchosen) && merge.KeepId != Guid.Empty) + { + _keepId = merge.KeepId; + _merge = merge; + } + } Build(_review); if ((_plan?.Projects ?? _merge?.Projects) is { } steps) SetProjectTargets(steps); IsLoaded = true; if (_integrate && _part == CopyDialogPart.Plan && Unchosen > 0) _part = CopyDialogPart.Details; OnAllPropertiesChanged(); - if (_part == CopyDialogPart.Plan) SchedulePlan(TimeSpan.Zero); + if (_part is CopyDialogPart.Plan or CopyDialogPart.Projects) SchedulePlan(TimeSpan.Zero); } catch (Exception ex) when (Expected(ex)) { @@ -353,7 +387,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel private void Build(CopyReview review) { - Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t, _policy.Value, IsMerge) { Swapped = Swapped })]; + Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t, _policy.Value, IsMerge) { Swapped = Swapped, Places = Places })]; _class = _classes.FirstOrDefault(c => c.Class == _startClass) ?? _classes.FirstOrDefault(c => c.Class is not (PhotoClass.Same or PhotoClass.Converted)) ?? _classes.FirstOrDefault(); @@ -377,10 +411,11 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel foreach (var row in _details) row.SetQuietly(chosen.GetValueOrDefault(row.Path, -1)); } - /// The kept sequence changed sides: the columns follow it. - private void Reorient(bool wasSwapped) + /// The kept sequence changed sides (or was first chosen): the columns and the photo sides follow it. + private void Reorient(bool wasSwapped, bool wasKnown) { - if (wasSwapped == Swapped || _review is not { } review) return; + OrientClasses(); + if ((wasSwapped == Swapped && wasKnown == _keepId.HasValue) || _review is not { } review) return; BuildDetails(review); BuildPhotos(); } @@ -396,7 +431,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel : [.. review.Photos.Of(cls.Value).Select(p => new CopyPhotoRow(p, IsMerge, choosing && !IsMerge && cls is PhotoClass.OnlyHere or PhotoClass.OnlyThere, choosing && cls == PhotoClass.Differs, choices, _perPhoto.TryGetValue(p.Key, out var c) ? c : null, () => OnPhotoChanged(p.Key), drop, - Swapped))]; + Swapped, Places))]; foreach (var row in _photos) row.PropertyChanged += (_, e) => { if (e.PropertyName != nameof(CopyPhotoRow.IsSelected)) return; @@ -441,10 +476,10 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel private void Keep(CopyKeepOption option) { var wasSwapped = Swapped; + var wasKnown = _keepId.HasValue; _keepId = option.SequenceId; foreach (var other in _keep.Where(o => !ReferenceEquals(o, option))) other.SetQuietly(false); - foreach (var row in _classes) row.Swapped = Swapped; - Reorient(wasSwapped); + Reorient(wasSwapped, wasKnown); RaiseHeadings(); Changed(); } @@ -524,8 +559,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel var wasSwapped = Swapped; _keepId = merge.KeepId; foreach (var option in _keep) option.SetQuietly(option.SequenceId == _keepId); - foreach (var row in _classes) row.Swapped = Swapped; - Reorient(wasSwapped); + Reorient(wasSwapped, wasKnown: false); } } else if (_shell.Services.Sync.Remote is { } remote && string.Equals(_shell.Services.Sync.Server, Copy.Server, StringComparison.OrdinalIgnoreCase)) @@ -583,8 +617,11 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel Trash(plan.Photos, PhotoAction.TrashThere, there); Photos(plan.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, PhotoAction.TrashHere, "Server.Copies.Plan.Receives", here); Photos(plan.Photos, PhotoAction.Send, PhotoAction.SendVersion, PhotoAction.TrashThere, "Server.Copies.Plan.Receives", there); - var versions = plan.Photos.Count(p => p.Action == PhotoAction.SendVersion); + // Only the versions whose server version is trashed there or excluded from its Main (both kept, or one that stays + // for want of the Delete right): a server version that could not be excluded stays in use. + var versions = plan.ServerUsesOurs; if (versions > 0) there.Add(new(Loc.Plural("Server.Copies.Plan.ServerUsesOurs", versions, ServerName), Loc.L("Tooltips.Server.Copies.Plan.ServerUsesOurs"))); + if (plan.StaysForDelete > 0) there.Add(new(Loc.Plural("Server.Copies.Plan.NeedsDelete", plan.StaysForDelete), IsWarning: true)); // A detail changes on the side that does not keep its own value: this PC takes the server's, the server this PC's. var toHere = _details.Where(d => d.Chosen == CopySide.Other).SelectMany(d => d.Paths).Distinct(StringComparer.Ordinal).Count(); var toThere = _details.Where(d => d.Chosen == CopySide.ThisPc).SelectMany(d => d.Paths).Distinct(StringComparer.Ordinal).Count(); diff --git a/src/Chronos.App/Server/Copies/CopyDialogs.xaml b/src/Chronos.App/Server/Copies/CopyDialogs.xaml index 8bf47d7b..a82d026a 100644 --- a/src/Chronos.App/Server/Copies/CopyDialogs.xaml +++ b/src/Chronos.App/Server/Copies/CopyDialogs.xaml @@ -63,10 +63,10 @@ - - - - + + + + @@ -130,40 +130,58 @@ ToolTip="{l:Loc Tooltips.Server.Copies.DeleteOnServer}" ToolTipService.ShowOnDisabled="True" Visibility="{Binding CanDeleteThere, Converter={StaticResource CopyBoolToVisibility}}" /> - - - - - - - - - - - - - - - - - - - -