fix: phase 5a fix round 3, desktop: newer copies, readable discard, working-state conflicts, edits kept aside
Owner review 2, R8. Round 2's checkers left five desktop problems: - A workspace copy whose project.chronos a newer Chronos wrote (a format this one does not know) was listed as damaged and offered for Discard. It is now listed as "Newer Chronos" with its own tooltip, named from what of its file still reads. It never opens, is never checked out over, and Remove local copy refuses it with a sentence that says why. - Discard of any copy moved only the files Chronos knows. It now moves every file and folder of the copy aside (only the media are deleted) and removes the folder only when nothing else came into it. - Discarding a damaged copy asked to type its folder's GUID. It now asks for the name the copy is still known by (its file, else the library's index; the project's name, else the sequence's title), else for the number of its files. The heading never shows the id. - A conflict at a path where the working state had gone back to the base value listed the local version's value. The conflict now lists the working state's value in every case. Where the working state already holds the library's value there is nothing to ask: that path takes the library's value in the replayed versions too, so they agree. - EditorSession.ReloadAsync, ResolveConflict and TakeOverAsync threw NewerSettingsException on every reload when an edit was not stored yet and the stored project became a newer Chronos's. The edit is now kept in versions/.replaced (outside the chain, never sent), a toast says so, the pending save is dropped and the newer settings are shown read-only. When the edit cannot be kept aside, the editor stays as it is and nothing is dropped. The SequenceViewModel wiring now has a view-model test: the copy's facts in Open in workspace, the refused-folder toast and its Choose folder action, and the picker for a newer copy and a damaged one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
488b588ad9
commit
e8ea858021
21 files changed
+696
-54
No files matched your search
@@ -446,7 +446,9 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
/// only when they are those <paramref name="shown"/> lists (others are recorded and asked about first, as without a
|
||||
/// choice). Taking the server's everywhere tells <paramref name="kept"/> the working state as keeping this side's values
|
||||
/// would have left it (placed), and the working state it replaces is kept aside (<c>versions/.replaced</c>), never in the
|
||||
/// chain. A conflict recorded before stays when the home holds no version after the base (it lost them: nothing to
|
||||
/// chain. A conflict lists this side's value as the working state holds it, the base value it went back to included; where
|
||||
/// the working state holds the home's value already there is nothing to ask, and the replayed versions take that value
|
||||
/// too. A conflict recorded before stays when the home holds no version after the base (it lost them: nothing to
|
||||
/// settle it against).
|
||||
/// Written in steps a cut can stop at any point (<see cref="WorkspaceReplay"/>): the journal, the replayed versions, the
|
||||
/// base with the merged working state (the commit point), then the old versions set aside and the held ones adopted.
|
||||
@@ -500,6 +502,16 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var choice = takeTheirs is EveryPath ? null : takeTheirs;
|
||||
List<ProjectSettings> mine = [.. locals.Select(v => ProjectMerge.Read(ProjectContent.Rebind(v.SettingsJson, photos)))];
|
||||
var replay = ProjectMerge.Replay(basisSettings, mine, headSettings, choice);
|
||||
// Where the working state holds the home's value already, the user has nothing to choose: the home's value is taken
|
||||
// there, in the replayed versions too, so they and the working state agree (never asked, never listed).
|
||||
var workingSide = WorkingConflicts(tip, working, basisSettings, headSettings);
|
||||
var silent = replay.Conflicts.Concat(ProjectMerge.Conflicts(tip, working, replay.Commits.Count > 0 ? replay.Commits[^1] : headSettings))
|
||||
.Select(d => d.Path).Where(p => !workingSide.Keys.Any(q => Overlaps(p, q))).ToHashSet(StringComparer.Ordinal);
|
||||
if (silent.Count > 0)
|
||||
{
|
||||
choice = choice is null ? silent : new HashSet<string>(choice.Concat(silent), StringComparer.Ordinal);
|
||||
replay = ProjectMerge.Replay(basisSettings, mine, headSettings, choice);
|
||||
}
|
||||
// This side's values wherever both changed: what taking the server's everywhere replaces (the editor's undo of it).
|
||||
var keptTip = replay.Commits.Count > 0 ? replay.Commits[^1] : headSettings;
|
||||
if (takeTheirs is EveryPath) replay = ProjectMerge.Replay(basisSettings, mine, headSettings, Paths(replay.Conflicts));
|
||||
@@ -507,8 +519,7 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var merge = ProjectMerge.MergeWithConflicts(tip, working, newTip, choice);
|
||||
var keptMine = takeTheirs is EveryPath ? ProjectMerge.MergeWithConflicts(tip, working, keptTip).Merged : merge.Merged;
|
||||
if (takeTheirs is EveryPath) merge = ProjectMerge.MergeWithConflicts(tip, working, newTip, Paths(merge.Conflicts));
|
||||
var differences = AsInTheWorkingState(replay.Conflicts.Concat(merge.Conflicts).DistinctBy(d => d.Path),
|
||||
ProjectMerge.Conflicts(basisSettings, working, headSettings));
|
||||
var differences = AsInTheWorkingState(replay.Conflicts.Concat(merge.Conflicts).DistinctBy(d => d.Path).Where(d => !silent.Contains(d.Path)), workingSide);
|
||||
if (differences.Count > 0 && (takeTheirs is null || (shown is not null && !SameDifferences(shown.Differences, differences))))
|
||||
{
|
||||
var conflict = new WorkspaceConflict(head.Id, head.Number, basis?.Id ?? Guid.Empty, [.. locals.Select(v => v.Id)], differences, DateTimeOffset.UtcNow);
|
||||
@@ -1111,14 +1122,25 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
|
||||
/// <summary>
|
||||
/// The conflicts found as the user sees them: where the working state holds a value of its own against the home's
|
||||
/// (<paramref name="working"/>: edited since the last local version), that value is this side's, not the version's.
|
||||
/// (<paramref name="working"/>, <see cref="WorkingConflicts"/>), that value is this side's, not the version's.
|
||||
/// Keeping mine keeps it, and taking the server's replaces it, so one answer settles what was listed.
|
||||
/// </summary>
|
||||
private static List<SettingsDifference> AsInTheWorkingState(IEnumerable<SettingsDifference> found, IReadOnlyList<SettingsDifference> working)
|
||||
{
|
||||
var now = working.DistinctBy(d => d.Path).ToDictionary(d => d.Path, StringComparer.Ordinal);
|
||||
return [.. found.Select(d => now.TryGetValue(d.Path, out var held) ? held : d)];
|
||||
}
|
||||
private static List<SettingsDifference> AsInTheWorkingState(IEnumerable<SettingsDifference> found, IReadOnlyDictionary<string, SettingsDifference> working) =>
|
||||
[.. found.Select(d => working.TryGetValue(d.Path, out var held) ? held : d)];
|
||||
|
||||
/// <summary>
|
||||
/// The settings where the working state holds a value of its own against the home's head, by path: against the last
|
||||
/// local version (<paramref name="tip"/>: edited since it, the base value it went back to included), else against the
|
||||
/// base (the version's value, unchanged since). A conflict at a path neither lists has the home's value in the working
|
||||
/// state already.
|
||||
/// </summary>
|
||||
private static Dictionary<string, SettingsDifference> WorkingConflicts(ProjectSettings tip, ProjectSettings working, ProjectSettings basis, ProjectSettings head) =>
|
||||
ProjectMerge.Conflicts(tip, working, head).Concat(ProjectMerge.Conflicts(basis, working, head)).DistinctBy(d => d.Path)
|
||||
.ToDictionary(d => d.Path, StringComparer.Ordinal);
|
||||
|
||||
/// <summary>Two merge paths name the same setting, or one lies inside the other ("camera" and "camera.aspect").</summary>
|
||||
private static bool Overlaps(string a, string b) =>
|
||||
a == b || a.StartsWith(b + ".", StringComparison.Ordinal) || b.StartsWith(a + ".", StringComparison.Ordinal);
|
||||
|
||||
/// <summary>Whether two conflicts list the same settings with the same values on each side (in any order).</summary>
|
||||
private static bool SameDifferences(IReadOnlyList<SettingsDifference> shown, IReadOnlyList<SettingsDifference> found) =>
|
||||
|
||||
Reference in new issue
Block a user