fix(workspace): settle only the conflict shown, keep what a choice replaces, desktop gaps of phase 5a
Review 2, phase 5a, fix round 1 (desktop and the engine side of Resolve and Restore). - Resolve applies Keep mine / Take the library's only to the conflict the dialog listed: when the head or what differs moved since, the new conflict is recorded and asked again; Sync re-works a pending conflict instead of re-showing a stale list. Take the library's first saves uncommitted changes as a version, and the editor takes it as one undo step (toast Undo, Ctrl+Z) that brings back only the settings both changed. - Restore saves unsaved changes as a version also while a conflict waits; a restore that changed nothing, or was undone, no longer marks the next version as a Restore. - The editor's saves and merges of a workspace project merge positions photo by photo (portable form) and ask where both sides changed a setting, never deciding for ours. - Read-only after a pull is signalled, and no save that can never be stored is left behind. - The chip is read again after edits; a background conflict waits for the open dialog; Send first and Delete show the conflict they met; Discard changes needs the typed name. - Open project... reaches the library's other projects (Save both's sibling, also from its toast); copies whose project or sequence is gone read Not in library and can be removed from the picker's Workspace rows; a delete whose local copy stays says so. - A workspace folder inside a library is refused before anything is written. - Conflict and Compare lines name heroes, exclusions and keyframes; History shows the PC name alone, never the program's prefixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50e28fd63d
commit
8027d84f7e
28 files changed
+1321
-134
No files matched your search
@@ -46,7 +46,8 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
Source = source;
|
||||
_codecs = codecs ?? [];
|
||||
_basis = content.Project;
|
||||
History = new ProjectHistory(content.Project);
|
||||
// Undo steps take outside changes as the source merges them (a workspace project: positions photo by photo).
|
||||
History = new ProjectHistory(content.Project, merge: (basis, ours, theirs) => source.Merge(basis, ours, theirs).Merged);
|
||||
History.Changed += OnProjectChanged;
|
||||
_saver = new ProjectSaver(SaveAsync, saveDelay ?? DefaultSaveDelay);
|
||||
_saver.Failed += OnSaveFailed;
|
||||
@@ -190,10 +191,11 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settles <see cref="Conflict"/> against the server's settings as the last save read them. Both choices first take
|
||||
/// in what only the server changed (like any merge, without an undo step). <paramref name="keepMine"/> then saves
|
||||
/// the editor's values of the settings both changed; otherwise the server's values become the project as one
|
||||
/// undoable step, so Ctrl+Z brings the editor's back (and saves them).
|
||||
/// Settles <see cref="Conflict"/> against the settings stored meanwhile (the server's, a workspace's working state a sync
|
||||
/// wrote) as the last save read them. Both choices first take in what only the other side changed (like any merge,
|
||||
/// without an undo step). <paramref name="keepMine"/> then saves the editor's values of the settings both changed;
|
||||
/// otherwise the other side's values become the project as one undoable step, so Ctrl+Z brings the editor's back (and
|
||||
/// saves them).
|
||||
/// </summary>
|
||||
/// <returns>False when there is no conflict to settle (a later save already went through).</returns>
|
||||
public bool ResolveConflict(bool keepMine)
|
||||
@@ -202,8 +204,8 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
Conflict = null;
|
||||
var basis = _basis;
|
||||
_basis = theirs;
|
||||
History.Replace(ProjectMerge.Merge(basis, Project, theirs));
|
||||
if (!keepMine) History.Apply(ProjectMerge.Merge(basis, theirs, Project));
|
||||
History.Replace(Source.Merge(basis, Project, theirs).Merged);
|
||||
if (!keepMine) History.Apply(Source.Merge(basis, theirs, Project).Merged);
|
||||
// The change waiting for its retry goes now, on top of the server's settings.
|
||||
_ = _saver.FlushAsync();
|
||||
return true;
|
||||
@@ -245,13 +247,13 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
{
|
||||
var content = await Source.LoadAsync(cancellationToken);
|
||||
Follow(content);
|
||||
// A server's settings that conflict with the editor's waiting change are not merged over it: that change's
|
||||
// retry meets them and asks (Conflict).
|
||||
if (Conflict is null && (!IsRemote || ProjectMerge.Conflicts(_basis, Project, content.Project).Count == 0))
|
||||
// Settings a server or a sync stored that conflict with the editor's waiting change are not merged over it: that
|
||||
// change's retry meets them and asks (Conflict).
|
||||
var merge = Conflict is null ? Source.Merge(_basis, Project, content.Project) : null;
|
||||
if (merge is not null && (!Source.AsksConflicts || !merge.HasConflicts))
|
||||
{
|
||||
var merged = ProjectMerge.Merge(_basis, Project, content.Project);
|
||||
_basis = content.Project;
|
||||
History.Replace(merged);
|
||||
History.Replace(merge.Merged);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -261,6 +263,38 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
ContentChanged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the project again after the user took the other side's values of the settings both changed (a workspace
|
||||
/// project's "Take the library's", settled by its sync): what only the other side changed comes in as any merge does,
|
||||
/// without an undo step (<paramref name="kept"/>: the stored project as keeping the editor's values would have left
|
||||
/// it), then the values taken become the project as one undoable step, so Ctrl+Z brings the editor's back (and saves
|
||||
/// them), as <see cref="ResolveConflict"/> does for a server's.
|
||||
/// </summary>
|
||||
/// <returns>That step, which a toast's Undo can take back while it is the last change; null when it changed nothing.</returns>
|
||||
public async Task<ProjectRestore?> TakeOverAsync(ProjectSettings kept, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(kept);
|
||||
await _saver.FlushAsync();
|
||||
var taken = await BeginReadAsync();
|
||||
ProjectRestore? step = null;
|
||||
try
|
||||
{
|
||||
var content = await Source.LoadAsync(cancellationToken);
|
||||
Follow(content);
|
||||
var basis = _basis;
|
||||
_basis = content.Project;
|
||||
History.Replace(Source.Merge(basis, Project, kept).Merged);
|
||||
var before = Project;
|
||||
if (!IsReadOnly && History.Apply(Source.Merge(kept, Project, content.Project).Merged)) step = new ProjectRestore(this, before, Project);
|
||||
}
|
||||
finally
|
||||
{
|
||||
taken.SetResult();
|
||||
}
|
||||
ContentChanged?.Invoke();
|
||||
return step;
|
||||
}
|
||||
|
||||
/// <summary>Stores pending changes now; false when the save failed (the change stays pending and is retried).</summary>
|
||||
public Task<bool> FlushAsync() => _saver.FlushAsync();
|
||||
|
||||
@@ -357,7 +391,9 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
|
||||
private void OnProjectChanged()
|
||||
{
|
||||
_saver.Schedule(Project);
|
||||
// A read-only project takes what is read again (a workspace pull of a newer Chronos's settings) without a save that
|
||||
// could never be stored and would be retried for ever.
|
||||
if (!IsReadOnly) _saver.Schedule(Project);
|
||||
ProjectChanged?.Invoke();
|
||||
}
|
||||
|
||||
@@ -410,7 +446,7 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
Conflict = null;
|
||||
_basis = stored;
|
||||
// Someone else's change was merged in: show it without an undo step (edits made since the save are kept).
|
||||
if (!ProjectMerge.SameValues(stored, project)) History.Replace(ProjectMerge.Merge(project, Project, stored));
|
||||
if (!ProjectMerge.SameValues(stored, project)) History.Replace(Source.Merge(project, Project, stored).Merged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user